Category: Streams-Files
Superclass: Object
I expose the syntax of file names, including paths. I know how to manipulate such a path by splitting it into its components. In addition, I expose information about files (both real and virtual) such as their size and timestamps.

Method category index

file name management (class)
still unclassified (class)
accessing (instance)
converting (instance)
decoration (instance)
directory operations (instance)
enumerating (instance)
file name management (instance)
file operations (instance)
printing (instance)
still unclassified (instance)
testing (instance)
virtual filesystems (instance)

file name management (class)

append: fileName to: directory
Answer the name of a file named `fileName' which resides in a directory named `directory'.

extensionFor: aString

Answer the extension of a file named `aString'. Note: the extension includes an initial dot.

fullNameFor: aString

Answer the full path to a file called `aString', resolving the `.' and `..' directory entries, and answer the result. `/..' is the same as '/'.

pathFor: aString

Determine the path of the name of a file called `aString', and answer the result. With the exception of the root directory, the final slash is stripped.

pathFor: aString ifNone: aBlock

Determine the path of the name of a file called `aString', and answer the result. With the exception of the root directory, the final slash is stripped. If there is no path, evaluate aBlock and return the result.

pathFrom: srcName to: destName

Answer the relative path to destName when the current directory is srcName's directory.

stripExtensionFrom: aString

Remove the extension from the name of a file called `aString', and answer the result.

stripFileNameFor: aString

Determine the path of the name of a file called `aString', and answer the result as a directory name including the final slash.

stripPathFrom: aString

Remove the path from the name of a file called `aString', and answer the file name plus extension.

top


still unclassified (class)

isAbsolute: aString
Answer whether aString is an absolute ptah.

top


accessing (instance)

at: aName
Answer a File or Directory object as appropriate for a file named 'aName' in the directory represented by the receiver.

creationTime

Answer the creation time of the file identified by the receiver. On some operating systems, this could actually be the last change time (the `last change time' has to do with permissions, ownership and the like).

group: aString

Set the group of the file identified by the receiver to be aString.

includes: aName

Answer whether a file named `aName' exists in the directory represented by the receiver.

lastAccessTime

Answer the last access time of the file identified by the receiver

lastAccessTime: aDateTime

Update the last access time of the file corresponding to the receiver, to be aDateTime.

lastAccessTime: accessDateTime lastModifyTime: modifyDateTime

Update the timestamps of the file corresponding to the receiver, to be accessDateTime and modifyDateTime.

lastChangeTime

Answer the last change time of the file identified by the receiver (the `last change time' has to do with permissions, ownership and the like). On some operating systems, this could actually be the file creation time.

lastModifyTime

