Re: Get the newest file in a directory



g_file_info_get_modification_time is marked as (out caller-allocates).
So you would use:

    let infoTimeVal = info.get_modification_time();

On Thu, Feb 2, 2012 at 11:35 AM, Stefano Ciancio <s ciancio gmail com> wrote:
> Hi all,
>
> in shell extension I'll try to determine the newest file present in a
> directory.
>
> I have used this code:
>
>    let dir = Gio.file_new_for_path(bookmarkDir);
>    var backupEnum =
> dir.enumerate_children('standard::name,standard::type,time::modified',
> Gio.FileQueryInfoFlags.NONE, null);
>
>    let infoTimeVal = new GLib.TimeVal();
>    let max = 0;
>    let info;
>
>    while ((info = backupEnum.next_file(null)) != null) {
>       let type = info.get_file_type();
>        if (type == Gio.FileType.REGULAR) {
>
>          info.get_modification_time(infoTimeVal);
>
>          if (infoTimeVal.tv_sec > max) {
>            max = infoTimeVal.tv_sec;
>             var lastFile = info;
>          }
>        }
>    }
>    backupEnum.close(null);
>
> I my system (F16) it works correctly, but in a Debian (I don't know version)
> the command info.get_modification_time(infoTimeVal) return zero in
> infoTimeVal.tv_sec variable.
>
> There is something I'm missing? Can I obtain the same results in other ways.
>
> Thanks.
> _______________________________________________
> gnome-shell-list mailing list
> gnome-shell-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-shell-list



-- 
  Jasper


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]