Re: [Vala] Get CREATION DATE OR TIME of file

2016-01-14 Thread Dev_NIX
Be careful, Gmail marked me this mail as spam, don't know why.

--

*   EOF   *

2016-01-09 15:25 GMT+01:00 Mario Daniel Ruiz Saavedra <
desideran...@rocketmail.com>:

> It's not currently possible to do that on most systems, take a look
> at File creation times [LWN.net]
> |   |
> |   |   |   |   |   |
> | File creation times [LWN.net]By Jonathan Corbet July 26, 2010 Linux
> systems, like the Unix systems that came before, maintain threedifferent
> timestamps for each file.  |
> |  |
> | Ver en lwn.net | Vista previa por Yahoo |
> |  |
> |   |
>
>
>
> Mario Daniel Ruiz Saavedra  Estudiante Ing. Sistemas - Universidad del
> Norte mru...@uninorte.edu.co - twitter.com/desiderantes -
> joindiaspora.com/u/desiderantes
>
> El Sábado, 9 de enero, 2016 8:34:17, raum  escribió:
>
>
>
>  Hi,
>
> Problem between windows and linux API,  probably...
>
> Either you can take a look to one of my project wich worked on linux
>
> https://github.com/Raumy/check_fs
>
> Regards
> Le 9 janv. 2016 10:30, Chris Daley  a écrit :
> >
> > Hi all,
> >
> > One possible solution to this problem that would be Windows only is to
> > retrieve the file creation date via the Windows API. The following code
> is
> > untested as I am still setting up my Winodws VM but you might be able to
> > try it out in the meantime. You will need to install the Windows SDK if
> you
> > haven't already and I assume you are using mingw. A caveat, I haven't
> used
> > the Windows API in a long time so you may need to double check the
> headers
> > to make sure the function definitions are correct - this is for version
> > 7.0. I'm assuming it's possible, as the parts of the Windows API you
> would
> > be linking to are C libraries and this is more or less how you would do
> it
> > in C# but like I said - this is an untested thought experiment that might
> > be a total NO-OP. The only thing I could find on the internets was from
> the
> > mailing list quite a few years back -
> > http://comments.gmane.org/gmane.comp.programming.vala/2867 - but it does
> > suggest that this is entirely possible.
> >
> > Anyway, the code...
> >
> > // All of this is Windows API definitions which could be put into a
> > separate vapi
> >
> > // The CreateFile flag for reading
> > const int64 GENERIC_READ = 0x8000;
> >
> > // Contains a 64-bit value representing the number of 100-nanosecond
> > intervals since January 1, 1601 (UTC).
> > struct FileTime {
> > // The low-order part of the file time.
> > int64 dwLowDateTime;
> > // The high-order part of the file time.
> > int64 dwHighDateTime;
> > }
> >
> > struct SystemTime {
> >int64 wYear;
> >int64 wMonth;
> >int64 wDayOfWeek;
> >int64 wDay;
> >int64 wHour;
> >int64 wMinute;
> >int64 wSecond;
> >int64 wMilliseconds;
> > }
> >
> > [CCode(cheader_filename = "WinBase.h ")]
> > public extern bool GetFileTime(void* file_handle,
> > out lpCreationTime,
> > out lpLastAccessTime,
> > out lpLastWriteTime
> > );
> >
> > [CCode(cheader_filename = "WinBase.h ")]
> > public extern void CreateFile(
> > string lpFileName,
> > int64 dwDesiredAccess,
> > int64 dwShareMode,
> > void* lpSecurityAttributes,
> > int64 dwCreationDisposition,
> > int64 dwFlagsAndAttributes,
> > void* hTemplateFile
> > );
> >
> > [CCode(cheader_filename = "WinBase.h ")]
> > public extern bool FileTimeToSystemTime (FileTime filetime, out
> SystemTime);
> >
> > public static int main (string[] args) {
> >
> >void* testfile = CreateFile("./test.vala", GENERIC_READ,0, null, 0, 0,
> > null);
> >FileTime time;
> >bool success = GetFileTime(testfile,out time, null, null);
> >
> > if (success) {
> >SystemTime systime;
> >FileTimeToSystemTime (time, out systime);
> >message ("Success: File created on %02d/%02d/%d %02d:%02d",
> > systime.wMonth, systime.wDay, systime.wYear, systime.wHour,
> > systime.wMinute);
> > } else {
> >   message ("Something went wrong");
> >}
> > }
> >
> > This would need to be compiled with the right paths set to the Windows
> SDK
> > location and linked against Kernel32.lib.
> >
> > Like I said, it's untested (yet) and I won't have time until next week to
> > look at it again, so caveat emptor. If you're wanting to make a nicer
> > demonstration out of it, you could save the Windows extern functions and
> > struct definitions to a vapi file - like windows.vapi - to make it look
> > less complicated (which it is, compared to the C code that would achieve
> > the same effect).
> >
> > Let me know if you have any success.
> >
> > Cheers
> > Chris
> >
> > 2016-01-08 12:35 GMT-08:00 Edwin De La Cruz :
> >
> > > Lametablemente no way? At least not directly using Vala , I understand
> > > what I have read so far.
> > > I keep looking for any option , since it was very important for me to
> > > do in Vala and convince some people that language worth learning ...
> > > I'll keep looking.
> > > Mis proyectos de soft