Answer the last modify time of the file identified by the receiver (the `last modify time' has to do with the actual file contents).

lastModifyTime: aDateTime

Update the last modification timestamp of the file corresponding to the receiver, to be aDateTime.

mode

Answer the permission bits for the file identified by the receiver

mode: anInteger

Set the permission bits for the file identified by the receiver to be anInteger.

owner: aString

Set the owner of the file identified by the receiver to be aString.

owner: ownerString group: groupString

Set the owner and group of the file identified by the receiver to be aString.

pathTo: destName

Compute the relative path from the receiver to destName.

refresh

Refresh the statistics for the receiver

size

Answer the size of the file identified by the receiver

top


converting (instance)

asFile
Answer the receiver.

top


decoration (instance)

all
Return a decorator of the receiver that will provide recursive descent into directories for iteration methods. Furthermore, iteration on the returned wrapper will not include '.' or '..' directory entries, and will include the receiver (directly, not via '.').

top


directory operations (instance)

createDirectories
Create the receiver as a directory, together with all its parents.

createDirectory

Create the receiver as a directory, together with all its parents.

nameAt: aName

Answer a FilePath for a file named `aName' residing in the directory represented by the receiver.

top


enumerating (instance)

allFilesMatching: aPattern do: aBlock
Evaluate aBlock on the File objects that match aPattern (according to String>>#match:) in the directory named by the receiver. Recursively descend into directories.

directories

Answer an Array with Directory objects for the subdirectories of the directory represented by the receiver.

do: aBlock

Evaluate aBlock once for each file in the directory represented by the receiver, passing a FilePath object (or a subclass) to it. It depends on the subclass whether iteration will include the '.' and '..' directory entries.

entries

Answer an Array with File or Directory objects for the contents of the directory represented by the receiver.

entryNames

Answer an Array with the names of the files in the directory represented by the receiver.

files

Answer an Array with File objects for the contents of the directory represented by the receiver.

filesMatching: aPattern

Evaluate aBlock once for each file in the directory represented by the receiver, passing a File or Directory object to aBlock. Returns the *names* of the files for which aBlock returns true.

filesMatching: aPattern do: block

Evaluate block on the File objects that match aPattern (according to String>>#match:) in the directory named by the receiver.

namesDo: aBlock

Evaluate aBlock once for each file in the directory represented by the receiver, passing its name. It depends on the subclass whether iteration will include the '.' and '..' directory entries.

namesMatching: aPattern do: block

Evaluate block on the file names that match aPattern (according to String>>#match:) in the directory named by the receiver.

reject: aBlock

Evaluate aBlock once for each file in the directory represented by the receiver, passing a File or Directory object to aBlock. Returns the *names* of the files for which aBlock returns true.

select: aBlock

Evaluate aBlock once for each file in the directory represented by the receiver, passing a File or Directory object to aBlock. Returns the *names* of the files for which aBlock returns true.

top


file name management (instance)

directory
Answer the Directory object for the receiver's path

extension

Answer the extension of the receiver

full

Answer the full name of the receiver, resolving the `.' and `..' directory entries, and answer the result. Answer nil if the name is invalid (such as '/usr/../../badname')

fullName

Answer a String with the full path to the receiver (same as #name; it is useless to override this method).

name

Answer String with the full path to the receiver (same as #fullName).

parent

Answer the Directory object for the receiver's path

path

Answer the path (if any) of the receiver

stripExtension

Answer the path (if any) and file name of the receiver

stripFileName

Answer the path of the receiver, always including a directory name (possibly `.') and the final directory separator

stripPath

Answer the file name and extension (if any) of the receiver

top


file operations (instance)

contents
Open a read-only FileStream on the receiver, read its contents, close the stream and answer the contents

fileIn

File in the receiver

linkAs: destName

Create destName as a hard link of the receiver.

linkFrom: srcName

Create the receiver as a hard link from srcName.

open: mode

Open the receiver in the given mode (as answered by FileStream's class constant methods)

open: mode ifFail: aBlock

Open the receiver in the given mode (as answered by FileStream's class constant methods). Upon failure, evaluate aBlock.

open: class mode: mode ifFail: aBlock

Open the receiver in the given mode (as answered by FileStream's class constant methods)

openDescriptor: mode

Open the receiver in the given mode (as answered by FileStream's class constant methods)

openDescriptor: mode ifFail: aBlock

Open the receiver in the given mode (as answered by FileStream's class constant methods). Upon failure, evaluate aBlock.

pathFrom: dirName

Compute the relative path from the directory dirName to the receiver

readStream

Open a read-only FileStream on the receiver

remove

Remove the file identified by the receiver

renameTo: newName

Rename the file identified by the receiver to newName

symlinkAs: destName

Create destName as a symbolic link of the receiver. The appropriate relative path is computed automatically.

symlinkFrom: srcName

Create the receiver as a symbolic link from srcName (relative to the path of the receiver).

touch

Update the timestamp of the file corresponding to the receiver.

withReadStreamDo: aBlock

Answer the result of invoking aBlock with a reading stream open on me, closing it when the dynamic extent of aBlock ends.

withWriteStreamDo: aBlock

Answer the result of invoking aBlock with a writing stream open on me, closing it when the dynamic extent of aBlock ends.

writeStream

Open a write-only FileStream on the receiver

top


printing (instance)

asString
Print a representation of the receiver on aStream.

displayOn: aStream

Print a representation of the receiver on aStream.

printOn: aStream

Print a representation of the receiver on aStream.

withShellEscapes

Return the representation of the receiver with shell characters escaped.

top


still unclassified (instance)

/ aName
Answer a File or Directory object as appropriate for a file named 'aName' in the directory represented by the receiver.

top


testing (instance)

exists
Answer whether a file with the name contained in the receiver does exist.

isAbsolute

Answer whether the receiver identifies an absolute path.

isAccessible

Answer whether a directory with the name contained in the receiver does exist and can be accessed

isDirectory

Answer whether a file with the name contained in the receiver does exist and identifies a directory.

isExecutable

Answer whether a file with the name contained in the receiver does exist and is executable

isFile

Answer whether a file with the name contained in the receiver does exist and does not identify a directory.

isFileSystemPath

Answer whether the receiver corresponds to a real filesystem path.

isReadable

Answer whether a file with the name contained in the receiver does exist and is readable

isRelative

Answer whether the receiver identifies a relative path.

isSymbolicLink

Answer whether a file with the name contained in the receiver does exist and identifies a symbolic link.

isWriteable

Answer whether a file with the name contained in the receiver does exist and is writeable

top


virtual filesystems (instance)

zip
Not commented.

top