Recent

Author Topic: File creation time - linux  (Read 13600 times)

Elphi

  • Full Member
  • ***
  • Posts: 132
File creation time - linux
« on: May 09, 2009, 10:20:41 pm »
How can I get a file creation time on linux?
On windows I use the following:
Code: [Select]
function FileGetCreationTime(const AFileName: AnsiString): TDateTime;
var
  SearchRec: TSearchRec;
  SysTime: SYSTEMTIME;
  FileTime: TFILETIME;
begin
  if FindFirst(AFileName, faAnyFile, SearchRec) = 0 then
  begin
    FileTimeToLocalFileTime(SearchRec.FindData.ftCreationTime, FileTime);
    FileTimeToSystemTime(FileTime, SysTime);
    Result := SystemTimeToDateTime(SysTime);
  end;
end;

kandukeswara

  • Newbie
  • Posts: 2
Re: File creation time - linux
« Reply #1 on: December 16, 2009, 04:02:42 am »
maybe you can change :
FileTimeToLocalFileTime(SearchRec.FindData.ftCreationTime, FileTime);
on line 9, to :
FileTimeToLocalFileTime(SearchRec.Time, FileTime);

good luck

clauslack

  • Sr. Member
  • ****
  • Posts: 275
Re: File creation time - linux
« Reply #2 on: December 16, 2009, 04:21:18 am »
I think that work fine in Linux and Windows.
Code: [Select]
var fecha:Tdate;fechatmp:longint;filename:string;
fechatmp:=FileAge(filename);
fecha:=int(FileDateToDateTime(fechatmp))

check filename if is ANSI or UTF8..(FileAge(utf8tosys(filename)))

Regards

Hitman

  • Newbie
  • Posts: 3
Re: File creation time - linux
« Reply #3 on: December 16, 2009, 01:24:02 pm »
There is no such thing as "File creation time" on *nix file systems.
http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-inodes.html

 

TinyPortal © 2005-2018