FileDirectory
Last updated at 7:05 pm UTC on 14 July 2022
From the class comment:
A FileDirectory represents a folder or directory in the underlying platform's file system. It carries a fully-qualified path name for the directory it represents, and can enumerate the files and directories within that directory.
A FileDirectory can be thought of as a Dictionary whose keys are the local names of files in that directory, and whose values are directory "entries". Each entry is an array of five items:
- name
- creationTime
- modificationTime
- dirFlag
- fileSize
The times are given in seconds, and can be converted to a time and date via Time>dateAndTimeFromSeconds:. See the comment in lookupEntry:... which provides primitive access to this information.
- FileDirectory default gives back a platform specific directory object (of a subclass of FileDirectory) denoting the directory where the .image file is in.
- FileDirectory default containingDirectory gives back a platform specific directory object (of a subclass of FileDirectory) denoting the parent directory where the .image file is in.
- FileDirectory default pathName gives back a string denoting the default directory.
see also:
aFileDirectory keysDo: [:key | ...]
aFileDirectory fileEntries do: [:aDirectoryEntryFile | ...]
dirName := '/home/he/Documents/pictures/'".
aFileDirectory := FileDirectory on: dirName.
modificationDate := Date year: 2022 month: 5 day: 1.
recentlyModifiedFiles := aFileDirectory fileEntries select: [:aDirectoryEntryFile | aDirectoryEntryFile modificationDateAndTime >= modificationDate].
Benchmark
| foo bar baz |
foo := FileDirectory on: '/no/where/at/all'.
bar := FileDirectory on: '/Users/eliot/Desktop/not there'.
baz := FileDirectory default.
[foo exists. bar exists. baz exists] bench '73,700 per second. 13.6 microseconds per run. 0.64 % GC time.'
See also
FileMan