Check Modification Date of single file?

Richard Gaskin ambassador at fourthworld.com
Mon Nov 14 20:21:07 EST 2005


Alex Tweedly wrote:
> Sivakatirswami wrote:
> 
>> Klaus, Aloha from Hawaii, I hope you don't have too cold a winter  
>> over there, pray that the Gulf Stream doesn't stop...predicted to  
>> soon -- maybe as soon as in next five years or so -- at which time  
>> Europe freezes over; if it does you can move to Hawaii and help us here.
>>
>> Detailed files: right, saw that... but thats returned from all files  
>> in the defaultFolder... I looking to get that info from a single file  
>> on a single path  (this list of file I have is in multiple folders)
> 
> 
> I don't think there is a way to get the info for a single file. Remember 
> that what "the detailed files" does is read the directory info - so it 
> would not be significantly faster to read the info for one file than it 
> is for the whole folder.
> 
> Ideally (for performance) you'd sort the list of files you care about by 
> folder, then visit each folder in turn, get the detailed files, make the 
> decision about each of the files in your list, then move on to the next 
> folder ...

Agreed.  The function below takes about 4ms per call on my 1GHz PB G4. 
If you comment out the second part of the GetModDate function below "--" 
it takes almost the same amount of time, suggesting that most of the 
time is eaten storing, changing, and restoring the directory:

on mouseUp
   put 1000 into n
   put the millisecs into t
   repeat n
     get GetModDate("/Users/richardgaskin/Documents/EPSON OS X booklet.pdf")
   end repeat
   put (the millisecs - t)/n
end mouseUp


function GetModDate pPath
   set the itemdel to "/"
   put urlEncode(last item of pPath) into tFile
   delete last item of pPath
   put the directory into tSaveDir
   set the directory to pPath
   put the detailed files into tFileList
   set the directory to tSaveDir
   --
   set the itemdel to comma
   get lineoffset(cr&tFile&comma, tFileList)
   if it > 0 then
     return item 5 of line it of tFileList
   end if
end GetModDate




--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list