IonicWind Software

IWBasic => General Questions => Topic started by: Egil on March 23, 2016, 04:04:43 AM

Title: Retrieving directory creation & last written times.
Post by: Egil on March 23, 2016, 04:04:43 AM
Does anyone know how to retrieve the date and time when a directory was created and when it was last written to?

Title: Re: Retrieving directory creation & last written times.
Post by: Andy on March 23, 2016, 04:35:44 AM
Egil,

I think the GetFileTime function should work.

DECLARE IMPORT,GetFileTime(handle:INT,creation:filetime,access:filetime,writet:filetime), INT

Andy.
Title: Re: Retrieving directory creation & last written times.
Post by: Egil on March 23, 2016, 05:34:21 AM
Thanks Andy!

I've used that function for doing the same with files, with a slightly modified version of the file filetime.iwb that came with the IWB examples. So will try to see if the folder data also can be retrieved in the same way.
Title: Re: Retrieving directory creation & last written times.
Post by: Andy on March 23, 2016, 05:50:23 AM
Egil,

No problem!

Found this post:
http://www.ionicwind.com/forums/index.php/topic,1494.0.html

This may help you a little more?

Andy.
Title: Re: Retrieving directory creation & last written times.
Post by: Egil on March 23, 2016, 06:59:01 AM
Andy,

Got exactly the same challenge here as in the link you supplied. The only difference is the mumber of files. My old time radio recordings collection now has around 25000 mp3 files in 1300 directories. So really need to make a program that makes it possible fo find specific files in an easy way.

Have been playing around with the functions mentioned in that thread all morning here, but begin to think that all that functions were all made for the FAT and FAT32 file systems and that all do not work properly with the NTFS system. Getting some weird results here, so probably doing something wrong.
There is also an new file system I think will be more often used in the future, the ReFS (made for Windows 8 servers), but this one have to wait until I have decided to go on with windows or not.

But taking a break now. The house is full of grandchildren, and we have planned to walk along the beaches for our annual easter family photo contest...
Title: Re: Retrieving directory creation & last written times.
Post by: LarryMc on March 23, 2016, 09:55:39 AM
Remember this:
Not all file systems can record creation and last access times and not all file systems record them in the same manner. For example, on 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). Therefore, the GetFileTime function may not return the same file time information set using the SetFileTime function.
NTFS delays updates to the last access time for a file by up to one hour after the last access. NTFS also permits last access time updates to be disabled. Last access time is not updated on NTFS volumes by default.
Windows Server 2003 and Windows XP:  Last access time is updated on NTFS volumes by default.


There is other info in this  article that is helpful
https://msdn.microsoft.com/en-us/library/ms724290.aspx
Title: Re: Retrieving directory creation & last written times.
Post by: Egil on March 23, 2016, 10:57:00 AM
Thanks for the nice link Larry!

QuoteNTFS delays updates to the last access time for a file by up to one hour after the last access. NTFS also permits last access time updates to be disabled. Last access time is not updated on NTFS volumes by default.

Well, I got two NTFS disks on this pc. Windows Explorer is able to report both creation times and last updated times with one second accuracy. That is good enough for my application. And since it is done by windows Explorer, I am convinced that it will be possible to do the same with a home brew program coded with any of the IWB languages.

Guess the best way to solve my problem is to browse the include files to see how the structures for file and folders are defined. When I find the correct structure the rest ought to be relatively easy....
Not sure, but think that Allan Nuss once posted code that could do that kind of browsing automaticly, so have to search the forum to see if I can find it.