Re: [Vala] Get CREATION DATE OR TIME of file

2016-01-09 Thread Mario Daniel Ruiz Saavedra
It's not currently possible to do that on most systems, take a look at File 
creation times [LWN.net]
|   |
|   |   |   |   |   |
| File creation times [LWN.net]By Jonathan Corbet July 26, 2010 Linux systems, 
like the Unix systems that came before, maintain threedifferent timestamps for 
each file.  |
|  |
| Ver en lwn.net | Vista previa por Yahoo |
|  |
|   |


 
Mario Daniel Ruiz Saavedra  Estudiante Ing. Sistemas - Universidad del Norte 
mru...@uninorte.edu.co - twitter.com/desiderantes -
joindiaspora.com/u/desiderantes 

El Sábado, 9 de enero, 2016 8:34:17, raum  escribió:
 
 

 Hi,

Problem between windows and linux API,  probably...

Either you can take a look to one of my project wich worked on linux

https://github.com/Raumy/check_fs

Regards
Le 9 janv. 2016 10:30, Chris Daley  a écrit :
>
> Hi all,
>
> One possible solution to this problem that would be Windows only is to
> retrieve the file creation date via the Windows API. The following code is
> untested as I am still setting up my Winodws VM but you might be able to
> try it out in the meantime. You will need to install the Windows SDK if you
> haven't already and I assume you are using mingw. A caveat, I haven't used
> the Windows API in a long time so you may need to double check the headers
> to make sure the function definitions are correct - this is for version
> 7.0. I'm assuming it's possible, as the parts of the Windows API you would
> be linking to are C libraries and this is more or less how you would do it
> in C# but like I said - this is an untested thought experiment that might
> be a total NO-OP. The only thing I could find on the internets was from the
> mailing list quite a few years back -
> http://comments.gmane.org/gmane.comp.programming.vala/2867 - but it does
> suggest that this is entirely possible.
>
> Anyway, the code...
>
> // All of this is Windows API definitions which could be put into a
> separate vapi
>
> // The CreateFile flag for reading
> const int64 GENERIC_READ = 0x8000;
>
> // Contains a 64-bit value representing the number of 100-nanosecond
> intervals since January 1, 1601 (UTC).
> struct FileTime {
>     // The low-order part of the file time.
>     int64 dwLowDateTime;
>     // The high-order part of the file time.
>     int64 dwHighDateTime;
> }
>
> struct SystemTime {
>    int64 wYear;
>    int64 wMonth;
>    int64 wDayOfWeek;
>    int64 wDay;
>    int64 wHour;
>    int64 wMinute;
>    int64 wSecond;
>    int64 wMilliseconds;
> }
>
> [CCode(cheader_filename = "WinBase.h ")]
> public extern bool GetFileTime(void* file_handle,
>     out lpCreationTime,
>     out lpLastAccessTime,
>     out lpLastWriteTime
> );
>
> [CCode(cheader_filename = "WinBase.h ")]
> public extern void CreateFile(
>     string lpFileName,
>     int64 dwDesiredAccess,
>     int64 dwShareMode,
>     void* lpSecurityAttributes,
>     int64 dwCreationDisposition,
>     int64 dwFlagsAndAttributes,
>     void* hTemplateFile
> );
>
> [CCode(cheader_filename = "WinBase.h ")]
> public extern bool FileTimeToSystemTime (FileTime filetime, out SystemTime);
>
> public static int main (string[] args) {
>
>    void* testfile = CreateFile("./test.vala", GENERIC_READ,0, null, 0, 0,
> null);
>    FileTime time;
>    bool success = GetFileTime(testfile,out time, null, null);
>
>     if (success) {
>    SystemTime systime;
>    FileTimeToSystemTime (time, out systime);
>    message ("Success: File created on %02d/%02d/%d %02d:%02d",
> systime.wMonth, systime.wDay, systime.wYear, systime.wHour,
> systime.wMinute);
>     } else {
>   message ("Something went wrong");
>    }
> }
>
> This would need to be compiled with the right paths set to the Windows SDK
> location and linked against Kernel32.lib.
>
> Like I said, it's untested (yet) and I won't have time until next week to
> look at it again, so caveat emptor. If you're wanting to make a nicer
> demonstration out of it, you could save the Windows extern functions and
> struct definitions to a vapi file - like windows.vapi - to make it look
> less complicated (which it is, compared to the C code that would achieve
> the same effect).
>
> Let me know if you have any success.
>
> Cheers
> Chris
>
> 2016-01-08 12:35 GMT-08:00 Edwin De La Cruz :
>
> > Lametablemente no way? At least not directly using Vala , I understand
> > what I have read so far.
> > I keep looking for any option , since it was very important for me to
> > do in Vala and convince some people that language worth learning ...
> > I'll keep looking.
> > Mis proyectos de software libre en:
> > Github - edwinspire
> >
> >
> > 2016-01-08 9:04 GMT-05:00 Luc Chante :
> > > Hi,
> > >
> > > You can test le file a attached to this mail.
> > >
> > > T
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


 
  
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listi

