File modification time: Difference between revisions

m
m (Update Lang example: Fix spelling of Lang)
m (→‎{{header|Wren}}: Minor tidy)
 
(One intermediate revision by one other user not shown)
Line 612:
AD 2022-01-01 AM 05:00:00.000 (Sat) Mountain Standard Time
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
CFURLRef desktopURL = fn FileManagerURLForDirectory( NSDesktopDirectory, NSUserDomainMask )
CFURLRef url = fn URLByAppendingPathComponent( desktopURL, @"file.txt" )
CFDictionaryRef dict = fn FileManagerAttributesOfItemAtURL( url )
 
print dict[@NSFileModificationDate] // Read file's current date
 
// Reset file date to current
fn FileManagerSetAttributesOfItemAtURL( CFURLRef url, @{NSFileModificationDate:fn DateNow )
</syntaxhighlight>
 
 
=={{header|Gambas}}==
Line 1,505 ⟶ 1,518:
{{libheader|Wren-date}}
As there is currently no way for Wren-cli to get or set file modification times, we instead use an embedded script so the C host can do this for us.
<syntaxhighlight lang="ecmascriptwren">/* file_mod_time_wrenFile_modification_time_wren */
 
import "./date" for Date
Line 1,540 ⟶ 1,553:
<br>
We now embed this in the following C program, build and run it:
<syntaxhighlight lang="c">/* gcc file_mod_timeFile_modification_time.c -o file_mod_timeFile_modification_time -lwren -lm */
 
#include <sys/stat.h>
Line 1,678 ⟶ 1,691:
WrenVM* vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "file_mod_timeFile_modification_time.wren";
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
9,476

edits