Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Unpacking file time data

gregp
Beginner
1,804 Views
Does anyone know how to unpack the encoded file time data to greater precision than the integer seconds that GETFILEINFOQQ and UNPACKQQ gives? I "thought" the file times were actually encoded to miliseconds, but the unpack routine only gives to even seconds. I'm trying to get a more accurate time stamp for photos shot during an auto-sequence and could really use fractional seconds.

Thanks - Greg
0 Kudos
16 Replies
Steven_L_Intel1
Employee
1,804 Views
Try the Win32 API routine FileTimeToSystemTime. The Platform SDK documentation on filetime has some other interesting stuff, such as:

A file time is a 64-bit value that represents the number of 100-nanosecond intervals that have elapsed since 12:00 A.M. January 1, 1601 (UTC). The system records file times whenever applications create, access, and write to files. Not all file systems can record creation and last access time and not all file systems record them in the same manner. For example, on NT FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour.

0 Kudos
gregp
Beginner
1,804 Views
How do I link to the FileTimeToSystemTime routine? It comes up missing with the default libraries.
Thanks - Greg
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,804 Views
It's in Kernel32.dll, which must be linked in with every sane Windows application.
However, if you USE DFWIN, that should fix it -- without it, the compiler can't see the correct prototype so it generates the wrong information for the linker.
Jugoslav
0 Kudos
gregp
Beginner
1,804 Views
I have a console application not a windows application so it uses DFLIB. Can I still access it for a console app?
-Greg
0 Kudos
Steven_L_Intel1
Employee
1,804 Views
Yes, you have full access to the Win32 API from console applications.
0 Kudos
gregp
Beginner
1,804 Views
I added a USE DFWIN and got it to find the routine, but get a memeory violation error. Guess I still don't have it quite right.
0 Kudos
Steven_L_Intel1
Employee
1,804 Views
So what does your code look like? This is a simple call, such as:
ret = FileTimeToSystemTime (ft,st)
where ft is a variable of type T_FILETIME and st is a variable of type T_SYSTEMTIME.
0 Kudos
gregp
Beginner
1,804 Views
I can get the linker to work using USE KERNEL32 also.
Here's what I'm "trying"
use the function STAT to get the file date
copy that intothe FILETIME structure low dw
use the function FileTimeToSystemTime referencing the FILETIME structure and a SYSTEMTIME structure.
I get an error instruction referenced memeory at "0x00000000"
-Greg
0 Kudos
gregp
Beginner
1,804 Views
T_FILETIME as a file type is new to me, will have to go look that up. I defined structures and used them in the function call.
-Greg
0 Kudos
gregp
Beginner
1,804 Views
Seeing that I'm clearly missing it, here is what I had coded:

USE DFLIB

USE KERNEL32

USE SCREENIO

USE DFPORT

Structure /Systime1/

Integer*2 wYear;

Integer*2 wMonth;

Integer*2 wDayOfWeek;

Integer*2 wDay;

Integer*2 wHour;

Integer*2 wMinute;

Integer*2 wSecond;

Integer*2 wMilliseconds

End Structure

Structure /Filetime1/

Integer*4 wFile1

Integer*4 wFile2

End Structure

c

ifind = stat(file1,statb)

isize1 = statb(8)

date1 = statb(10)

wFile1 = statb(10)

wFile2 = 0

status=FileTimeToSystemTime(wFile1,wYear)

write(*,*) wDay,wHour,wMinute,wSecond,wMilliseconds

0 Kudos
gregp
Beginner
1,804 Views
I tried to set TYPE(T_FILETIME) FT and TYPE(T_SYSTEMTIME) ST then use them in the call but it says the arguments type mismatch. In Kernel32.F90 the arguments are defined as INTEGER.
I also tried defining variables INTEGER FT and INTEGER ST then making the call, but then I get the memory error again.
I'm lost.
-Greg
0 Kudos
Steven_L_Intel1
Employee
1,804 Views
There are several things wrong here. First, the portability library routine stat returns a completely different kind of time than GETFILEINFOQQ. Second, upon further reading, GETFILEINFOQQ doesn't provide the granularity you want. You will have to use Win32 API routines, including GetFileTime,to get the information.
When you are using structures, you also need to declare RECORD variables of the structure type. You haven't, and your references to wFile1 and wFile2 are just undeclared REAL variables, not fields of the structure.
Also, you appear to be using an old version of Compaq Visual Fortran or perhaps even Digital Visual Fortran. That is why the arguments to the routine in kernel32.f90 were integers - in that version, you have to pass loc(var) rather than var directly.

Message Edited by sblionel on 10-27-2004 03:22 PM

0 Kudos
gregp
Beginner
1,804 Views
Before I bail completly on this experiment (because all the variations of using type,record,structure that I've tried from my too limited understanding of the documentation aren't working) ... is it possible my copy of Kernel32.F90 has a problem as the file time declerations in FileTimeToSystemTime and SystemTimeToFileTIme disagree? One types the argumensts as T_FILETIME etc and the other types both arguments as INTEGER??
-Greg
0 Kudos
Steven_L_Intel1
Employee
1,804 Views
What version of Visual Fortran are you using? The definition looked correct to me in CVF 6.6 and Intel Visual Fortran 8.1.
0 Kudos
gregp
Beginner
1,804 Views
Compac Version 6.1
-Greg
0 Kudos
Steven_L_Intel1
Employee
1,804 Views
Ah, the distant past....

Basically, you need the following Win32 API routines

CreateFile (to open the file)
GetFileTime
CloseHandle

Then you decide what to do with the FileTime value you get.
0 Kudos
Reply