-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.lang
42 lines (34 loc) · 967 Bytes
/
test.lang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import fs;
import path;
import time;
class DirectoryReader {
let directoryPath: string;
fn mount(directoryPath: string) {
this.directoryPath = directoryPath;
}
fn readRecentFiles() {
let allFiles: []string = fs.readDir(this.directoryPath);
let recentFiles: []string = [];
foreach file in allFiles {
let fullPath: string = path.join(this.directoryPath, file);
let fileInfo: FileInfo = fs.stat(fullPath);
if this.isFileRecent(fileInfo.creationTime) {
recentFiles.push(fullPath);
}
}
foreach file in recentFiles {
println(file, fs.stat(file).creationTime);
}
}
fn isFileRecent(creationTime: Time): boolean {
let twentyFourHoursAgo: Time = time.now() - time.hours(24);
creationTime > twentyFourHoursAgo;
}
}
fn main() {
const directory: string = "/path/to/directory";
const reader = new DirectoryReader();
reader.mount(directory);
reader.readRecentFiles();
}
main();