2
0
Brucey 2 жил өмнө
parent
commit
3ac752229b

+ 17 - 0
filesystem.mod/doc/setfiletime.bmx

@@ -0,0 +1,17 @@
+' setfiletime.bmx
+
+SuperStrict
+
+Const FILENAME:String = "file.txt"
+
+SaveString("Hello", FILENAME)
+
+Local ft:Long = FileTime(FILENAME)
+
+Print ft
+
+ft :- 3600 ' less 1 hour
+
+SetFileTime(FILENAME, ft)
+
+Print FileTime(FILENAME)

+ 19 - 1
filesystem.mod/filesystem.bmx

@@ -232,7 +232,7 @@ End Function
 
 Rem
 bbdoc: Gets file time
-returns: The time the file at @path was last modified 
+returns: The time the file at @path was last modified.
 End Rem
 Function FileTime:Long( path$, timetype:Int=FILETIME_MODIFIED )
 	FixPath path
@@ -261,6 +261,24 @@ Function FileTime:Long( path$, timetype:Int=FILETIME_MODIFIED )
 	End If
 End Function
 
+Rem
+bbdoc: Sets the file modified or last accessed time.
+about: @time should be number of seconds since epoch.
+End Rem
+Function SetFileTime( path:String, time:Long, timeType:Int=FILETIME_MODIFIED)
+	FixPath path
+	If MaxIO.ioInitialized Then
+		' Not available
+	Else
+		Select timetype
+			Case FILETIME_MODIFIED
+				utime_(path, timeType, time)
+			Case FILETIME_ACCESSED
+				utime_(path, timeType, time)
+		End Select
+	End If
+End Function
+
 Rem
 bbdoc: Gets the file size
 returns: The size, in bytes, of the file at @path, or -1 if the file does not exist