Re: [Vala] Get CREATION DATE OR TIME of file

2016-01-09 Thread raum
Hi,

Problem between windows and linux API,  probably...

Either you can take a look to one of my project wich worked on linux

https://github.com/Raumy/check_fs

Regards
Le 9 janv. 2016 10:30, Chris Daley  a écrit :
>
> Hi all,
>
> One possible solution to this problem that would be Windows only is to
> retrieve the file creation date via the Windows API. The following code is
> untested as I am still setting up my Winodws VM but you might be able to
> try it out in the meantime. You will need to install the Windows SDK if you
> haven't already and I assume you are using mingw. A caveat, I haven't used
> the Windows API in a long time so you may need to double check the headers
> to make sure the function definitions are correct - this is for version
> 7.0. I'm assuming it's possible, as the parts of the Windows API you would
> be linking to are C libraries and this is more or less how you would do it
> in C# but like I said - this is an untested thought experiment that might
> be a total NO-OP. The only thing I could find on the internets was from the
> mailing list quite a few years back -
> http://comments.gmane.org/gmane.comp.programming.vala/2867 - but it does
> suggest that this is entirely possible.
>
> Anyway, the code...
>
> // All of this is Windows API definitions which could be put into a
> separate vapi
>
> // The CreateFile flag for reading
> const int64 GENERIC_READ = 0x8000;
>
> // Contains a 64-bit value representing the number of 100-nanosecond
> intervals since January 1, 1601 (UTC).
> struct FileTime {
>     // The low-order part of the file time.
>     int64 dwLowDateTime;
>     // The high-order part of the file time.
>     int64 dwHighDateTime;
> }
>
> struct SystemTime {
>    int64 wYear;
>    int64 wMonth;
>    int64 wDayOfWeek;
>    int64 wDay;
>    int64 wHour;
>    int64 wMinute;
>    int64 wSecond;
>    int64 wMilliseconds;
> }
>
> [CCode(cheader_filename = "WinBase.h ")]
> public extern bool GetFileTime(void* file_handle,
>     out lpCreationTime,
>     out lpLastAccessTime,
>     out lpLastWriteTime
> );
>
> [CCode(cheader_filename = "WinBase.h ")]
> public extern void CreateFile(
>     string lpFileName,
>     int64 dwDesiredAccess,
>     int64 dwShareMode,
>     void* lpSecurityAttributes,
>     int64 dwCreationDisposition,
>     int64 dwFlagsAndAttributes,
>     void* hTemplateFile
> );
>
> [CCode(cheader_filename = "WinBase.h ")]
> public extern bool FileTimeToSystemTime (FileTime filetime, out SystemTime);
>
> public static int main (string[] args) {
>
>    void* testfile = CreateFile("./test.vala", GENERIC_READ,0, null, 0, 0,
> null);
>    FileTime time;
>    bool success = GetFileTime(testfile,out time, null, null);
>
>     if (success) {
>    SystemTime systime;
>    FileTimeToSystemTime (time, out systime);
>    message ("Success: File created on %02d/%02d/%d %02d:%02d",
> systime.wMonth, systime.wDay, systime.wYear, systime.wHour,
> systime.wMinute);
>     } else {
>   message ("Something went wrong");
>    }
> }
>
> This would need to be compiled with the right paths set to the Windows SDK
> location and linked against Kernel32.lib.
>
> Like I said, it's untested (yet) and I won't have time until next week to
> look at it again, so caveat emptor. If you're wanting to make a nicer
> demonstration out of it, you could save the Windows extern functions and
> struct definitions to a vapi file - like windows.vapi - to make it look
> less complicated (which it is, compared to the C code that would achieve
> the same effect).
>
> Let me know if you have any success.
>
> Cheers
> Chris
>
> 2016-01-08 12:35 GMT-08:00 Edwin De La Cruz :
>
> > Lametablemente no way? At least not directly using Vala , I understand
> > what I have read so far.
> > I keep looking for any option , since it was very important for me to
> > do in Vala and convince some people that language worth learning ...
> > I'll keep looking.
> > Mis proyectos de software libre en:
> > Github - edwinspire
> >
> >
> > 2016-01-08 9:04 GMT-05:00 Luc Chante :
> > > Hi,
> > >
> > > You can test le file a attached to this mail.
> > >
> > > T
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Get CREATION DATE OR TIME of file

