Files

AcornFileDirectory
An AcornFileDirectory is xxxxxxxxx.
Instance Variables
checkName:fixErrors:
Check if the file name contains any invalid characters
directoryContentsFor:
Return a collection of directory entries for the files and directories in
the directory with the given path. See primLookupEntryIn:index: for
further details.
directoryExists:
if the path is a root,we have to treat it carefully
fullPathFor:
if the arg is an empty string, just return my path name converted via the language stuff.
If the arg seems to be a rooted path, return it raw, assuming it is already ok.
Otherwise cons up a path
initialize
Subclasses should redefine this method to perform initializations on instance creation
isActiveDirectoryClass
isCaseSensitive
Return true if file names are treated case sensitive
maxFileNameLength
pathNameDelimiter
Return the delimiter character for this kind of directory. This depends on the current platform.
pathParts
Return the path from the root of the file system to this directory as an
array of directory names.
This version tries to cope with the RISC OS' strange filename formatting;
filesystem::discname/$/path/to/file
where the $ needs to be considered part of the filingsystem-discname atom.
privateFullPathForURI:
AsyncFile
An asynchronous file allows simple file read and write operations to be performed in parallel with other processing. This is useful in multimedia applications that need to stream large amounts of sound or image data from or to a file while doing other work.
close
fileHandle
initialize
Subclasses should redefine this method to perform initializations on instance creation
open:forWrite:
Open a file of the given name, and return a handle for that file. Answer the receiver if the primitive succeeds, nil otherwise.
If openForWrite is true, then:
if there is no existing file with this name, then create one
else open the existing file in read-write mode
otherwise:
if there is an existing file with this name, then open it read-only
else answer nil.
primClose:
Close this file. Do nothing if primitive fails.
primOpen:forWrite:semaIndex:
Open a file of the given name, and return a handle for that file. Answer the receiver if the primitive succeeds, nil otherwise.
primReadResult:intoBuffer:at:count:
Copy the result of the last read operation into the given buffer starting at the given index. The buffer may be any sort of bytes or words object, excluding CompiledMethods. Answer the number of bytes read. A negative result means:
-1 the last operation is still in progress
-2 the last operation encountered an error
primReadStart:fPosition:count:
Start a read operation of count bytes starting at the given offset in the given file.
primWriteResult:
Answer the number of bytes written. A negative result means:
-1 the last operation is still in progress
-2 the last operation encountered an error
primWriteStart:fPosition:fromBuffer:at:count:
Start a write operation of count bytes starting at the given index in the given buffer. The buffer may be any sort of bytes or words object, excluding CompiledMethods. The contents of the buffer are copied into an internal buffer immediately, so the buffer can be reused after the write operation has been started. Fail if there is insufficient C heap to allocate an internal buffer of the requested size.
readByteCount:fromFilePosition:onCompletionDo:
Start a read operation to read byteCount's from the given position in this file. and fork a process to await its completion. When the operation completes, evaluate the given block. Note that, since the completion block may run asynchronous, the client may need to use a SharedQueue or a semaphore for synchronization.
test:fileName:
AsyncFile new test: 10000 fileName: 'testData'
waitForCompletion
writeBuffer:atFilePosition:onCompletionDo:
Start an operation to write the contents of the buffer at given position in this file, and fork a process to await its completion. When the write completes, evaluate the given block. Note that, since the completion block runs asynchronously, the client may need to use a SharedQueue or a semaphore for synchronization.
CompressedSourceStream
I implement a file format that compresses segment by segment to allow incremental writing and browsing. Note that the file can only be written at the end.
Structure:
segmentFile The actual compressed file.
segmentSize This is the quantum of compression. The virtual file is sliced up
into segments of this size.
nSegments The maximum number of segments to which this file can be grown.
endOfFile The user's endOfFile pointer.
segmentTable When a file is open, this table holds the physical file positions
of the compressed segments.
segmentIndex Index of the most recently accessed segment.
Inherited from ReadWriteStream...
collection The segment buffer, uncompressed
position This is the position *local* to the current segment buffer
readLimit ReadLimit for the current buffer
writeLimit WriteLimit for the current buffer
Great care must be exercised to distinguish between the position relative to the segment buffer and the full file position (and, or course, the segment file position ;-).
The implementation defaults to a buffer size of 20k, and a max file size of 34MB (conveniently chosen to be greater than the current 33MB limit of source code pointers). The format of the file is as follows:
segmentSize 4 bytes
nSegments 4 bytes
endOfFile 4 bytes
segmentTable 4 bytes * (nSegments+1)
beginning of first compressed segment
It is possible to override the default allocation by sending the message #segmentSize:nSegments: immediately after opening a new file for writing, as follows:
bigFile _ (CompressedSourceStream on: (FileStream newFileNamed: 'biggy.stc'))
segmentSize: 50000 maxSize: 200000000
The difference between segment table entries reveals the size of each compressed segment. When a file is being written, it may lack the final segment, but any flush, position:, or close will force a dirty segment to be written.
atEnd
Primitive. Answer whether the receiver can access any more objects.
Optional. See Object documentation whatIsAPrimitive.
binary
do nothing
close
Presumably sets the status of the receiver to be closed. This message does
nothing at this level, but is included for FileStream compatibility.
contentsOfEntireFile
For non-file streams
fileID
Only needed for OSProcess stuff
firstSegmentLoc
First segment follows 3 header words and segment table
flush
Do nothing by default
next
Primitive. Return the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive.
next:
Answer the next anInteger elements of my collection. overriden for efficiency
nextPut:
Slow, but we don't often write, and then not a lot
nextPutAll:
Append the elements of aCollection to the sequence of objects accessible
by the receiver. Answer aCollection.
on:
openOn:
Open the receiver.
openReadOnly
position
Answer the current position of accessing the sequence of objects.
position:
Refer to the comment in PositionableStream|position:.
readHeaderInfo
readOnlyCopy
segmentOffset
segmentSize:maxSize:
Note that this method can be called after the initial open, provided that no
writing has yet taken place. This is how to override the default segmentation.
size
Primitive. Answer the number of indexable variables in the receiver.
This value is the same as the largest legal subscript. Essential. See Object
documentation whatIsAPrimitive.
test
FileDirectory default deleteFileNamed: 'test.stc'.
(CompressedSourceStream on: (FileStream newFileNamed: 'test.stc')) fileOutChanges
writeSegment
The current segment must be the last in the file.
CrLfFileStream
I am the same as a regular file stream, except that when I am in text mode, I will automatically convert line endings between the underlying platform's convention, and Squeak's convention of carriage-return only. The goal is that Squeak text files can be treated as OS text files, and vice versa.
In binary mode, I behave identically to a StandardFileStream.
To enable CrLfFileStream as the default file stream class for an entire image, modify FileStream class concreteStream .
There are two caveats on programming with CrLfFileStream.
First, the choice of text mode versus binary mode affects which characters are visible in Squeak, and no longer just affects whether those characters are returned as Character's or as Integer's. Thus the choice of mode needs to be made very carefully, and must be based on intent instead of convenience of representation. The methods asString, asByteArray, asCharacter, and asInteger can be used to convert between character and integer representations. (Arguably, file streams should accept either strings or characters in nextPut: and nextPutAll:, but that is not the case right now.)
Second, arithmetic on positions no longer works, because one character that Squeak sees (carriage return) could map to two characters in the underlying file (carriage return plus line feed, on MS Windows and MS DOS). Comparison between positions still works. (This caveat could perhaps be fixed by maintaining a map between Squeak positions and positions in the underlying file, but it is complicated. Consider, for example, updates to the middle of the file. Also, consider that text files are rarely updated in the middle of the file, and that general random access to a text file is rarely very useful. If general random access with specific file counts is desired, then the file is starting to sound like a binary file instead of a text file.)
ascii
opposite of binary
binary
Set this file to binary mode.
convertStringFromCr:
convertStringToCr:
defaultToCR
defaultToCRLF
defaultToLF
detectLineEndConvention
Detect the line end convention used in this stream. The result may be either #cr, #lf or #crlf.
guessDefaultLineEndConvention
initialize
Subclasses should redefine this method to perform initializations on instance creation
lineEndConvention
lineEndingConvention:
new
next
Answer the next byte from this file, or nil if at the end of the file.
next:
Return a string with the next n characters of the filestream in it. 1/31/96 sw
nextPut:
Write the given character to this file.
nextPutAll:
Write all the characters of the given string to this file.
open:forWrite:
Open the receiver. If writeMode is true, allow write, else access will be
read-only.
peek
Answer what would be returned if the message next were sent to the receiver. If the receiver is at the end, answer nil.
startUp
upTo:
Fast version to speed up nextChunk
verbatim:
Do not attempt to translate the characters. Use to override nextPutAll:
DirectoryEntry
an entry in a directory; a reference to either a file or a directory.
at:
compatibility interface
convertFromSystemName
creationTime
time the entry was created. (what's its type?)
fileSize
size of the entry, if it's a file
fromArray:
isDirectory
whether this entry represents a directory
modificationTime
time the entry was last modified
name
name of the entry
name:creationTime:modificationTime:isDirectory:fileSize:
privateName:creationTime:modificationTime:isDirectory:fileSize:
size
Answer how many elements the receiver contains.
DosFileDirectory
I represent a DOS or Windows FileDirectory.
checkName:fixErrors:
Check if the file name contains any invalid characters
driveName
return a possible drive letter and colon at the start of a Path name, empty string otherwise
fullNameFor:
Return a corrected, fully-qualified name for the given file name. If the given name is already a full path (i.e., it contains a delimiter character), assume it is already a fully-qualified name. Otherwise, prefix it with the path to this directory. In either case, correct the local part of the file name.
fullPathFor:
Return the fully-qualified path name for the given file.
isCaseSensitive
Return true if file names are treated case sensitive
isDrive:
maxFileNameLength
pathNameDelimiter
Return the delimiter character for this kind of directory. This depends on the current platform.
privateFullPathForURI:
relativeNameFor:
Return the full name for path, assuming that path is a name relative to me.
setPathName:
Ensure pathString is absolute - relative directories aren't supported on all platforms.
splitName:to:
FileDirectory
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.
acceptsUploads
activeDirectoryClass
asUrl
Convert my path into a file:// type url - a FileUrl.
assureExistence
Make sure the current directory exists. If necessary, create all parts in between
assureExistenceOfPath:
Make sure the local directory exists. If necessary, create all parts in between
baseNameFor:
changeSuffix
checkName:fixErrors:
Check a string aFileName for validity as a file name. Answer the original file name if it is valid. If the name is not valid (e.g., it is too long or contains illegal characters) and fixing is false, raise an error. If fixing is true, fix the name (usually by truncating and/or tranforming characters), and answer the corrected name. The default behavior is just to truncate the name to the maximum length for this platform. Subclasses can do any kind of checking and correction appropriate for their platform.
containingDirectory
Return the directory containing this directory.
contentStreamForURI:
contentUTF8StreamForURI:
contentUTF8WriteableStreamForURI:
contentWriteableStreamForURI:
copyFile:toFile:
copyFileNamed:toFileNamed:
Copy the contents of the existing file with the first name into a new file with the second name. Both files are assumed to be in this directory.
copyFileWithoutOverwriteConfirmationNamed:toFileNamed:
Copy the contents of the existing file with the first name into a file with the second name (which may or may not exist). If the second file exists, force an overwrite without confirming. Both files are assumed to be in this directory.
createDirectory:
Create a directory with the given name in this directory. Fail if the name is bad or if a file or directory with that name already exists.
default
deleteDirectory:
Delete the directory with the given name in this directory. Fail if the path is bad or if a directory by that name does not exist.
deleteFileNamed:
Delete the file with the given name in this directory.
deleteFileNamed:ifAbsent:
Delete the file of the given name if it exists, else evaluate failBlock.
If the first deletion attempt fails do a GC to force finalization of any lost references. ar 3/21/98 17:53
deleteFilePath:
deleteLocalFiles
Delete the local files in this directory.
dirPathFor:
directoryContentsFor:
Return a collection of directory entries for the files and directories in the directory with the given path. See primLookupEntryIn:index: for further details.
directoryEntry
directoryEntryFor:
Answer the directory entry for the given file or path. Sorta like a poor man's stat().
directoryExists:
Answer true if a directory of the given name exists. The given name may be either a full path name or a local directory within this directory.
directoryNamed:
Return the subdirectory of this directory with the given name.
directoryNames
Return a collection of names for the subdirectories of this directory.
directoryObject
dot
downloadUrl
entries
Return a collection of directory entries for the files and directories in this directory. Each entry is a five-element array: (<name><creationTime><modificationTime><dirFlag><fileSize>). See primLookupEntryIn:index: for further details.
entryAt:
find the entry with local name fileName
entryAt:ifAbsent:
Find the entry with local name fileName and answer it.
If not found, answer the result of evaluating aBlock.
exists
Answer whether the directory exists
extensionDelimiter
extensionFor:
fileAndDirectoryNames
FileDirectory default fileAndDirectoryNames
fileExists:
Answer true if a file of the given name exists. The given name may be either a full path name or a local file within this directory.
fileName:extension:
fileNamed:
Open the file with the given name in this directory for writing.
fileNames
Return a collection of names for the files (but not directories) in this directory.
fileNamesMatching:
FileDirectory default fileNamesMatching: '*'
FileDirectory default fileNamesMatching: '*.image;*.changes'
fileOrDirectoryExists:
Answer true if either a file or a directory file of the given name exists. The given name may be either a full path name or a local name within this directory.
fileSuffixesForMimeType:
Return a list file suffixes for mime type. This is a suboptimal solution.
filesContaining:caseSensitive:
Search the contents of all files in the receiver and its subdirectories for the search string. Return a list of paths found. Make the search case sensitive if aBoolean is true.
forFileName:
forceNewFileNamed:
Open the file with the given name in this directory for writing. If it already exists, delete it first without asking.
fullName
Return the full name of this directory.
fullNameFor:
Return a corrected, fully-qualified name for the given file name. If the given name is already a full path (i.e., it contains a delimiter character), assume it is already a fully-qualified name. Otherwise, prefix it with the path to this directory. In either case, correct the local part of the file name.
fullNamesOfAllFilesInSubtree
Answer a collection containing the full names of all the files in the subtree of the file system whose root is this directory.
fullPathFor:
fullPathForURI:
getMacFileTypeAndCreator:
get the Macintosh file type and creator info for the file with the given name. Fails if the file does not exist or if the type and creator type arguments are not strings of length 4. Does nothing on other platforms (where the underlying primitive is a noop).
imageSuffix
includesKey:
Answer true if this directory includes a file or directory of the given name. Note that the name should be a local file name, in contrast with fileExists:, which takes either local or full-qualified file names.
isAFileNamed:
isActiveDirectoryClass
isCaseSensitive
Return true if file names are treated case sensitive
isLegalFileName:
Answer true if the given string is a legal file name.
isRemoteDirectory
answer whatever the receiver is a remote directory
isTypeFile
keysDo:
Evaluate the given block for each file or directory name in this directory.
lastNameFor:extension:
Assumes a file name includes a version number encoded as '.' followed by digits
preceding the file extension. Increment the version number and answer the new file name.
If a version number is not found, set the version to 1 and answer a new file name
localName
Return the local name of this directory.
localNameFor:
Return the local part the given name.
lookInUsualPlaces:
makeAbsolute:
makeRelative:
matchingEntries:
Ignore the filter criteria for now
maxFileNameLength
mimeTypesFor:
Return a list of MIME types applicable to the receiver. This default implementation uses the file name extension to figure out what we're looking at but specific subclasses may use other means of figuring out what the type of some file is. Some systems like the macintosh use meta data on the file to indicate data type
newFileNamed:
Create a new file with the given name in this directory.
nextNameFor:extension:
Assumes a file name includes a version number encoded as '.' followed by digits
preceding the file extension. Increment the version number and answer the new file name.
If a version number is not found, set the version to 1 and answer a new file name
oldFileNamed:
Open the existing file with the given name in this directory.
oldFileOrNoneNamed:
If the file exists, answer a read-only FileStream on it. If it doesn't, answer nil.
on:
Return another instance
openChanges:forImage:
openSources:andChanges:forImage:
openSources:forImage:
pathFromUrl:
pathName
Return the path from the root of the file system to this directory.
pathNameDelimiter
Return the delimiter character for this kind of directory. This depends on the current platform.
pathParts
Return the path from the root of the file system to this directory as an array of directory names.
primCreateDirectory:
Create a directory named by the given path. Fail if the path is bad or if a file or directory by that name already exists.
primDeleteDirectory:
Delete the directory named by the given path. Fail if the path is bad or if a directory by that name does not exist.
primDeleteFileNamed:
Delete the file of the given name. Return self if the primitive succeeds, nil otherwise.
primGetMacFileNamed:type:creator:
Get the Macintosh file type and creator info for the file with the given name. Fails if the file does not exist or if the type and creator type arguments are not strings of length 4. This primitive is Mac specific; it is a noop on other platforms.
primLookupEntryIn:index:
Look up the index-th entry of the directory with the given fully-qualified path (i.e., starting from the root of the file hierarchy) and return an array containing:
<name> <creationTime> <modificationTime> <dirFlag> <fileSize>
The empty string enumerates the top-level files or drives. (For example, on Unix, the empty path enumerates the contents of '/'. On Macs and PCs, it enumerates the mounted volumes/drives.)
The creation and modification times are in seconds since the start of the Smalltalk time epoch. DirFlag is true if the entry is a directory. FileSize the file size in bytes or zero for directories. The primitive returns nil when index is past the end of the directory. It fails if the given path is bad.
primPathNameDelimiter
primRename:to:
Rename the file of the given name to the new name. Fail if there is no file of the old name or if there is an existing file with the new name.
Changed to return nil instead of failing ar 3/21/98 18:04
primSetMacFileNamed:type:creator:
Set the Macintosh file type and creator info for the file with the given name. Fails if the file does not exist or if the type and creator type arguments are not strings of length 4. This primitive is Mac specific; it is a noop on other platforms.
printOn:
Refer to the comment in Object|printOn:.
privateFullPathForURI:
putFile:named:
Copy the contents of the existing fileStream into the file destinationFileName in this directory. fileStream can be anywhere in the fileSystem.
putFile:named:retry:
Copy the contents of the existing fileStream into the file destinationFileName in this directory. fileStream can be anywhere in the fileSystem. No retrying for local file systems.
readOnlyFileNamed:
Open the existing file with the given name in this directory for read-only access.
realUrl
Senders expect url without trailing slash - #url returns slash
recursiveDelete
Delete the this directory, recursing down its tree.
relativeNameFor:
Return the full name for aFileName, assuming that aFileName is a name relative to me.
rename:toBe:
Rename the file of the given name to the new name. Fail if there is no file of the old name or if there is an existing file with the new name.
retrieveMIMEDocument:
root
setDefaultDirectory:
setDefaultDirectoryClass
setDefaultDirectoryFrom:
setMacFileNamed:type:creator:
Set the Macintosh file type and creator info for the file with the given name. Fails if the file does not exist or if the type and creator type arguments are not strings of length 4. Does nothing on other platforms (where the underlying primitive is a noop).
setPathName:
shutDown
slash
sleep
Leave the FileList window. Do nothing. Disk directories do not have to be shut down.
splitName:to:
splitNameVersionExtensionFor:
answer an array with the root name, version # and extension.
See comment in nextSequentialNameFor: for more details
startUp
statsForDirectoryTree:
Return the size statistics for the entire directory tree starting at the given root. The result is a three element array of the form: (<number of folders><number of files><total bytes in all files>). This method also serves as an example of how recursively enumerate a directory tree.
storeServerEntryOn:
upLoadProject:named:resourceUrl:retry:
Copy the contents of the existing fileStream into the file destinationFileName in this directory. fileStream can be anywhere in the fileSystem. No retrying for local file systems.
updateProjectInfoFor:
only swiki servers for now
uri
Convert my path into a file:// type url. For odd characters use %20 notation.
uri:
url
Convert my path into a file:// type url String.
urlForFileNamed:
wakeUp
Entering a FileList window. Do nothing. Disk directories do not have to be awakened.
withAllFilesDo:andDirectoriesDo:
For the receiver and all it's subdirectories evaluate directoryBlock.
For a read only file stream on each file within the receiver
and it's subdirectories evaluate fileStreamBlock.
withAllSubdirectoriesCollect:
Evaluate aBlock with each of the directories in the subtree of the file system whose root is this directory.
Answer the results of these evaluations.
writeProject:inFileNamed:fromDirectory:
write aProject (a file version can be found in the file named fileNameString in localDirectory)
FilePath
This class absorb the difference of internal and external representation of the file path. The idea is to keep the internal one as much as possible, and only when it goes to a primitive, the encoded file path, i.e. the native platform representation is passsed to the primitive.
The converter used is obtained by "LanguageEnvironment defaultFileNameConverter".
asSqueakPathName
asString
Answer a string that represents the receiver.
asVmPathName
classVersion
copySystemToVm
coverter:
isNullPath
an empty path is used to represent the root path(s) when calling the primitive to list directory entries. Some users need to check for this and this is cleaner than grabbing the pathname and assuming it is a plain String
pathName
pathName:
pathName:isEncoded:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
FileStream
I represent a Stream that accesses a FilePage from a File. One use for my instance is to access larger "virtual Strings" than can be stored contiguously in main memory. I restrict the objects stored and retrieved to be Integers or Characters. An end of file pointer terminates reading; it can be extended by writing past it, or the file can be explicitly truncated.

To use the file system for most applications, you typically create a FileStream. This is done by sending a message to a FileDirectory (file:, oldFile:, newFile:, rename:newName:) which creates an instance of me. Accesses to the file are then done via my instance.
*** On DOS, files cannot be shortened! *** To overwrite a file with a shorter one, first delete the old file (FileDirectory deleteFilePath: 'Hard Disk:aFolder:dataFolder:foo') or (aFileDirectory deleteFileNamed: 'foo'). Then write your new shorter version.
asBinaryOrTextStream
I can switch between binary and text data
asUrl
Convert my path into a file:// type url - a FileUrl.
ascii
Set this file to ascii (text) mode.
atEnd
Answer true if the current position is >= the end of file position.
1/31/96 sw: subclassResponsibility
binary
Set this file to binary mode.
close
Close this file.
closed
Answer true if this file is closed.
concreteStream
contents
Return the contents of the receiver. Do not close or otherwise touch the receiver. Return data in whatever mode the receiver is in (e.g., binary or text).
contentsOfEntireFile
Read all of the contents of the receiver.
convertCRtoLF:
cs
dataIsValid
detectFile:do:
directoryEntry
edit
Create and schedule an editor on this file.
file
Answer the file for the page the receiver is streaming over.
1/31/96 sw: made subclass responsibility
fileIn
Guarantee that the receiver is readOnly before fileIn for efficiency and
to eliminate remote sharing conflicts.
fileIn:
fileInObjectAndCode
Read the file directly, do not use an RWBinaryOrTextStream.
fileIntoNewChangeSet
File all of my contents into a new change set.
fileNamed:
fileNamed:do:
fileReaderServicesForFile:suffix:
flush
When writing, flush the current buffer out to disk.
forceNewFileNamed:
forceNewFileNamed:do:
fullName:
httpPostDocument:args:
httpPostMultipart:args:
initialize
Subclasses should redefine this method to perform initializations on instance creation
isAFileNamed:
isSourceFileSuffix:
localName
longPrintOn:
Do nothing, so it will print short. Called to print the error file. If the error was in a file operation, we can't read the contents of that file. Just print its name instead.
longPrintOn:limitedTo:indent:
Do nothing, so it will print short. Called to print the error file. If the error was in a file operation, we can't read the contents of that file. Just print its name instead.
mimeTypes
multiCs
multiSt
name
Answer the name of the file for the page the receiver is streaming over. 1/31/96 sw: made subclassResponsibility
new
newFileNamed:
newFileNamed:do:
next
Primitive. Return the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive.
next:
Answer the next anInteger elements of my collection. overriden for efficiency
nextPut:
1/31/96 sw: subclassResponsibility
nextPutAll:
1/31/96 sw: made subclass responsibility
oldFileFullyNamed:
oldFileNamed:
oldFileNamed:do:
oldFileOrNoneNamed:
position
Answer the current character position in the file.
1/31/96 sw: subclassResponsibility
position:
Set the current character position in the file to pos.
1/31/96 sw: made subclassResponsibility
post:target:url:ifError:
post:url:ifError:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
readOnly
Set this file's mode to read-only.
readOnlyFileFullyNamed:
readOnlyFileNamed:
readOnlyFileNamed:do:
readOnlyStream
readWrite
Set this file's mode to read-write.
removeLineFeeds:
reopen
Ensure that the receiver is open, re-open it if necessary.
requestDropStream:
requestURL:target:
requestURLStream:
requestURLStream:ifError:
reset
Set the current character position to the beginning of the file.
1/31/96 sw: subclassResponsibility
serviceFileIn
serviceRemoveLineFeeds
services
setToEnd
Set the current character position to the end of the File. The same as
self position: self size. 1/31/96 sw: made subclassResponsibility
size
Answer the size of the file in characters.
1/31/96 sw: made subclass responsibility
skip:
Set the character position to n characters from the current position.
Error if not enough characters left in the file
1/31/96 sw: made subclassResponsibility.
sourceFileSuffixes
st
text
Set this file to text (ascii) mode.
truncate:
Truncate file to pos
unload
uri
url
Convert my path into a file:// type url String.
viewGZipContents
View the contents of a gzipped file
writeSourceCodeFrom:baseName:isSt:
writeSourceCodeFrom:baseName:isSt:useHtml:
MacFileDirectory
I represent a Macintosh FileDirectory.
fullNameFor:
Return a corrected, fully-qualified name for the given file name. If the given name is already a full path (i.e., it contains a delimiter character), assume it is already a fully-qualified name. Otherwise, prefix it with the path to this directory. In either case, correct the local part of the file name.
fullPathFor:
Return the fully-qualified path name for the given file.
getTypeToMimeMappings
initializeTypeToMimeMappings
isAbsolute:
isActiveDirectoryClass
isCaseSensitive
Return true if file names are treated case sensitive
makeAbsolute:
makeRelative:
mimeTypesFor:
Return a list of MIME types applicable to the receiver. This default implementation uses the file name extension to figure out what we're looking at but specific subclasses may use other means of figuring out what the type of some file is. Some systems like the macintosh use meta data on the file to indicate data type
pathNameDelimiter
Return the delimiter character for this kind of directory. This depends on the current platform.
privateFullPathForURI:
MacHFSPlusFileDirectory
A MacHFSPlusFileDirectory is xxxxxxxxx.
Instance Variables
isActiveDirectoryClass
maxFileNameLength
RemoteString
My instances provide an external file reference to a piece of text. It may be the sourceCode of a method, or the class comments of a class.
The changes file or file-in file usually has a chunk that is just the source string of a method:
max: aNumber
^ self > aNumber ifTrue: [self] ifFalse: [aNumber]!
I can return either a String or a Text. Some a chunk is followed by a second chunk (beginning with ]style[) containing style information. The encoding is like this:
max: aNumber
^ self > aNumber ifTrue: [self] ifFalse: [aNumber]!
]style[(14 50 312)f1,f1b,f1LInteger +;i!
Allowed TextAttributes are TextFontChange, TextEmphasis, TextColor, TextDoIt, TextKern, TextLink, TextURL. TextFontReference and TextAnchor are not supported.
See PositionableStream nextChunkText and RunArray class scanFrom:.
checkSum:
Construct a checksum of the string. A three byte number represented as Base64 characters.
currentTextAttVersion
fileNumber:position:
fileStream
Answer the file stream with position set at the beginning of my string.
Answer a read only copy to avoid syntax errors when accessed via
multiple processes.
initialize
Subclasses should redefine this method to perform initializations on instance creation
last
makeNewTextAttVersion
Create a new TextAttributes version because some inst var has changed. If no change, don't make a new one.
newFileNumber:position:
newString:onFileNumber:
newString:onFileNumber:toFile:
position
Answer the location of the string on a file.
setSourcePointer:
sourceFileNumber
Answer the index of the file on which the string is stored.
sourcePointer
string
Answer the receiver's string if remote files are enabled.
Use a read only copy to avoid syntax errors when accessed via
multiple processes.
string:onFileNumber:
Store this as my string if source files exist.
string:onFileNumber:toFile:
Store this as the receiver's text if source files exist. If aStringOrText is a Text, store a marker with the string part, and then store the runs of TextAttributes in the next chunk.
structureAt:
text
Answer the receiver's string asText if remote files are enabled.
Use a read only copy to avoid syntax errors when accessed via
multiple processes.
SourceFileArray
This class is an abstract superclass for source code access mechanisms. It defines the messages that need to be understood by those subclasses that store and retrieve source chunks on files, over the network or in databases.
The first concrete subclass, StandardSourceFileArray, supports access to the traditional sources and changes files. Other subclasses might implement multiple source files for different applications, or access to a network source server.
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
fileIndexFromSourcePointer:
Return the index of a source file corresponding to the given source pointer.
filePositionFromSourcePointer:
Return the position within a source file for the given source pointer.
size
Answer how many elements the receiver contains.
sourcePointerFromFileIndex:andPosition:
Return a sourcePointer encoding the given file index and position
StandardFileStream
Provides a simple, platform-independent, interface to a file system. This initial version ignores issues of Directories etc. The instance-variable fallbackStream at the moment holds an instance of HFSMacFileStream, to bridge us to the new world while in the old. The instance variable rwmode, inherited from class PositionableStream, here is used to hold a Boolean -- true means opened for read-write, false means opened for read-only. 2/12/96 sw
actAsExecutor
Prepare the receiver to act as executor for any resources associated with it
ascii
opposite of binary
atEnd
Answer whether the receiver is at its end.
basicNext
Answer the next byte from this file, or nil if at the end of the file.
binary
Set this file to binary mode.
close
Close this file.
closed
Answer true if this file is closed.
compressFile
Write a new file that has the data in me compressed in GZip format.
contentType
defaultBrowserReadyWait
directory
Return the directory containing this file.
directoryUrl
ensureOpen
Make sure that this file really is open.
file
Answer the object representing the receiver's file. Need for compatibility with some calls -- check senders. 2/14/96 sw
fileDoesNotExistUserHandling:
fileExistsUserHandling:
fileNamed:
finalize
Finalize the resource associated with the receiver. This message should only be sent during the finalization process. There is NO garantuee that the resource associated with the receiver hasn't been free'd before so take care that you don't run into trouble - this all may happen with interrupt priority.
findString:
Fast version of #upToAll: to find a String in a file starting from the beginning.
Returns the position and also sets the position there.
If string is not found 0 is returned and position is unchanged.
findStringFromEnd:
Fast version to find a String in a file starting from the end.
Returns the position and also sets the position there.
If string is not found 0 is returned and position is unchanged.
flush
Flush pending changes
forceNewFileNamed:
fullName
Answer this file's full path name.
getFileType
On the Macintosh, get the file type and creator of this file. On other platforms, do nothing.
insertLineFeeds
(FileStream oldFileNamed: 'BBfix2.st') insertLineFeeds
isAFileNamed:
isBinary
Return true if the receiver is a binary byte stream
isDirectory
Answer whether the receiver represents a directory. For the post-transition case, uncertain what to do. 2/14/96 sw
isReadOnly
isRunningAsBrowserPlugin
localName
mimeType
name
Answer this file's full path name.
newFileNamed:
next
Answer the next byte from this file, or nil if at the end of the file.
next:
Return a string with the next n characters of the filestream in it. 1/31/96 sw
next:into:startingAt:
Read n bytes into the given string.
Return aString or a partial copy if less than
n elements have been read.
next:putAll:startingAt:
Store the next anInteger elements from the given collection.
nextPut:
Write the given character to this file.
nextPutAll:
Write all the characters of the given string to this file.
nextWordsInto:
Note: The file primitives automatically adjust for word based objects.
oldFileFullyNamed:
oldFileNamed:
open
For compatibility with a few existing things. 2/14/96 sw
open:forWrite:
Open the file with the given name. If writeMode is true, allow writing, otherwise open the file in read-only mode.
openReadOnly
Open the receiver as a read-only file. 1/31/96 sw
padToEndWith:
On the Mac, files do not truncate. One can delete the old file and write a new one, but sometime deletion fails (file still open? file stale?). This is a sad compromise. Just let the file be the same length but pad it with a harmless character.
peek
Answer what would be returned if the message next were sent to the receiver. If the receiver is at the end, answer nil.
peekFor:
Answer false and do not advance if the next element is not equal to item, or if this stream is at the end. If the next element is equal to item, then advance over it and return true
peekLast
Return that item just put at the end of the stream
position
Return the receiver's current file position. 2/12/96 sw
position:
Set the receiver's position as indicated. 2/12/96 sw
post:target:url:ifError:
Post data to the given URL. The returned file stream contains the reply of the server.
If Squeak is not running in a browser evaluate errorBlock
post:url:ifError:
primAtEnd:
Answer true if the file position is at the end of the file.
primBrowserReady
primClose:
Close this file.
primCloseNoError:
Close this file. Don't raise an error if the primitive fails.
primDropRequestFileHandle:
Primitive. Return the (read-only) file handle for some file that was just dropped onto Squeak.
Fail if dropIndex is out of range or the primitive is not supported.
primDropRequestFileName:
Primitive. Return the file name for some file that was just dropped onto Squeak.
Fail if dropIndex is out of range or the primitive is not supported.
primFlush:
Flush pending changes to the disk
primGetPosition:
Get this files current position.
primOpen:writable:
Open a file of the given name, and return the file ID obtained.
If writableFlag is true, then
if there is none with this name, then create one
else prepare to overwrite the existing from the beginning
otherwise
if the file exists, open it read-only
else return nil
primRead:into:startingAt:count:
Read up to count bytes of data from this file into the given string or byte array starting at the given index. Answer the number of bytes actually read.
primSetPosition:to:
Set this file to the given position.
primSize:
Answer the size of this file.
primSizeNoError:
Answer the size of this file. Answer nil if the primitive fails; this indicates that the file handle has become stale.
primTruncate:to:
Truncate this file to the given position.
primURLPost:data:semaIndex:
primURLPost:target:data:semaIndex:
Post the data (url might be 'mailto:' etc)
primURLRequest:semaIndex:
primURLRequest:target:semaIndex:
target - String (frame, also ':=top', ':=parent' etc)
primURLRequestDestroy:
primURLRequestFileHandle:
primURLRequestState:
primWrite:from:startingAt:count:
Write count bytes onto this file from the given string or byte array starting at the given index. Answer the number of bytes written.
printOn:
Put a printed version of the receiver onto aStream. 1/31/96 sw
privateCheckForBrowserPrimitives
readInto:startingAt:count:
Read into the given array as specified, and return the count
actually transferred. index and count are in units of bytes or
longs depending on whether the array is Bitmap, String or ByteArray
readOnly
Make this file read-only.
readOnlyCopy
readOnlyFileDoesNotExistUserHandling:
readOnlyFileFullyNamed:
readOnlyFileNamed:
readWrite
Make this file writable.
register
register:
registry
reopen
Close and reopen this file. The file position is reset to zero.
requestDropStream:
Return a read-only stream for some file the user has just dropped onto Squeak.
requestURL:target:
requestURL:target:ifError:
Request to go to the target for the given URL.
If Squeak is not running in a browser evaluate errorBlock
requestURLStream:
FileStream requestURLStream:'http://www.squeak.org'
requestURLStream:ifError:
Request a FileStream for the given URL.
If Squeak is not running in a browser evaluate errorBlock
reset
Set the current character position to the beginning of the file.
1/31/96 sw: subclassResponsibility
retryWithGC:until:forFileNamed:
setFileTypeToObject
On the Macintosh, set the file type and creator of this file to be a Squeak object file. On other platforms, do nothing. Setting the file type allows Squeak object files to be sent as email attachments and launched by double-clicking. On other platforms, similar behavior is achieved by creating the file with the '.sqo' file name extension.
setToEnd
Set the position of the receiver to the end of file. 1/31/96 sw
size
Answer the size of the file in characters. 2/12/96 sw
skip:
Set the character position to n characters from the current position.
Error if not enough characters left in the file. 1/31/96 sw
truncate
Truncate to zero
truncate:
Truncate to this position
unregister
unregister:
upTo:
Fast version to speed up nextChunk
upToEnd
Answer a subcollection from the current access position through the last element of the receiver.
waitBrowserReadyFor:ifFail:
StandardSourceFileArray
This class implements the source file management behavior of traditional Squeak, with a sources file and a changes file. File positions are mapped such that those files can be up to 32MBytes in size.
Structure:
files Array -- storing the actual source files
at:
Primitive. Assumes receiver is indexable. Answer the value of an
indexable element in the receiver. Fail if the argument index is not an
Integer or is out of bounds. Essential. See Object documentation
whatIsAPrimitive.
at:put:
Primitive. Assumes receiver is indexable. Store the argument value in
the indexable element of the receiver indicated by index. Fail if the
index is not an Integer or is out of bounds. Or fail if the value is not of
the right type for this kind of collection. Answer the value that was
stored. Essential. See Object documentation whatIsAPrimitive.
fileIndexFromSourcePointer:
Return the index of the source file which contains the source chunk addressed by anInteger
filePositionFromSourcePointer:
Return the position of the source chunk addressed by anInteger
initialize
Subclasses should redefine this method to perform initializations on instance creation
initialize:
install
new:
size
Answer how many elements the receiver contains.
sourcePointerFromFileIndex:andPosition:
Return a source pointer according to the new 32M algorithm
UnixFileDirectory
I represent a Unix FileDirectory.
directoryExists:
Handles the special case of testing for the root dir: there isn't a
possibility to express the root dir as full pathname like '/foo'.
fileOrDirectoryExists:
Handles the special case of testing for the root dir: there isn't a
possibility to express the root dir as full pathname like '/foo'.
fullPathFor:
Return the fully-qualified path name for the given file.
maxFileNameLength
pathFromUrl:
pathNameDelimiter
Return the delimiter character for this kind of directory. This depends on the current platform.
setPathName:
Unix path names start with a leading delimiter character.