GetFileDate + GetFileTime

BlitzMax Forums/BlitzMax Programming/GetFileDate + GetFileTime

Rimmsy(Posted 2007) [#1]
Do you guys have any idea how I'd use the Win32 GetFileTime command to retrieve a file's last written date and time? I'm writing a program that'll only compress files that haven't been updated recently.

I've been trying to edit this for bmx:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1442

Any help would be appreciated. I've been racking my brains with all the @s, buffers, floats, toCStrings, etc!


tonyg(Posted 2007) [#2]
Extended Time Function Module


Rimmsy(Posted 2007) [#3]
Tony, I get an Internal Error from that link.


tonyg(Posted 2007) [#4]
Hmmm...
What about this one ?


Rimmsy(Posted 2007) [#5]
After all the messing around,

Local time:Int = FileTime("c:\autoexec.bat")
Local tm  :Int Ptr = Int Ptr(localtime_(Varptr(time)))

Print "time:" +time
Print "sec:"  +tm[0]
Print "min:"  +tm[1]
Print "hour:" +tm[2]
Print "day:"  +tm[3]
Print "month:"+(tm[4]+1)
Print "year:" +(tm[5]+1900)
Print "wday:" +tm[6]
Print "yday:" +(tm[7]+1)


Did it all. Weird! Thanks Tony.


Rimmsy(Posted 2007) [#6]
This works nicely.

Strict

Local i:fileInformation=New fileInformation
	i.checkFile("c:\autoexec.bat")

Type fileInformation
	Field name$
	Field longtime
	
	Field hour,minute,second
	Field day,month,year
	
	Method checkFile(file$)
                name=file
		Local time:Int = FileTime(file)
		Local tm:Int Ptr = Int Ptr(localtime_(Varptr(time)))

		longtime=time
		hour=tm[2]
		minute=tm[1]
		second=tm[0]
		
		day=tm[3]
		month=(tm[4]+1)
		year=(tm[5]+1900)
	End Method
	
	Method getTidyString_Time$()
		Return hour+":"+minute+":"+second
	End Method
	
	Method getTidyString_Date$()
		Return day+"/"+month+"/"+year
	End Method
	
	Method getTidyString_all$()
		Return getTidyString_Time()+" "+getTidyString_Date()
	End Method
	
	Method compare(s:Object)
		Local o:fileInformation=fileInformation(s)
		If o <> Null
			If o.longtime=longtime
				Return 0
			ElseIf o.longtime> longtime
				Return 1 
			Else 
				Return -1
			EndIf
		EndIf		
	End Method
End Type