2016-01-09 Thread Chris Daley
Hi all,

One possible solution to this problem that would be Windows only is to
retrieve the file creation date via the Windows API. The following code is
untested as I am still setting up my Winodws VM but you might be able to
try it out in the meantime. You will need to install the Windows SDK if you
haven't already and I assume you are using mingw. A caveat, I haven't used
the Windows API in a long time so you may need to double check the headers
to make sure the function definitions are correct - this is for version
7.0. I'm assuming it's possible, as the parts of the Windows API you would
be linking to are C libraries and this is more or less how you would do it
in C# but like I said - this is an untested thought experiment that might
be a total NO-OP. The only thing I could find on the internets was from the
mailing list quite a few years back -
http://comments.gmane.org/gmane.comp.programming.vala/2867 - but it does
suggest that this is entirely possible.

Anyway, the code...

// All of this is Windows API definitions which could be put into a
separate vapi

// The CreateFile flag for reading
const int64 GENERIC_READ = 0x8000;

// Contains a 64-bit value representing the number of 100-nanosecond
intervals since January 1, 1601 (UTC).
struct FileTime {
// The low-order part of the file time.
int64 dwLowDateTime;
// The high-order part of the file time.
int64 dwHighDateTime;
}

struct SystemTime {
   int64 wYear;
   int64 wMonth;
   int64 wDayOfWeek;
   int64 wDay;
   int64 wHour;
   int64 wMinute;
   int64 wSecond;
   int64 wMilliseconds;
}

