Hello all,
I am having some small challenges getting file time stamps
Platform: Windows10/11, 64 bit OS and processor.
Win32ada 25.0.0
In Windows files have 3 time properties, access time, creation time and modification time.
Short version: How can get the correct file times?
(much) longer version:
Using the WIN32Ada interface there are (at least) 2 ways of getting these times: Win32.crt.Stat.Stat, which returns a struct_stat record; and Win32.crt.Io.findfirst which returns a findata_t record. Both records have 3 time fields, of type Win32.crt.Types.time_t, representing the nr of second since EPOCH (01-jan-1970 00:00:00). In Win32 time_t is a 32-bit type, so for sure it will have a year 2038 problem if left unchanged.
And then there are Ada.Directories.Modification_Time which return Ada.Calendar.Time and GNAT.Os_Lib.File_Time_Stamp which returns GANT.OS_Lib.OS_Time
When I use these functions and compare them to the time stamps of a file in its property sheet the result do not agree
Time stamps according to property sheet:
- created : 18-Sep-2026 18:02:36
- modified: 12-Nov-2025 17:50:44
- accessed: 16-Sep-2026 18:02:36
Time stamp according Ada.Directories.Modification_Time:
- modified: 12-Nov-2025 17:50:44 ==> agrees with file property sheet
Time stamp according GNAT.OS_Lib.File_Time_Stamp:
- time stamp: 12-Nov-2025 16:50:44 ==> agrees with file property sheet modification time, given the time zone
Time stamps according Win32.Crt.Stat.Stat:
- created : 12-Nov-2025 17:50:44 ==> is the modified time in the property sheet
- modified: 01-Jan-1970 00:00:00 ==> no match what so ever
- accessed: 21-Sep-2026 16:54:41 ==> no match what so ever
Online search for the relevant C documentation on stuct stat I can’t find any agreement on the order of elements
Time stamps according Win32.Crt.Io.findfirst:
- created : 01-Jan-1970 09:05:58 ==> no match what so ever
- modified: 01-Jan-1970 00:00:00 ==> no match what so ever
- accessed: 18-Sep-2026 17:02:36 ==> matches created in file property sheet, given the time zone
Furthermore, in the ‘name’ field (type Char260) the first 16 (or so) elements are bogus; and the reported file size is also incorrect. The results suggest a misalignment with the actual C implementation.
So, how come the Win32ada values are way off?
And how can I get the correct values for the file time stamps?
(Sorry for the amount of text)