Windows to Linux Porting - timeCreated and timeLastAccessed

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri May 4 14:02:24 UTC 2018


On Friday, May 04, 2018 13:17:36 Vino via Digitalmars-d-learn wrote:
> On Friday, 4 May 2018 at 12:38:07 UTC, Adam D. Ruppe wrote:
> > What are you actually trying to do with it? These functions are
> > probably the wholly wrong approach.
>
> Hi Adam,
>
>   The existing program in Windows do few task's eg: Delete files
> older that certain days, and now we are trying to port to Linux,
> and above was just a example, hence asked the right approach for
> porting.

Linux does not keep track of the creation time of a file. So, it will not
work to have a program on Linux ask a file how long it's been since the file
was created. If you want that information, you'll have to store it elsewhere
somehow (and that generally only works if you created the file in the first
place).

The modification time of the file is the time that the file was last changed
(which would be the creation time if it were only ever written to once, but
in the general case, it has no relation to the creation time at all). So,
you could use std.file.timeLastModified to find out if a file has been
changed within the last x number of days, but there is no way to find out
the creation time of a file by asking the filesystem.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list