[CCode(cheader_filename = "WinBase.h ")]
public extern bool GetFileTime(void* file_handle,
out lpCreationTime,
out lpLastAccessTime,
out lpLastWriteTime
);

[CCode(cheader_filename = "WinBase.h ")]
public extern void CreateFile(
string lpFileName,
int64 dwDesiredAccess,
int64 dwShareMode,
void* lpSecurityAttributes,
int64 dwCreationDisposition,
int64 dwFlagsAndAttributes,
void* hTemplateFile
);

[CCode(cheader_filename = "WinBase.h ")]
public extern bool FileTimeToSystemTime (FileTime filetime, out SystemTime);



public static int main (string[] args) {

   void* testfile = CreateFile("./test.vala", GENERIC_READ,0, null, 0, 0,
null);
   FileTime time;
   bool success = GetFileTime(testfile,out time, null, null);

if (success) {
   SystemTime systime;
   FileTimeToSystemTime (time, out systime);
   message ("Success: File created on %02d/%02d/%d %02d:%02d",
systime.wMonth, systime.wDay, systime.wYear, systime.wHour,
systime.wMinute);
} else {
  message ("Something went wrong");
   }
}

This would need to be compiled with the right paths set to the Windows SDK
location and linked against Kernel32.lib.

Like I said, it's untested (yet) and I won't have time until next week to
look at it again, so caveat emptor. If you're wanting to make a nicer
demonstration out of it, you could save the Windows extern functions and
struct definitions to a vapi file - like windows.vapi - to make it look
less complicated (which it is, compared to the C code that would achieve
the same effect).

Let me know if you have any success.

Cheers
Chris


2016-01-08 12:35 GMT-08:00 Edwin De La Cruz :

> Lametablemente no way? At least not directly using Vala , I understand
> what I have read so far.
> I keep looking for any option , since it was very important for me to
> do in Vala and convince some people that language worth learning ...
> I'll keep looking.
> Mis proyectos de software libre en:
> Github - edwinspire
>
>
> 2016-01-08 9:04 GMT-05:00 Luc Chante :
> > Hi,
> >
> > You can test le file a attached to this mail.
> >
> > This is what I get (under windows with msys2 and vala 0.30) :
> >
> > $ ./test
> > ** Message: test.vala:21: FileAttribute.TIME_CREATED =>
> > FileAttributeType.INVALID
> > ** Message: test.vala:56: Can be read !!!
> > ** Message: test.vala:60: FileAttribute.TIME_CREATED =>
> > FileAttributeStatus.UNSET
> >
> > Even in C when you are looking for the creation date there is no simple
> > answer.
> >
> >
> http://unix.stackexchange.com/questions/91197/how-to-find-creation-date-of-file#91200
> >
> > Le jeu. 7 janv. 2016 à 15:27, Edwin De La Cruz  a
> > écrit :
> >>
> >> Best regards . Attempt to get the date or time unix date of creation
> >> of a file and do not get it , I used the following code :
> >>
> >>
> >> var directory = File.new_for_path (path);
> >>
> >> var fi = directory.query_info ("*", GLib.FileQueryInfoFlags.NONE);
> >>
> >>  stdout.printf ("Date %s \n", fi.get_attribute_as_string
> >> (GLib.FileAttribute.TIME_CREATED));
> >>  stdout.printf ("Date or time %s \n", fi.get_attribute_int64
> >> (GLib.FileAttribute.TIME_MODIFIED).to_string());
> >>
> >> I always returns 0 , maybe I'm not doing it correctly , be obliged his
> >> help.
> >>
> >> I'm using Windows valac - 0.26 .
> >>
> >>
> >> Mis proyectos de software libre en:
> >> Github - edwinspire
> >> ___

