filename$ = "c:\Program Files\PureBasic\Examples\Sources\Data\Background.bmp"
Structure stats
size.q
mtim.q
ctim.q
EndStructure
; ================================================
Procedure GetFileStats1(filename.s, *stats.stats)
*stats\mtim = ConvertDate(GetFileDate(filename, #PB_Date_Modified), #PB_Date_UTC)
*stats\ctim = ConvertDate(GetFileDate(filename, #PB_Date_Created ), #PB_Date_UTC)
*stats\size = FileSize(filename)
EndProcedure
Define test1.stats
GetFileStats1(filename$, test1)
Debug test1\mtim
; ================================================
Structure stat64 Align #PB_Structure_AlignC
st_dev.l ; ID of device containing the file
st_ino.u ; Serial number for the file
st_mode.u ; Access mode and file type for the file
st_nlink.w ; Number of links to the file
st_uid.w ; User ID of file owner
st_gid.w ; Group ID of group owner
st_rdev.l ; Device ID (if the file is a character or block special device)
st_size.q ; File size in bytes (if the file is a regular file)
st_atime.q ; Time of last access
st_mtime.q ; Time of last data modification
st_ctime.q ; Time of last file status change
EndStructure
ImportC ""
_stat64(path.p-utf8, *buf)
EndImport
Procedure GetFileStats2(filename.s, *stats.stats): Protected stat64.stat64
_stat64(filename, stat64)
*stats\mtim = stat64\st_mtime ; UTC-Time Modified
*stats\ctim = stat64\st_ctime ; UTC-Time Created/Birth
*stats\size = stat64\st_size
EndProcedure
Define test2.stats
GetFileStats2(filename$, test2)
Debug test2\mtim
filename$ =#PB_Compiler_Home+"\Examples\Sources\Data\Background.bmp"
Structure stats
size.q
mtim.q
ctim.q
EndStructure
; ================================================
Procedure GetFileStats1(filename.s, *stats.stats)
*stats\mtim = ConvertDate(GetFileDate(filename, #PB_Date_Modified), #PB_Date_UTC)
*stats\ctim = ConvertDate(GetFileDate(filename, #PB_Date_Created ), #PB_Date_UTC)
*stats\size = FileSize(filename)
EndProcedure
Define test1.stats
GetFileStats1(filename$, test1)
Debug ""+test1\mtim+" => "+FormatDate("%mm/%dd/%yyyy %hh:%ii:%ss",test1\mtim)
; ================================================
Structure stat64 Align #PB_Structure_AlignC
st_dev.l ; ID of device containing the file
st_ino.u ; Serial number for the file
st_mode.u ; Access mode and file type for the file
st_nlink.w ; Number of links to the file
st_uid.w ; User ID of file owner
st_gid.w ; Group ID of group owner
st_rdev.l ; Device ID (if the file is a character or block special device)
st_size.q ; File size in bytes (if the file is a regular file)
st_atime.q ; Time of last access
st_mtime.q ; Time of last data modification
st_ctime.q ; Time of last file status change
EndStructure
ImportC ""
_stat64(path.p-utf8, *buf)
EndImport
Procedure GetFileStats2(filename.s, *stats.stats): Protected stat64.stat64
_stat64(filename, stat64)
*stats\mtim = stat64\st_mtime ; UTC-Time Modified
*stats\ctim = stat64\st_ctime ; UTC-Time Created/Birth
*stats\size = stat64\st_size
EndProcedure
Define test2.stats
GetFileStats2(filename$, test2)
Debug ""+test2\mtim+" => "+FormatDate("%mm/%dd/%yyyy %hh:%ii:%ss",test2\mtim)
EDIT 08/07/24 : Correction of a small error I made in the code, but which had no effect on the final result.
Last edited by boddhi on Wed Aug 07, 2024 11:41 am, edited 1 time in total.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...