Back: False-printing Up: Base classes Forward: File class-C functions   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.71 File

Defined in namespace Smalltalk
Superclass: Object
Category: Streams-Files
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.

1.71.1 File class: C functions  (class)
1.71.2 File class: file name management  (class)
1.71.3 File class: file operations  (class)
1.71.4 File class: instance creation  (class)
1.71.5 File class: reading system defaults  (class)
1.71.6 File class: testing  (class)
1.71.7 File: accessing  (instance)
1.71.8 File: file name management  (instance)
1.71.9 File: file operations  (instance)
1.71.10 File: printing  (instance)
1.71.11 File: testing  (instance)


1.71.1 File class: C functions

errno
Answer the current value of C errno.

stringError: errno
Answer C strerror's result for errno.


1.71.2 File class: file name management

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.


1.71.3 File class: file operations

checkError
Return whether an error had been reported or not. If there had been one, raise an exception too

checkError: errno
The error with the C code `errno' has been reported. If errno >= 1, raise an exception

remove: fileName
Remove the file with the given path name

rename: oldFileName to: newFileName
Rename the file with the given path name oldFileName to newFileName

symlink: srcName as: destName
Create a symlink for the srcName file with the given path name

symlink: destName from: srcName
Create a symlink named destName file from the given path (relative to destName)

touch: fileName
Update the timestamp of the file with the given path name.


1.71.4 File class: instance creation

name: aName
Answer a new file with the given path. The path is not validated until some of the fields of the newly created objects are accessed

on: aVFSHandler
Answer a new file with the given path. The handler that returns the information is aVFSHandler


1.71.5 File class: reading system defaults

executable
Answer the full path to the executable being run.

image
Answer the full path to the image being used.


1.71.6 File class: testing

exists: fileName
Answer whether a file with the given name exists

isAccessible: fileName
Answer whether a directory with the given name exists and can be accessed

isExecutable: fileName
Answer whether a file with the given name exists and can be executed

isReadable: fileName
Answer whether a file with the given name exists and is readable

isWriteable: fileName
Answer whether a file with the given name exists and is writeable


1.71.7 File: accessing

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).

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.

name
Answer the name of the file identified by the receiver

refresh
Refresh the statistics for the receiver

size
Answer the size of the file identified by the receiver


1.71.8 File: file name management

directory
Answer the Directory object for the receiver's path

extension
Answer the extension of the receiver

fullName
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')

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


1.71.9 File: file operations

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

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.

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
Invoke aBlock with a reading stream open on me, closing it when the dynamic extent of aBlock ends.

withWriteStreamDo: aBlock
Invoke 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


1.71.10 File: printing

displayOn: aStream
Print a representation of the receiver on aStream.

printOn: aStream
Print a representation of the receiver on aStream.


1.71.11 File: testing

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

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.

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

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

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



Back: File-printing Up: File Forward: FileDescriptor   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on May, 22 2008 using texi2html