The Directory object can be used in two ways:
d := Directory clone setPath("c:/foo") creates an object that deals with directory "c:/foo" and can answer certain questions about it, like "which files are in this directory" (d fileNames).Directory currentWorkingDirectory returns the current directory, regardless of the contents of the directory object it's called on.Get a list of names of files in the current directory:
Directory fileNames
#=> list("cube.io", "cygwin1.bak", ...etc...)
Get the current working directory:
Io> Directory currentWorkingDirectory #=> /cygdrive/c/lang/IoFull-Cygwin-2006-04-20
Often, Directory (and File) objects are returned by other methods. For example:
files := Directory files # only returns files files at(0) #=> File_0x820c40 items := Directory items items at(4) #=> Directory_0x8446b0 items at(4) name #=> DarkSide-0.0.1 # a directory name
Setting a Directory object to a certain directory and using it:
Io> root := Directory clone setPath("c:/")
#=> Directory_0x8637b8:
Io> root fileNames
#=> list("AUTOEXEC.BAT", "boot.ini", "CONFIG.SYS", ...)
Checking if a directory exists:
Io> Directory clone setPath("q:/") exists
#=> false