[Gambas-user] file time stamp

vuott at tutanota.com vuott at tutanota.com
Mon Apr 24 15:09:20 CEST 2023


...maybe with Extern ?

[code]
Private Const EPOCH As String = "01/01/1970"


Library "libc:6"

Public Struct utimbuf
  actime As Long
  modtime As Long
End Struct

' int utime (const char *__file, const struct utimbuf *__file_times)
' Set the access and modification times of FILE to those given in *FILE_TIMES.
' If FILE_TIMES is NULL, set them to the current time.
Private Extern utime(__file As String, __file_times As Utimbuf) As Integer


Public Sub Main()
 
Dim ut As New Utimbuf
Dim s As String

s = "/path/of/file"
 
With ut
' Changes the 'access' timestamp to the file to 1661040000 seconds from the initial date (Tempo Unix):
   .actime = DateDiff(CDate(EPOCH), CDate("08/21/2022"), gb.Second)
' Changes the 'modification' timestamp to the file to 1661040000 seconds from the initial date (Unix Time):
    .modtime = DateDiff(CDate(EPOCH), CDate("08/21/2022"), gb.Second)
End With

utime(s, ut)

End

[/code]



23 apr 2023, 22:44 da benoit.minisini at gambas-basic.org:

> Le 21/04/2023 à 18:48, Marco Ancillotti a écrit :
>
>> Hi all ,
>>
>> is there a way to update file/dir timestamp like shell command touch do ?
>>
>> I simply need to touch a directory to update timestamp , I can do a shell "touch <dir>" but there's a gambas way to do that ?
>>
>> thank's,
>> marco.
>>
>
> Mmm... Not really, unless someone finds a trick.
>
> --
> Benoît Minisini.
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230424/65ac846b/attachment.htm>


More information about the User mailing list