Re: [Vala] Get CREATION DATE OR TIME of file

2016-01-08 Thread Edwin De La Cruz
Lametablemente no way? At least not directly using Vala , I understand
what I have read so far.
I keep looking for any option , since it was very important for me to
do in Vala and convince some people that language worth learning ...
I'll keep looking.
Mis proyectos de software libre en:
Github - edwinspire


2016-01-08 9:04 GMT-05:00 Luc Chante :
> Hi,
>
> You can test le file a attached to this mail.
>
> This is what I get (under windows with msys2 and vala 0.30) :
>
> $ ./test
> ** Message: test.vala:21: FileAttribute.TIME_CREATED =>
> FileAttributeType.INVALID
> ** Message: test.vala:56: Can be read !!!
> ** Message: test.vala:60: FileAttribute.TIME_CREATED =>
> FileAttributeStatus.UNSET
>
> Even in C when you are looking for the creation date there is no simple
> answer.
>
> http://unix.stackexchange.com/questions/91197/how-to-find-creation-date-of-file#91200
>
> Le jeu. 7 janv. 2016 à 15:27, Edwin De La Cruz  a
> écrit :
>>
>> Best regards . Attempt to get the date or time unix date of creation
>> of a file and do not get it , I used the following code :
>>
>>
>> var directory = File.new_for_path (path);
>>
>> var fi = directory.query_info ("*", GLib.FileQueryInfoFlags.NONE);
>>
>>  stdout.printf ("Date %s \n", fi.get_attribute_as_string
>> (GLib.FileAttribute.TIME_CREATED));
>>  stdout.printf ("Date or time %s \n", fi.get_attribute_int64
>> (GLib.FileAttribute.TIME_MODIFIED).to_string());
>>
>> I always returns 0 , maybe I'm not doing it correctly , be obliged his
>> help.
>>
>> I'm using Windows valac - 0.26 .
>>
>>
>> Mis proyectos de software libre en:
>> Github - edwinspire
>> ___
>> vala-list mailing list
>> vala-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/vala-list
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Get CREATION DATE OR TIME of file

2016-01-08 Thread Luc Chante
Hi,

You can test le file a attached to this mail.

This is what I get (under windows with msys2 and vala 0.30) :

$ ./test
** Message: test.vala:21: FileAttribute.TIME_CREATED =>
FileAttributeType.INVALID
** Message: test.vala:56: Can be read !!!
** Message: test.vala:60: FileAttribute.TIME_CREATED =>
FileAttributeStatus.UNSET

Even in C when you are looking for the creation date there is no simple
answer.

http://unix.stackexchange.com/questions/91197/how-to-find-creation-date-of-file#91200

Le jeu. 7 janv. 2016 à 15:27, Edwin De La Cruz  a
écrit :

> Best regards . Attempt to get the date or time unix date of creation
> of a file and do not get it , I used the following code :
>
>
> var directory = File.new_for_path (path);
>
> var fi = directory.query_info ("*", GLib.FileQueryInfoFlags.NONE);
>
>  stdout.printf ("Date %s \n", fi.get_attribute_as_string
> (GLib.FileAttribute.TIME_CREATED));
>  stdout.printf ("Date or time %s \n", fi.get_attribute_int64
> (GLib.FileAttribute.TIME_MODIFIED).to_string());
>
> I always returns 0 , maybe I'm not doing it correctly , be obliged his
> help.
>
> I'm using Windows valac - 0.26 .
>
>
> Mis proyectos de software libre en:
> Github - edwinspire
> ___
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>


test.vala
Description: Binary data
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list