langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,7 @@
#load "unix.cma";;
open Unix;;
let mtime = (stat filename).st_mtime;; (* seconds since the epoch *)
utimes filename (stat filename).st_atime (time ());;
(* keep atime unchanged
set mtime to current time *)

View file

@ -0,0 +1,11 @@
NSFileManager *fm = [NSFileManager defaultManager];
// Pre-OS X 10.5
NSLog(@"%@", [[fm fileAttributesAtPath:@"input.txt" traverseLink:YES] fileModificationDate]);
[fm changeFileAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate]
atPath:@"input.txt"];
// OS X 10.5+
NSLog(@"%@", [[fm attributesOfItemAtPath:@"input.txt" error:NULL] fileModificationDate]);
[fm setAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate]
ofItemAtPath:@"input.txt" error:NULL];

View file

@ -0,0 +1,4 @@
FILE-INFO:FILE-NAME = 'c:/temp'.
MESSAGE
STRING( FILE-INFO:FILE-MOD-TIME, 'HH:MM:SS' )
VIEW-AS ALERT-BOX

View file

@ -0,0 +1,5 @@
declare
[Path] = {Module.link ['x-oz://system/os/Path.ozf']}
Modified = {Path.mtime "input.txt"} %% posix time
in
{Show {OsTime.localtime Modified}} %% human readable record

View file

@ -0,0 +1,21 @@
use NativeCall;
class utimbuf is repr('CStruct') {
has int $.actime;
has int $.modtime;
submethod BUILD(:$atime, :$mtime) {
$!actime = $atime;
$!modtime = $mtime;
}
}
sub sysutime(Str, utimbuf --> int) is native is symbol('utime') {*}
sub MAIN (Str $file) {
my $mtime = $file.IO.modified // die "Can't stat $file: $!";
my $ubuff = utimbuf.new(:atime(time),:mtime($mtime));
sysutime($file, $ubuff);
}

View file

@ -0,0 +1,2 @@
;;; Print modification time (seconds since Epoch)
sysmodtime('file') =>

View file

@ -0,0 +1,8 @@
$modificationTime = (Get-ChildItem file.txt).LastWriteTime
Set-ItemProperty file.txt LastWriteTime (Get-Date)
$LastReadTime = (Get-ChildItem file.txt).LastAccessTime
Set-ItemProperty file.txt LastAccessTime(Get-Date)
$CreationTime = (Get-ChildItem file.txt).CreationTime
Set-ItemProperty file.txt CreationTime(Get-Date)

View file

@ -0,0 +1,3 @@
Debug FormatDate("%yyyy/%mm/%dd", GetFileDate("file.txt",#PB_Date_Modified))
SetFileDate("file.txt",#PB_Date_Modified,Date(1987, 10, 23, 06, 43, 15))
Debug FormatDate("%yyyy/%mm/%dd - %hh:%ii:%ss", GetFileDate("file.txt",#PB_Date_Modified))

View file

@ -0,0 +1,3 @@
Function getModDate(f As FolderItem) As Date
Return f.ModificationDate
End Function

View file

@ -0,0 +1,3 @@
name$ = DIR$("input.txt", 0)
PRINT "File date: "; FileRec.Date
PRINT "File time: "; FileRec.Time

View file

@ -0,0 +1,23 @@
files #f, DefaultDir$ + "\*.*" ' all files in the defalt directory
print "hasanswer: ";#f HASANSWER() ' does it exist
print "rowcount: ";#f ROWCOUNT() ' number of files in the directory
print '
#f DATEFORMAT("mm/dd/yy") ' set format of file date to template given
#f TIMEFORMAT("hh:mm:ss") ' set format of file time to template given
for i = 1 to #f rowcount() ' loop through the files
if #f hasanswer() then ' or loop with while #f hasanswer()
print "nextfile info: ";#f nextfile$(" ") ' set the delimiter for nextfile info
print "name: ";name$ ' file name
print "size: ";#f SIZE() ' file size
print "date: ";#f DATE$() ' file date
print "time: ";#f TIME$() ' file time
print "isdir: ";#f ISDIR() ' is it a directory or file
name$ = #f NAME$()
shell$("touch -t 201002032359.59 ";name$;""") ' sell to os to set date
print
end if
next

View file

@ -0,0 +1,11 @@
$ include "seed7_05.s7i";
include "osfiles.s7i";
include "time.s7i";
const proc: main is func
local
var time: modificationTime is time.value;
begin
modificationTime := getMTime("data.txt");
setMTime("data.txt", modificationTime);
end func;

View file

@ -0,0 +1,2 @@
slate[1]> (File newNamed: 'LICENSE') fileInfo modificationTimestamp.
1240349799

View file

@ -0,0 +1,6 @@
val mtime = OS.FileSys.modTime filename; (* returns a Time.time data structure *)
(* unfortunately it seems like you have to set modification & access times together *)
OS.FileSys.setTime (filename, NONE); (* sets modification & access time to now *)
(* equivalent to: *)
OS.FileSys.setTime (filename, SOME (Time.now ()))

View file

@ -0,0 +1,5 @@
$$ MODE TUSCRIPT
file="rosetta.txt"
ERROR/STOP OPEN (file,READ,-std-)
modified=MODIFIED (file)
PRINT "file ",file," last modified: ",modified

View file

@ -0,0 +1 @@
T=`stat -c %Y $F`

View file

@ -0,0 +1 @@
T=`stat -c %y $F`

View file

@ -0,0 +1,3 @@
# Note the quotation marks -- very important!
T="2000-01-01 01:02:03.040506070 -0800"
touch -c -d "$T" $F

View file

@ -0,0 +1,2 @@
T=200102030405.06
touch -c -t $T $F

View file

@ -0,0 +1,2 @@
T=02030405
touch -c -t $T $F

View file

@ -0,0 +1 @@
touch -c $F

View file

@ -0,0 +1 @@
Num_Type(File_Stamp_Time("input.txt"))

View file

@ -0,0 +1,2 @@
File_Stamp_String(10, "input.txt")
Reg_Type(10)

View file

@ -0,0 +1,13 @@
Dim file As New IO.FileInfo("test.txt")
'Creation Time
Dim createTime = file.CreationTime
file.CreationTime = createTime.AddHours(1)
'Write Time
Dim writeTime = file.LastWriteTime
file.LastWriteTime = writeTime.AddHours(1)
'Access Time
Dim accessTime = file.LastAccessTime
file.LastAccessTime = accessTime.AddHours(1)