eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'Filename':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: Filename


Inheritance:

   Object
   |
   +--Filename
      |
      +--AutoDeletedFilename
      |
      +--UnixFilename

Package:
stx:libbasic
Category:
System-Support
Version:
rev: 1.547 date: 2019/08/17 12:40:21
user: cg
file: Filename.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


Filenames; originally added for ST-80 compatibility, is
taking over functionality from other classes (FileDirectory).

Instances of Filename do not necessarily represent valid or existing
files - i.e. it is possible (and useful) to have instances for non-existing
files around. In other words: the name-string is not checked automatically
for being correct or existing.
Thus, it is possible to do queries such as:

    '/fee/foo/foe' asFilename exists
    '/not_existing' asFilename isDirectory
    '/foo/bar' asFilename isReadable

(all of the above examples will probably return false on your machine ;-).

examples:

    'Makefile' asFilename readStream

    'newFile' asFilename writeStream

    Filename newTemporary writeStream

Beside lots of protocol to query for a file's attributes, the class
protocol offers methods for filename completion, to construct paths
(in an OS-independent way) and to create temporary files.
Especially the path construction methods (i.e. #construct:) are highly
recommended in order to avoid having OS details (like directory separators
being slash or backslash) spread in your application.

Since Filenames have different semantics under different operating systems,
class methods are delegated to concrete implementations in various subclasses like
UnixFilename, PCFilename, ...
The delegation is implemented in a way, so that some methods of
specific OS Filenames might be used, even if ST/X is currently running
on a different OS (as long as the method does not depend on the OperatingSystem class).


Related information:

    String
    FileStream
    DirectoryStream
    PipeStream
    Socket
    OperatingSystem
    Date
    Time

Class protocol:

defaults
o  concreteClass
different subclasses of Filename are used for different
OperatingSystems; concreteClass is supposed to return an appropriate class.

o  defaultClass
different subclasses of Filename are used for different
OperatingSystems; defaultClass is supposed to return an appropriate class

o  defaultTempDirectoryName
return the default temp directory as a filename.
This is used, if no special preferences were defined in
any of the TEMP-environment variables (see tempDirectory).

usage example(s):

     Filename defaultTempDirectoryName

o  defaultVolumeName

initialization
o  initialize
initialize for the OS we are running on

usage example(s):

     self initialize

o  initializeConcreteClass
initialize for the OS we are running on

usage example(s):

     self initializeConcreteClass

o  reinitialize
initialize for the OS we are running on (after a restart)

usage example(s):

     self reinitialize

instance creation
o  applicationDataDirectory
return the directory, where user-and-application-specific private files are to be
located (ini-files, preferences etc.).
Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>'
is returned, under unix, we use ~/.<appName> (but see details in UnixOS).
For smalltalk itself (the IDE), 'smalltalk' is used as appName.
If the directory does not exist, it is created

usage example(s):

     Filename applicationDataDirectory

o  applicationDataDirectoryFor: appName
return the directory, where user-and-application-specific private files are to be
located (ini-files, preferences etc.).
Under windows, something like 'C:\Users\Administrator\AppData\Roaming\<appName>'
is returned, under unix, we use ~/.<appName> (but see details in UnixOS).
If the directory does not exist, it is created

usage example(s):

     Filename applicationDataDirectoryFor:'smalltalk'
     Filename applicationDataDirectoryFor:'expecco'

o  currentDirectory
return a filename for the current directory

usage example(s):

     Filename currentDirectory

o  defaultDirectory
ST80 compatibility: same as currentDirectory

usage example(s):

     Filename defaultDirectory

o  defaultTempDirectory
return the default temp directory as a filename.
That is the same as TempDirectory, except that TempDirectory can be changed
from the outside (via tempDirectory:) whereas this is the OS's original default.
Use this for files which MUST remain the same (stx_sourceCache)

usage example(s):

     Filename tempDirectory
     Filename defaultTempDirectory

o  desktopDirectory
return your desktop directory.
Under windows, that's the real desktop directory;
under other OperatingSystems, the home directory is returned.

usage example(s):

     Filename desktopDirectory

o  documentsDirectory
return your documents directory.
Under windows, that's the real 'Documents' or 'My Documents';
under other OperatingSystems, the home directory is returned.

usage example(s):

     Filename documentsDirectory

o  downloadsDirectory
return the downloads directory.
Some OperatingSystems do not support this - on those,
the documentsDirectory is returned.
Notice: services under windows do not have a user/home and therefore
no downloads directory.

usage example(s):

     Filename downloadsDirectory

o  findDefaultDirectory
same as #defaultDirectory for ST80 compatibility

o  fromComponents: aCollectionOfDirectoryNames
create & return a new filename from components given in
aCollectionOfDirectoryNames. If the first component is the name of the
root directory (i.e. '/') an absolute path-filename is returned.

usage example(s):

     Filename fromComponents:#('/' 'foo' 'bar' 'baz')
     PCFilename fromComponents:#('/' 'foo' 'bar' 'baz')
     UnixFilename fromComponents:#('/' 'foo' 'bar' 'baz')
     OpenVMSFilename fromComponents:#('foo' 'bar' 'baz')

     Filename fromComponents:#('foo' 'bar' 'baz')
     Filename fromComponents:#('/')

     Filename fromComponents:
         (Filename components:('.' asFilename pathName))

     Filename fromComponents:
         (Filename components:('.' asFilename name))

o  fromUser
show a box to enter a filename.
Return a filename instance or nil (if cancel was pressed).

usage example(s):

     Filename fromUser

o  homeDirectory
return your homeDirectory.
Some OperatingSystems do not support this - on those, the defaultDirectory
(which is the currentDirectory) is returned.
Notice: services under windows also do not have a home directory.

usage example(s):

     Filename homeDirectory

o  named: aString
return a filename for a directory named aString.
This is the same as 'aString asFilename'.

usage example(s):

     Filename named:'/tmp/fooBar'

o  newTemporary
return a new unique filename - use this for temporary files.
The filenames returned are '/tmp/stxtmp_xx_nn' where xx is our
unix process id, and nn is a unique number, incremented with every
call to this method.
If any of the environment variables STX_TMPDIR, ST_TMPDIR, TMPDIR is set,
its value defines the temp directory.
Notice, that no file is created by this - only a unique name
is generated.

DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporary
(the insecurity is due to a small chance for some other program to open/create
the file, as only a name is generated here. However, chances are small as the name
is reasonably random - but for security relevant applications, this may be relevant)

usage example(s):

     Filename newTemporary
     Filename newTemporary

o  newTemporaryDirectory
return a new unique temporary directory - use this for temporary files.
The directories returned are '/tmp/stxtmp_xx_nn' where xx is our
unix process id, and nn is a unique number, incremented with every
call to this method.
If any of the environment variables STX_TMPDIR, ST_TMPDIR, TMPDIR is set,
its value defines the temp directory.

o  newTemporaryDirectoryIn: aDirectoryOrNil
return a new unique temporary directory in another directory, or the current dir.
Use this for temporary files.
The directories returned are '/tmp/stxtmp_xx_nn' where xx is our
unix process id, and nn is a unique number, incremented with every
call to this method.
If any of the environment variables STX_TMPDIR, ST_TMPDIR, TMPDIR... is set,
its value defines the temp directory.

o  newTemporaryIn: aDirectoryOrNil
return a new unique filename - use this for temporary files.
The filenames returned are in aDirectoryPrefix and named 'stxtmp_xx_nn',
where xx is our unix process id, and nn is a unique number, incremented
with every call to this method.
Notice: only a unique filename object is created and returned - no physical
file is created by this method (i.e. you have to send #writeStream or
whatever to it in order to really create something).
See also: #newTemporary which looks for a good temp directory.

DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporaryIn:

usage example(s):

temp files in '/tmp':

     Filename newTemporary
     Filename newTemporaryIn:(Filename tempDirectory)

usage example(s):

temp files somewhere
     (not recommended - use above since it can be controlled via shell variables):

     UnixFilename newTemporaryIn:'/tmp'
     UnixFilename newTemporaryIn:'/tmp'
     UnixFilename newTemporaryIn:'/usr/tmp'
     UnixFilename newTemporaryIn:'/'

usage example(s):

a local temp file:

     Filename newTemporaryIn:''
     Filename newTemporaryIn:nil
     Filename newTemporaryIn:'.'
     Filename newTemporaryIn:('source' asFilename)

o  newTemporaryIn: aDirectoryOrNil nameTemplate: template
return a new unique filename - use this for temporary files.
The filenames returned are in aDirectoryOrNil and named after the given template,
in which %1 and %2 are expanded to the unix process id, and a unique number, incremented
with every call to this method respectively.
If the template does not contain %-meta characters, and the file already exists,
a sequence of _1, _2,... is appended to the name. This is dangerous, as it does not prevent race
conditions (if two such files are created at the same time).

Notice: only a unique filename object is created and returned - no physical
file is created by this method (i.e. you have to send #writeStream or
whatever to it in order to really create something).
See also: #newTemporary which looks for a good temp directory.

DO NOT USE THIS FOR PLAIN FILES - IT IS UNSECURE use FileStream>>#newTemporaryIn:nameTemplate:

usage example(s):

temp files in '/tmp':

     Filename newTemporary
     Filename newTemporaryIn:nil nameTemplate:'out_%1_%2.txt'
     Filename newTemporaryIn:(Filename tempDirectory) nameTemplate:'out_%1_%2.txt'

usage example(s):

temp files somewhere
     (not recommended - use above since it can be controlled via shell variables):

     UnixFilename newTemporaryIn:'/tmp'     nameTemplate:'foo%1_%2'
     UnixFilename newTemporaryIn:'/tmp'     nameTemplate:'foo%1_%2'
     UnixFilename newTemporaryIn:'/usr/tmp' nameTemplate:'foo%1_%2'
     UnixFilename newTemporaryIn:'/'        nameTemplate:'foo%1_%2'

usage example(s):

a local temp file:

     Filename newTemporaryIn:''             nameTemplate:'foo%1_%2'
     Filename newTemporaryIn:nil            nameTemplate:'foo%1_%2'
     Filename newTemporaryIn:'.'            nameTemplate:'foo%1_%2'
     Filename newTemporaryIn:('source' asFilename) nameTemplate:'foo%1_%2'

o  nullDevice
return the filename of the nullDevice (if available).
returns nil, if the OperatingSystem does not support this.

usage example(s):

     Filename nullDevice
     UnixFilename nullDevice
     PCFilename nullDevice

o  remoteHost: remoteHostString rootComponents: aCollectionOfDirectoryNames
create & return a new filename from components given in
aCollectionOfDirectoryNames on a host named remoteHostString.
An absolute network-filename is returned.

o  rootComponents: aCollectionOfDirectoryNames
create & return a new filename from components given in
aCollectionOfDirectoryNames.
An absolute path-filename is returned.

usage example(s):

     Filename rootComponents:#('/' 'foo' 'bar' 'baz')

     Filename rootComponents:#('foo' 'bar' 'baz')
     PCFilename rootComponents:#('foo' 'bar' 'baz')
     UnixFilename rootComponents:#('foo' 'bar' 'baz')

     Filename rootComponents:#('/')

     Filename rootComponents:
         (Filename components:('.' asFilename pathName))

     Filename rootComponents:
         (Filename components:('.' asFilename name))

o  rootDirectory
return a filename for the root directory

usage example(s):

     Filename rootDirectory

o  rootDirectoryOnVolume: aVolumeName
return a filename for the root directory on some volume

usage example(s):

     Filename rootDirectoryOnVolume:'/phys/idefix'
     Filename rootDirectoryOnVolume:'d:'

o  tempDirectory
return the temp directory as a filename.
If any of the environment variables STX_TMPDIR, ST_TMPDIR, TMPDIR,...
is set, its value defines the name,
otherwise, '/tmp' is used. (at least on unix ...).

Notice: do not hardcode '/tmp' into your programs - things may be
different on other operating systems. Also, the user may want to set the
TMPDIR environment variable to have her temp files somewhere else.

usage example(s):

     Filename tempDirectory
     Filename tempDirectory pathName
     Filename tempDirectory exists
     Filename tempDirectory isWritable
     (Filename tempDirectory construct:'foo') makeDirectory
     (Filename tempDirectory construct:'foo') remove

o  tempDirectory: aFilename
set the default temporary directory.
This allows overwriting the automatically determined tmpDirectory
by a knowledgable stand alone startup program.
Do not use elsewhere (and only if absolutely required)

o  trashDirectoryOrNil
if the underlying OS uses/supports a trash folder,
return it. Otherwise return nil.
Asks the OS for the pathname; for example, on OSX, '~/.Trash' is returned.

usage example(s):

     Filename trashDirectoryOrNil

o  usersPrivateSmalltalkDirectory
Filename usersPrivateSmalltalkDirectory

misc
o  filterSeps: aFilenameString
ST80 compatibility:
filter out (invalid) separators in aFilenameString.
We recommend using #makeLegalFilename

o  nameWithSpecialExpansions: aString
return the nameString, expanding any OS specific macros.
Here, a ~/ or ~user/ prefix is expanded to the users home dir (as in csh)

usage example(s):

     Filename nameWithSpecialExpansions:'~'
     Filename nameWithSpecialExpansions:'~\work'
     Filename nameWithSpecialExpansions:'~stefan'
     Filename nameWithSpecialExpansions:'~stefan\work'
     Filename nameWithSpecialExpansions:'~foo'
     Filename nameWithSpecialExpansions:'~foo\bar'

usage example(s):

     UnixFilename nameWithSpecialExpansions:'~'
     UnixFilename nameWithSpecialExpansions:'~/work'
     UnixFilename nameWithSpecialExpansions:'~stefan'
     UnixFilename nameWithSpecialExpansions:'~stefan/work'
     UnixFilename nameWithSpecialExpansions:'~foo'
     UnixFilename nameWithSpecialExpansions:'~foo/bar'

usage example(s):

     PCFilename nameWithSpecialExpansions:'~'
     PCFilename nameWithSpecialExpansions:'~\work'
     PCFilename nameWithSpecialExpansions:'~stefan'
     PCFilename nameWithSpecialExpansions:'~stefan\work'
     PCFilename nameWithSpecialExpansions:'~foo'
     PCFilename nameWithSpecialExpansions:'~foo\bar'

o  suggest: aFilenameString
return a fileNamestring based on the argument,
which is legal on the current platform.

queries
o  currentDirectoryName
return a filename for the current directory

usage example(s):

     Filename currentDirectoryName

o  defaultDirectoryName
ST80 compatibility: return the defaultDirectories name (as a string)

usage example(s):

     Filename defaultDirectoryName

o  directorySuffix
Return the OS dependent directory suffix string, or nil if there is none.
The default is nil here, redefined for VMS

o  errorReporter
who knows the signals to report errors?

o  filenameCompletionFor: aString directory: inDirectory directoriesOnly: directoriesOnly filesOnly: filesOnly ifMultiple: aBlock
perform filename completion on aString in some directory;
return the longest matching filename prefix as a string.
The boolean directoriesOnly and filesOnly control respectively,
if only directories or only regular files are to be considered for completion.
If multiple files match, the exception block aBlock is evaluated with a
filename representing the directory (where the match was done) as argument.
(this may be different from the inDirectory argument, if aString is absolute
or starts with ../)

usage example(s):

     self 
        filenameCompletionFor:'/tm' 
        directory:nil 
        directoriesOnly:true 
        filesOnly:false 
        ifMultiple:[]

o  filenameCompletionFor: aString directory: inDirectory directoriesOnly: directoriesOnly filesOnly: filesOnly ifMultiple: aBlock forMultipleDo: aMultipleBlock
perform filename completion on aString in some directory;
return the longest matching filename prefix as a string.
The boolean directoriesOnly and filesOnly control respectively,
if only directories or only regular files are to be considered for completion.
If multiple files match, the exception block aBlock is evaluated with a
filename representing the directory (where the match was done) as argument and the aMultipleBlock
is evaluated with both the directory (where the match was done) and the matchSet
(list of matched filenames) as arguments.
(this may be different from the inDirectory argument, if aString is absolute
or starts with ../)

o  filesMatching: aPattern
return a collection of strings, representing the names
of files matching aPattern.
If aPattern contains a directory path, files are tried there;
otherwise, files from the currentDirectory are tried.
The returned strings are the expanded names, in the same form
as given in pattern.
The pattern should be a simple pattern.

usage example(s):

     Filename filesMatching:'*'
     Filename filesMatching:'/*'
     Filename filesMatching:'/usr/local/*'

o  isAbstract
return true, if this is not a concrete class

o  isBadCharacter: aCharacter
return true, if aCharacter is unallowed in a filename.

o  isCaseSensitive
return true, if filenames are case sensitive.
We ask the OS about this, to be independent here.
This is not really correct, as the sensitivity may depend on
the paricular mounted file system (NFS, for example).
So we need a query on the instance side

o  localNameStringFrom: aString
ST-80 compatibility.
what does this do ? (used in FileNavigator-goody).
GUESS:
does it strip off any volume characters and make a path relative ?

o  maxComponentLength
return the maximum number of characters a filename component may
be in size. This depends on the OperatingSystem.

o  maxLength
return the maximum number of characters a filename may be in size.
This depends on the OperatingSystem.

o  nullFilename
Return the OS dependent filename for /dev/null, or nil if there is none.
The default is nil here

o  parentDirectoryName
return the name used for the parent directory.
This is '..' for unix and dos-like systems.
(there may be more in the future.

usage example(s):

     Filename parentDirectoryName

o  separator
return the file/directory separator.
This is to be redefined in concrete classes.

usage example(s):

     Filename separator
     PCFilename separator

o  separatorString
return the file/directory separator as a string.

usage example(s):

     Filename separatorString

o  suffixSeparator
return the filename suffix separator.
Usually, this is $. for unix-like and msdos systems
(there is currently no known system, where this differs)

usage example(s):

      Filename suffixSeparator

o  tempFileNameTemplate
return a template for temporary files.
This is expanded with the current processID and a sequenceNumber
to generate a unique filename.

o  volumes
ST-80 compatibility.
GUESS: does it return the available drives on MSDOS systems ?
Q: what does this do on Unix systems ? (used in FileNavigator-goody).

usage example(s):

     Filename volumes

utilities
o  canonicalize: aPathString
convert the argument, aPathString to a good format.
This should eliminate useless directory components (i.e. '././')
and useless tree walks (i.e. '../foo/..').

usage example(s):

     Filename canonicalize:'/etc/../etc'
     Filename canonicalize:'/home/cg/../'
     Filename canonicalize:'/home/cg/../././'
     Filename canonicalize:'./home/cg/../././'
     Filename canonicalize:'/home/././cg/../././'
     Filename canonicalize:'/home/././cg/././'
     Filename canonicalize:'/home/cg/../../..'
     Filename canonicalize:'cg/../../..'
     Filename canonicalize:'./'
     Filename canonicalize:'/home/.'
     Filename canonicalize:'/home/../..'
     Filename canonicalize:'//foo'
     Filename canonicalize:'///foo'
     Filename canonicalize:'//foo//bar'

o  canonicalizedNameComponents: aPathString
convert the argument, aPathString to a good format.
This should eliminate useless directory components (i.e. '././')
and useless tree walks (i.e. '../foo/..').

Answer a sequenceable collection of name components.

usage example(s):

     Filename canonicalizedNameComponents:'/etc/../etc'
     Filename canonicalizedNameComponents:'/home/cg/../'
     Filename canonicalizedNameComponents:'/home/cg/../././'
     Filename canonicalizedNameComponents:'./home/cg/../././'
     Filename canonicalizedNameComponents:'/home/././cg/../././'
     Filename canonicalizedNameComponents:'/home/././cg/././'
     Filename canonicalizedNameComponents:'/home/cg/../../..'
     Filename canonicalizedNameComponents:'cg/../../..'
     Filename canonicalizedNameComponents:'/'
     Filename canonicalizedNameComponents:'./'
     Filename canonicalizedNameComponents:'/.'
     Filename canonicalizedNameComponents:'/home/.'
     Filename canonicalizedNameComponents:'/home'
     Filename canonicalizedNameComponents:'/home/../..'
     Filename canonicalizedNameComponents:'//foo'
     Filename canonicalizedNameComponents:'///foo'
     Filename canonicalizedNameComponents:'//foo//bar'

o  components: aString
separate the pathName given by aString into
a collection containing the directory components and the file's name as
the final component.
If the argument names an absolute path, the first component will be the
name of the root directory (i.e. '/').

o  filesMatchingGLOB: pattern
does a GLOB filename expansion.
Generates and returns a possibly empty list of files which match
the given glob pattern

usage example(s):

     Filename filesMatchingGLOB:'./A*'
     Filename filesMatchingGLOB:'/etc/A*'
     Filename filesMatchingGLOB:'/*/A*'
     '.' asFilename filesMatchingGLOB:'A*'

o  nameFromComponents: aCollectionOfDirectoryNames
return a filenameString from components given in aCollectionOfDirectoryNames.
If the first component is the name of the root directory (i.e. '/'),
an absolute path-string is returned.

usage example(s):

     Filename nameFromComponents:#('/' 'foo' 'bar' 'baz')
     Filename nameFromComponents:#('foo' 'bar' 'baz')
     Filename nameFromComponents:#('/')

     |comps|
     comps := Filename components:'/foo/bar/baz'.
     Filename nameFromComponents:comps

     |comps|
     comps := Filename components:'\foo\bar\baz'.
     Filename nameFromComponents:comps

     |comps|
     comps := Filename components:'c:\foo\bar\baz'.
     Filename nameFromComponents:comps

     |comps|
     comps := Filename components:'foo\bar\baz'.
     Filename nameFromComponents:comps

     |comps|
     comps := Filename components:'foo'.
     Filename nameFromComponents:comps

     |comps|
     comps := Filename components:'\'.
     Filename nameFromComponents:comps

     |comps|
     comps := Filename components:'c:\'.
     Filename nameFromComponents:comps

o  possiblyQuotedPathname: aPath
return a filename path usable as command line argument,
by quoting in double quotes if there are any embedded special characters.
On Unix systems, special characters might also be prefixed by a backslash character.

usage example(s):

     Filename possiblyQuotedPathname:'/tmp/bla'
     Filename possiblyQuotedPathname:'/tmp directory/bla'
     Filename possiblyQuotedPathname:'/tmp directory/bla file'

o  readingFile: aPathName do: aBlock
Create a read stream on a file, evaluate aBlock, passing that stream,
and return the block's value.
Ensures that the stream is closed.


Instance protocol:

Compatibility-VW5.4
o  asLogicalFileSpecification

o  canBeWritten
same as isWritable - for ST-80 compatibility

usage example(s):

     '/foo/bar' asFilename canBeWritten
     '/tmp' asFilename canBeWritten
     'Makefile' asFilename canBeWritten

o  definitelyExists
for now - a kludge

o  delete
remove the file - same as remove, for ST-80 compatibility

o  extension
return the receiver's extension;
that is the characters from and including
the last period or nil, if there is none.

usage example(s):

     'foo.html' asFilename extension
     'foo.bar' asFilename extension
     'foo.bar.baz' asFilename extension
     'foo.' asFilename extension
     'foo' asFilename extension
     '.login' asFilename extension

attribute setter
o  clearHidden
ignored here
- redefined for windows to clear the file's hidden flag

o  setHidden
ignored here
- redefined for windows to set the file's hidden flag

comparing
o  < aFilename
compare file names - used for sorting

o  = aFilename
return true, if the argument represents the same filename

o  contentsIsPrefixOf: aFilename
return true if the contents of the file represented by the receiver
is the same as or a prefix of the contents of the file represented by the argument, aFilename.
This compares the files' actual contents; not the filenames.

o  contentsStartsWithContentsOf: aFilename
return true if the contents of the file represented by aFilename
is the same as or a prefix of the contents of the file represented by the receiver.
This compares the files' actual contents; not the filenames.

o  hash
return an integer useful as a hash-key

o  sameContentsAs: aFilename
return true if the file represented by the receiver has the
same contents as the file represented by the argument, aFilename.
This compares the file's actual contents; not the filenames.

usage example(s):

     'Make.proto' asFilename sameContentsAs:'Makefile'
     'Make.proto' asFilename sameContentsAs:'Make.proto'

converting
o  asAbsoluteFilename
return the receiver converted to a filename with
an absolute pathname.

If the receiver does not exist, no absolute filename is generated.

This makes sense, if you want to send #asString or #printString
or #hash or #= to it.

usage example(s):

     '.' asFilename
     '.' asFilename pathName
     '.' asFilename asAbsoluteFilename
     'c:' asFilename asAbsoluteFilename
     'foo' asFilename
     'foo' asFilename asAbsoluteFilename

o  asAutoDeletedFilename
will automatically delete myself, when no longer referenced

o  asBackupFilename
return the receiver converted to a backup filename.

usage example(s):

     'bla' asFilename asBackupFilename
     '/home/user/directory/bla' asFilename asBackupFilename
     'directory/bla' asFilename asBackupFilename

o  asCanonicalizedFilename
return the receiver converted to a filename without intermediate ..'s and .'s
(similar to an absolute pathname, but symlinks are not resolved).

usage example(s):

      'c:\test\work' asFilename asCanonicalizedFilename
      '/test/work' asFilename asCanonicalizedFilename

o  asFileURL
return a file URL-object from myself

o  asFilename
return the receiver converted to a filename; here, that's the receiver itself.

o  asNonBackupFilename
return the receiver converted to a backup filename.

usage example(s):

     'bla.bak' asFilename asNonBackupFilename
     '/home/user/directory/bla.bak' asFilename asNonBackupFilename
     'directory/bla.bak' asFilename asNonBackupFilename
     'directory/bla~' asFilename asNonBackupFilename

o  asString
return the receiver converted to a string

o  asURI
return the receiver converted to a file URI

o  asURL
return an URL-object from myself

o  asUniqueFilename
If a file by my name already exists, return a new filename with a unique string appended.
Here, a somewhat naive strategy is performed, by trying _1, _2,...
until a new name is generated.

usage example(s):

     'aaa.txt' asFilename contents:'bla'.
     'aaa.1.2.3.apk.txt' asFilename asUniqueFilename contents:'bla2'.
     'aaa.txt' asFilename asUniqueFilename contents:'bla3'.
     'aaa.txt' asFilename asUniqueFilename contents:'bla4'.
     #('aaa.txt' 'aaa_1.txt' 'aaa_2.txt' 'aaa_3.txt') do:[:f | f asFilename delete].  

o  components
return the receiver's filename components - that is the name of each directory
along the pathName (that DOES include the root directory)

usage example(s):

     '.' asFilename asAbsoluteFilename components
     'Makefile' asFilename asAbsoluteFilename components

o  makeLegalBasename
convert the receiver's name to be a legal basename.
This removes/replaces invalid characters and/or compresses
the name as required by the OS.
It also replaces the directory separator (i.e. '/') by an inderscore.
The implementation may change in the future to be more
OS specific.

usage example(s):

     'hello world' asFilename makeLegalBasename
      ('abc' copyWith:Character return) asFilename makeLegalBasename
      ('a/b/c' copyWith:Character return) asFilename makeLegalBasename

o  makeLegalFilename
convert the receiver's name to be a legal filename.
This removes/replaces invalid characters and/or compresses
the name as required by the OS.
The implementation may change in the future to be more
OS specific.

usage example(s):

     'hello world' asFilename makeLegalFilename
      ('abc' copyWith:Character return) asFilename makeLegalFilename

o  withEncoding: encodingSymbol
dummy for now - for ST80 compatibility

enumerating-contents
o  allDirectoriesDo: aBlock
evaluate aBlock for all (recursive) directories contained in the directory represented by the receiver.
The block is invoked with a filename-arguments.
The enumerations order within a directory is undefined - i.e. usually NOT sorted by
filenames (but by creation time - on some systems).
This excludes entries for '.' or '..'.
NoOp for non-existing directories; however, this behavior
may be changed in the near future, to raise an exception instead.
So users of this method better test for existing directory before.

usage example(s):

     '.' asFilename allDirectoriesDo:[:fn | Transcript showCR:fn name].
     '.' asFilename directoriesDo:[:fn | Transcript showCR:fn name].

o  allParentDirectoriesDo: aBlock
evaluate aBlock for all (recursive) directories along the parent directory path.
The block is invoked with a filename-arguments.

usage example(s):

     '.' asFilename allParentDirectoriesDo:[:fn | Transcript showCR:fn pathName].

o  directoriesDo: aBlock
evaluate aBlock for directories contained in the directory represented by the receiver.
The block is invoked with a filename-argument.
The enumerations order is undefined - i.e. usually NOT sorted by
filenames (but by creation time - on some systems).
This excludes entries for '.' or '..'.
OpenError is raised if I represent a non-existent or non-readable directories.
So users of this method better test for existing directory before.

usage example(s):

     '.' asFilename directoriesDo:[:fn | Transcript showCR:fn baseName].

o  directoryContentsAsFilenamesDo: aBlock
evaluate aBlock for each file in the directory represented by the receiver.
The block is invoked with a filename-argument.
The enumerations order is undefined - i.e. usually NOT sorted by
filenames (but by creation time - on some systems).
This excludes entries for '.' or '..'.
An OpenError exception is raised it the directory does not exist or is not readable.
So users of this method better test for existing directory before.
Notice: this enumerates fileName objects; see also
#directoryContentsDo:, which enumerates strings.

usage example(s):

     '.' asFilename directoryContentsAsFilenamesDo:[:fn | Transcript showCR:fn pathName].

o  directoryContentsDo: aBlock
evaluate aBlock for each file in the directory represented by the receiver.
The block is invoked with a string as argument.
The enumerations order is undefined - i.e. usually NOT sorted by
filenames (but by creation time - on some systems).
This excludes entries for '.' or '..'.
An OpenError exception is raised it the directory does not exist or is not readable.
So users of this method better test for existing directory before.
Notice: this enumerates strings; see also
#directoryContentsAsFilenamesDo:, which enumerates fileName objects.

usage example(s):

     '.' asFilename directoryContentsDo:[:fn | Transcript showCR:fn].
     'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn].
     [
        'doeSnotExIST' asFilename directoryContentsDo:[:fn | Transcript showCR:fn].
     ] on:OpenError do:[:ex| ex proceed]

o  filesDo: aBlock
evaluate aBlock for all regular files (i.e. subdirs are ignored)
contained in the directory represented by the receiver.

usage example(s):

     '.' asFilename filesDo:[:f | Transcript showCR:f].

o  filesMatchingGLOB: pattern do: aBlock
Interpreting pattern as a GLOB pattern,
evaluate aBlock for each file in me, which matches.
Returns the number of matches.

usage example(s):

     '..' asFilename filesMatchingGLOB:'A*' do:[:fn | Transcript showCR:fn].
     '../..' asFilename filesMatchingGLOB:'lib*/*.st' do:[:fn | Transcript showCR:fn].
     '/Library/Java/JavaVirtualMachines' asFilename filesMatchingGLOB:'*.jdk' do:[:fn | Transcript showCR:fn].    

o  filesMatchingGLOBComponents: patternComponents do: aBlock
patternComponents is a component-collection with possible GLOB patterns.
Evaluate aBlock for each file in me, which matches.
Returns the number of matches

o  filesMatchingGLOBDo: aBlock
Interpreting myself as a GLOB pattern,
evaluate aBlock for each file which matches.

usage example(s):

     '/etc/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '/etc/a*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../../lib*/*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../../lib*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../../*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../../*/*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../../*java*/*/[A-D]*.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../../*java*/*/Ary.st' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '/*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '../*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     './*/A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     './*/*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].
     '././A*' asFilename filesMatchingGLOBDo:[:fn | Transcript showCR:fn].

o  filesWithSuffix: suffix do: aBlock
evaluate aBlock for all regular files with a given suffix
contained in the directory represented by the receiver.
(i.e. subdirs are ignored)

usage example(s):

     '.' asFilename filesWithSuffix:'so' do:[:f | Transcript showCR:f].

o  recursiveDirectoryContentsAsFilenamesDo: aBlock
evaluate aBlock for all files and directories found under the receiver.
The block is invoked with the filenames as argument.
The walk is bread-first.
This excludes any entries for '.' or '..'.
Subdirectory files are included with a relative pathname.
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename recursiveDirectoryContentsAsFilenamesDo:[:f | Transcript showCR:f]

o  recursiveDirectoryContentsAsFilenamesDo: aBlock filterForVisitingDirectories: filterOrNil
evaluate aBlock for all files and directories found under the receiver.
The block is invoked with the filenames as argument.
The walk is bread-first.
This excludes any entries for '.' or '..'.
Subdirectory files are included with a relative pathname.
If filterOrNil is nonNil, it is passed every directory about to be walked into;
if it returns false, that directory is not entered.
Warning: this may take a long time to execute
(especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename recursiveDirectoryContentsAsFilenamesDo:[:f | Transcript showCR:f]

o  recursiveDirectoryContentsDo: aBlock
evaluate aBlock for all files and directories found under the receiver.
The block is invoked with the relative filenames as string-argument.
The walk is bread-first.
This excludes any entries for '.' or '..'.
Subdirectory files are included with a relative pathname.
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f]

o  recursiveDirectoryContentsDo: aBlock directoryPrefix: aPrefix
evaluate aBlock for all files and directories found under the receiver.
The block is invoked with a string-argument.
The walk is breadth-first.
This excludes any entries for '.' or '..'.
The argument to aBlock is a pathname relative to aPrefix.
A proceedable exception is raised forn non-accessible directories.
Warning: this may take a long time to execute (especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f]
     '/etc' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f]

o  recursiveDirectoryContentsDo: aBlock filterForVisitingDirectories: filterOrNil
evaluate aBlock for all files and directories found under the receiver.
The block is invoked with the relative filenames as string-argument.
The walk is bread-first.
This excludes any entries for '.' or '..'.
Subdirectory files are included with a relative pathname.
If filterOrNil is nonNil, it is passed every directory about to be walked into;
if it returns false, that directory is not entered.
Warning: this may take a long time to execute
(especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename recursiveDirectoryContentsDo:[:f | Transcript showCR:f]

o  recursiveDirectoryContentsWithPrefix: aPrefix filesDo: fileBlock directoriesDo: dirBlock
evaluate aBlock for all files and directories found under the receiver.
The blocks are invoked with a relative pathname as string-argument.
The walk is breadth-first (first files, then directories).
This excludes any entries for '.' or '..'.
A proceedable exception is raised for non-accessible directories.
Warning: this may take a long time to execute
(especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename 
        recursiveDirectoryContentsWithPrefix:'bla'
        filesDo:[:f | Transcript show:'file: '; showCR:f]
        directoriesDo:[:f | Transcript show:'dir: '; showCR:f]

o  recursiveDirectoryContentsWithPrefix: aPrefix filesDo: fileBlock directoriesDo: dirBlock filterForVisitingDirectories: filterOrNil
evaluate aBlock for all files and directories found under the receiver.
The blocks are invoked with a relative pathname as string-argument.
The walk is breadth-first (first files, then directories).
This excludes any entries for '.' or '..'.
A proceedable exception is raised for non-accessible directories.
If filterOrNil is nonNil, it is passed every directory about to be walked into;
if it returns false, that directory is not entered.
Warning: this may take a long time to execute
(especially with deep and/or remote fileSystems).

usage example(s):

     '.' asFilename 
        recursiveDirectoryContentsWithPrefix:'bla'
        filesDo:[:f | Transcript show:'file: '; showCR:f]
        directoriesDo:[:f | Transcript show:'dir: '; showCR:f]

o  recursiveFilesDo: fileBlock directoriesDo: dirBlock filterForVisitingDirectories: filterOrNil
evaluate aBlock for all files and directories found under the receiver.
The blocks are invoked with a relative pathname as string-argument.
The walk is depth-first (but files first, then directories).
This excludes any entries for '.' or '..'.
A proceedable exception is raised for non-accessible directories.
If filterOrNil is nonNil, it is passed every directory about to be walked into;
if it returns false, that directory is not entered.
Warning: this may take a long time to execute
(especially with deep and/or remote fileSystems).
Names are enumerated in the order they appear in the folder,
(which is not required to be sorted).

usage example(s):

     '.' asFilename 
        recursiveFilesDo:[:f | Transcript show:'file: '; showCR:f]
        directoriesDo:[:f | Transcript show:'dir: '; showCR:f]
        filterForVisitingDirectories:nil

o  recursiveFilesDo: fileBlock directoriesDo: dirBlock filterForVisitingDirectories: filterOrNil sortedBy: sortedByBlock
evaluate aBlock for all files and directories found under the receiver.
The blocks are invoked with a relative pathname as string-argument.
The walk is breadth-first (files first, then directories).
This excludes any entries for '.' or '..'.
A proceedable exception is raised for non-accessible directories.
If filterOrNil is nonNil, it is passed every directory about to be walked into;
if it returns false, that directory is not entered.
Warning: this may take a long time to execute
(especially with deep and/or remote fileSystems).
By default, names are enumerated in the order they appear in the folder,
(which is not required to be sorted).
If sortedByBlock is non nil, it is applied with the file names to sort them
(usually a block is provided to sort by name, aka [:a :b | a name < b name]
or by caseless name, like [:a :b | a name caselessBefore: b name]

usage example(s):

     '.' asFilename 
        recursiveFilesDo:[:f | Transcript show:'file: '; showCR:f]
        directoriesDo:[:f | Transcript show:'dir: '; showCR:f]
        filterForVisitingDirectories:nil
        sortedBy:[:a :b | a name caselessBefore: b name]

     '.' asFilename 
        recursiveFilesDo:[:f | Transcript showCR:f]
        directoriesDo:[:f | Transcript showCR:f]
        filterForVisitingDirectories:nil
        sortedBy:[:a :b | a name caselessBefore: b name]

     '../../..' asFilename 
        recursiveFilesDo:[:f | Transcript show:'file: '; showCR:f]
        directoriesDo:[:f | Transcript show:'dir: '; showCR:f]
        filterForVisitingDirectories:nil
        sortedBy:[:a :b | a name caselessBefore: b name]

     '../../..' asFilename 
        recursiveFilesDo:[:f | Transcript show:'file: '; showCR:f]
        directoriesDo:[:f | Transcript show:'dir: '; showCR:f]
        filterForVisitingDirectories:nil
        sortedBy:nil

o  withAllDirectoriesDo: aBlock
evaluate aBlock for myself and all (recursive) directories contained in the directory represented by the receiver.
The block is invoked with a filename-arguments.
The enumerations order within a directory is undefined - i.e. usually NOT sorted by
filenames (but by creation time - on some systems).
This excludes entries for '.' or '..'.
OpenError is raised if the name I represent does not exist or is not readable.
So users of this method better test for existing directory before.

usage example(s):

     '.' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name].
     'IdoNOTexist' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name].
     '/etc/hosts' asFilename withAllDirectoriesDo:[:fn | Transcript showCR:fn name].

error handling
o  fileCreationError: filename
report an error that some file could not be created

o  reportError: string with: filename
report an error

file access
o  appendStream
return a stream for appending to the file represented by the receiver.
If the file does not already exist, it is created.
Same as #appendingWriteStream for ST-80 compatibility.

o  appendingWriteStream
return a stream for appending to the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, writes are appended at the end.

o  existingReadWriteStream
return a stream for read/write the file represented by the receiver.
If the file does not already exist, an exception is raised.

usage example(s):

     '/tmp/blaFaselQuall666666' asFilename remove.
     '/tmp/blaFaselQuall666666' asFilename existingReadWriteStream.

o  newReadWriteStream
return a stream for read/write the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, it is truncated.

o  openWithMode: anArrayOrString
return a stream for read/write the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, it is truncated.

o  readStream
Return a stream for reading from the file represented by the receiver.
Raises an error if the file does not exist.

usage example(s):

      '/tmp/foo' asFilename readStream

o  readWriteStream
return a stream for read/write the file represented by the receiver.
If the file does not already exist, it is created.
If the file does exist, it is NOT truncated, but rewritten at the beginning.

o  writeStream
return a stream for writing to the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, it is truncated.

usage example(s):

     '/tmp/foo' asFilename writeStream

file access - migration
o  appendingWriteStreamOrNil
return a stream for appending to the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, writes are appended at the end.

Return nil, if the file cannot be opened.
Use this method for migration of old smalltalk code that expects a nil return code
instead of an exception when an error occurs.

o  newReadWriteStreamOrNil
return a stream for read/write the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, it is truncated.

Return nil, if the file cannot be opened.
Use this method for migration of old smalltalk code that expects a nil return code
instead of an exception when an error occurs.

o  readStreamOrNil
return a stream for reading from the file represented by the receiver.
If the file does not already exist, nil is returned.

Return nil, if the file cannot be opened.
Use this method for migration of old smalltalk code that expects a nil return code
instead of an exception when an error occurs.

usage example(s):

     '/tmp/foo' asFilename readStreamOrNil
     '/tmp/foo' asFilename readStream

o  readWriteStreamOrNil
return a stream for read/write the file represented by the receiver.
If the file does not already exist, it is created.
If the file does exist, it is NOT truncated, but rewritten at the beginning

Return nil, if the file cannot be opened.
Use this method for migration of old smalltalk code that expects a nil return code
instead of an exception when an error occurs.

o  writeStreamOrNil
return a stream for writing to the file represented by the receiver.
If the file does not already exist, it is created;
if it does exist, it is truncated.

Return nil, if the file cannot be opened.
Use this method for migration of old smalltalk code that expects a nil return code
instead of an exception when an error occurs.

usage example(s):

     '/etc/foo' asFilename writeStreamOrNil

file access rights
o  accessRights
return the access rights of the file as opaque data
(SmallInteger in unix/linux)

usage example(s):

     'Make.proto' asFilename accessRights printStringRadix:8
     'foo' asFilename accessRights printStringRadix:8

o  accessRights: opaqueData
set the access rights of the file to opaqueData,
which is normally retrieved by Filename>>#accessRights.

o  addAccessRights: aCollection
add the access rights as specified in aCollection for the file represented
by the receiver. The argument must be a collection of symbols,
such as #readUser, #writeGroup etc.

usage example(s):

     'foo' asFilename writeStream close.
     'foo' asFilename addAccessRights:#(readUser readGroup readOthers).
     'foo' asFilename addAccessRights:#(writeUser writeGroup writeOthers).
     'foo' asFilename addAccessRights:#(executeUser executeGroup executeOthers).

o  makeExecutable
make the file executable - you must have permission to do so.
For directories, execution means: 'allow changing into it'

o  makeExecutableForAll
make the file executable for all - you must have permission to do so.
For directories, execution means: 'allow changing into it'

o  makeExecutableForGroup
make the file executable for the group - you must have permission to do so.
For directories, execution means: 'allow changing into it'

o  makeReadable
make the file readable for the owner - you must have permission to do so.

o  makeReadableForAll
make the file readable for all - you must have permission to do so.

o  makeReadableForGroup
make the file readable for the group - you must have permission to do so.

o  makeUnwritable
make the file unwritable for all - you must have permission to do so.

o  makeWritable
make the file writableable for all - you must have permission to do so.

o  makeWritableForAll
make the file writable for all - you must have permission to do so.

o  makeWritableForGroup
make the file writable for the group - you must have permission to do so.

o  removeAccessRights: aCollection
remove the access rights as specified in aCollection for the file represented
by the receiver. The argument must be a collection of symbols,
such as #readUser, #writeGroup etc.
Raises an exception if not successful.

usage example(s):

     'foo' asFilename writeStream close.
     'foo' asFilename removeAccessRights:#(readUser readGroup readOthers).
     'foo' asFilename removeAccessRights:#(writeUser writeGroup writeOthers).
     'foo' asFilename removeAccessRights:#(executeUser executeGroup executeOthers).

o  symbolicAccessRights
return the access rights of the file as a aCollection of access symbols.
The returned collection consists of symbols like:
#readUser, #writeGroup etc.

usage example(s):

     'Make.proto' asFilename symbolicAccessRights

o  symbolicAccessRights: aCollectionOfSymbols
set the access rights of the file given a aCollection of access symbols.
The collection must consist of symbols like:
#readUser, #writeGroup etc.

file operations
o  appendTo: streamOrNewName
append the file - the argument must be a stream or convertable to a filename.
Raises an exception, if an error occurs.

usage example(s):

     'Make.proto' asFilename appendTo:'/tmp/Makefile.foo'.
     'Make.proto' asFilename appendTo:Transcript.
     'Make.proto' asFilename appendTo:'/tmp/Makefile.foo' asFilename
     'Make.proto' asFilename appendTo:'/dev/null'

o  copyTo: streamOrNewName
Copy the file's contents into another file or stream.
The argument must be a stream or convertable to a filename.
Raises an exception, if an error occurs.

usage example(s):

     'Make.proto' asFilename copyTo:'/tmp/Makefile.foo'
     'Make.proto' asFilename copyTo:'/tmp'
     'Make.proto' asFilename copyTo:Transcript
     'smalltalk' asFilename copyTo:'/dev/null'

o  copyToStream: outStream
Copy the file's contents into outStream.
Raises an exception, if an error occurs.

o  createAsEmptyFile
create an empty file with the receiver's name.
Raises an exception if not successful
(either already existing or creation not possible)

o  createAsHardLinkTo: linkFilenameString
create a directory with the receiver's name.
Raises an exception if not successful

usage example(s):

        '/tmp/link' asFilename createAsHardLinkTo:'bla'

o  createAsSymbolicLinkTo: linkFilenameString
create a symbolic link named linkFilenameString which points to me
Raises an exception if not successful

usage example(s):

        '/tmp/link' asFilename createAsSymbolicLinkTo:'bla'

o  makeDirectory
create a directory with the receiver's name.
Raises an exception if not successful

o  moveFileTo: newName
copy the file represented by the receiver, then delete it.
This is different to renaming in case of cross device moves.
Raise an exception if not successful.
(Notice, that a rename is tried first, in case of non-cross device move)

o  moveTo: newNameArg
copy the file represented by the receiver, then delete it.
This is different to renaming in case of cross device moves.
Raise an exception if not successful.
(Notice, that a rename is tried first, in case of non-cross device move)

o  recursiveCopyTo: destination
if I represent a regular file, copy it.
Otherwise, copy the directory and recursively
all of its subfiles/subdirectories.

Raises an exception if not successful.
Do not resolve symbolic links.
If a whole directory is to be copied and the destination directory
does not exist, it will be created.

usage example(s):

        '.' asFilename recursiveCopyTo:'/temp/xxx'.

o  recursiveCopyWithoutOSCommandTo: destination
if I represent a regular file, copy it.
Otherwise, copy the directory and all of its subfiles/subdirectories.
This one walks down the directory hierarchy, not using any OS command to do the copy.
Raises an exception if not successful.

Do not resolve symbolic links.
If a whole directory is to be copied and the destination directory
does not exist, it will be created.

usage example(s):

     '.' asFilename recursiveCopyWithoutOSCommandTo:'/tmp/xxx'.
     'smalltalk.rc' asFilename recursiveCopyWithoutOSCommandTo:'/tmp/xxx'.

o  recursiveMakeDirectory
create a directory with the receiver's name and all required intermediate
directories.
Raises an exception if not successful.

usage example(s):

        'k:\bla\quark' asFilename recursiveMakeDirectory

usage example(s):

        'C:\windows\bla\xx' asFilename recursiveMakeDirectory
        'C:\windows\bla' asFilename recursiveRemoveAll

o  recursiveMakeDirectoryForEachCreatedDo: aOneArgBlock
create a directory with the receiver's name and all required intermediate directories.
For each created directory evaluate aOneArgBlock with the
filename of the created directory.

Raises an exception if not successful.

usage example(s):

        '/tmp/bla/fasel/murks' asFilename recursiveMakeDirectoryForEachCreatedDo:[:name| Transcript show:'Created: '; showCR:name].
        '/tmp/bla' asFilename recursiveRemove.

        'k:\bla\quark' asFilename recursiveMakeDirectory

o  recursiveMoveDirectoryTo: newName
recursively copy the directory represented by the receiver, then delete it.
This is different to renaming in case of cross device moves.
Raise an exception if not successful.
(Notice, that a rename is tried first, in case of non-cross device move)

o  recursiveRemove
if I represent a regular file, remove it.
Otherwise, remove the directory and all of its subfiles/subdirectories.
Raise an exception if not successful.

usage example(s):

     'foo/bar' asFilename recursiveMakeDirectory.
     'foo' asFilename remove.
     self assert:('foo' asFilename exists not).


     'foo' asFilename recursiveRemove.
     'foo/bar' asFilename recursiveMakeDirectory.
     'foo' asFilename recursiveRemove.
     self assert:('foo' asFilename exists not).

o  recursiveRemoveAll
Remove all of my subfiles/subdirectories.
Raise an error if not successful.
This one walks down the directory hierarchy, not using any OS
command to do the remove.

o  recursiveRemoveWithoutOSCommand
if I represent a regular file, remove it.
Otherwise, remove the directory and all of its subfiles/subdirectories.
Raise an error if not successful.
This one walks down the directory hierarchy, not using any OS
command to do the remove.

o  remove
remove the file/directory.
Raises an exception if not successful (but not if it did not exist in the first place).
Use #recursiveRemove in order to (recursively) remove non empty directories.

usage example(s):

     (FileStream newFileNamed:'foo') close.
     'foo' asFilename remove

usage example(s):

     'foo' asFilename makeDirectory.
     'foo/bar' asFilename writeStream close.
     'foo' asFilename remove.   'expect an exception'
     'foo' asFilename recursiveRemove.

o  removeDirectory
remove the directory.
Raises an exception if not successful (or if it's not a directory).
Use #remove if it is not known if the receiver is a directory or file.
Use #recursiveRemove in order to (recursively) remove non empty directories.

usage example(s):

     (FileStream newFileNamed:'foo') close.
     'foo' asFilename removeDirectory

usage example(s):

     'foo' asFilename writeStream close.
     'foo' asFilename removeDirectory

o  removeFile
remove the file.
Raises an exception if not successful (or if it's not a file).
Use #remove if it is not known if the receiver is a directory or file.
Use #recursiveRemove in order to (recursively) remove non empty directories.

usage example(s):

     (FileStream newFileNamed:'foo') close.
     'foo' asFilename removeFile

usage example(s):

     'foo' asFilename makeDirectory.
     'foo' asFilename removeFile

o  renameTo: newName
rename the file - the argument must be convertable to a filename.
Raises an exception if not successful.
If newName already exists, it will be replaced by myself.

usage example(s):

     '/tmp/foo' asFilename renameTo:'/tmp/bar'
     '/tmp/' asFilename renameTo:'/etc/bar'
     'C:\windows' asFilename renameTo:'C:\win'

o  safeCopyTo: newNameArg
Copy the file's contents into another file.
Do it safe in an atomic operation which makes sure that no partially written file appears.
The argument must be convertable to a filename.
Raises an exception, if an error occurs.

usage example(s):

     'Make.proto' asFilename safeCopyTo:'/tmp/Makefile.foo'
     'Make.proto' asFilename safeCopyTo:'/'
     'smalltalk' asFilename safeCopyTo:'/xxxxxxxxxxxxxxxx/bla'

o  truncateTo: newSize
change the file's size.
This may not be supported on all operating systems
(raises an exception, if not)

file queries
o  accessTime
return a timeStamp containing the file's last access time.

usage example(s):

     Filename currentDirectory accessTime

o  creationTime
return a timeStamp containing the file's creation time.
NOTICE: only windoof distinguishes creation from modification;
under unix, nil is returned (callers should fall back and use mod-time then

usage example(s):

     Filename currentDirectory creationTime

o  dates
return the file's modification and access times as an object (currently a dictionary)
that responds to the at: message with arguments
#modified, #accessed or #statusChanged.

usage example(s):

maybe this is a symbolic link with a broken link target.
         Answer the dates of the link itself

usage example(s):

     Filename currentDirectory dates
     '../regression' asFilename dates

o  fileSize
return the size of the file in bytes.
Returns 0 if it does not exist.

o  fileType
this returns a string describing the type of contents of
the file. This is done using the unix 'file' command,
(which usually is configurable by /etc/magic).
On non-unix systems, this may simply return 'file',
not knowning about the contents.
Warning:
Since the returned string differs among systems (and language settings),
it is only useful for user-information;
NOT as a tag to be used by a program.

usage example(s):

     'Makefile' asFilename fileType
     '.' asFilename fileType
     '/dev/null' asFilename fileType
     '/usr/tmp' asFilename fileType
     '/tmp/.X11-unix/X0' asFilename fileType
     'smalltalk.rc' asFilename fileType
     'bitmaps/SBrowser.xbm' asFilename fileType

o  id
return the file's/directory's file-id (inode number)

usage example(s):

     Filename currentDirectory id

o  info
return some object filled with the file's info;
the info (for which corresponding access methods are understood by
the returned object) is:

type - a symbol giving the files fileType
mode - numeric access mode
uid - owners user id
gid - owners group id
fileSize - files size
id - files number (i.e. inode number)
accessed - last access time (as osTime-stamp)
modified - last modification time (as osTime-stamp)
statusChangeTime - last status change (as osTime-stamp)

Some of the fields may be returned as nil on systems which do not provide
all of the information.
The minimum returned info (i.e. on all OS's) will consist of at least:
modified
size
type

Don't expect things like uid/gid/mode to be non-nil; write your application
to either handle nil values,
or (better) use one of isXXXX query methods. (Be prepared for DOS ...)
(i.e. instead of:
someFilename type == #directory
use
someFilename isDirectory

usage example(s):

     Filename currentDirectory info
     '/dev/null' asFilename info
     'Make.proto' asFilename info
     'source/Point.st' asFilename info
     'source/Point.st' asFilename linkInfo
     '../../libbasic/Point.st' asFilename info
     '.' asFilename info
     '..' asFilename info
     '..\..' asFilename info
     '..\..\..' asFilename info
     '..\..\..\..' asFilename info
     'c:\' asFilename info

o  linkInfo
return the file's info. If it is a symbolic link return the info of the link itself
instead of the link's target.
The information is the same as returned by #info, except that if the
receiver represents a symbolic link, the links information
is returned
(while in this case, #info returns the info of the target file,
which is accessed via the symbolic link).

In addition to the normal entries, Unix returns an additional entry:
path -> the target files pathname

See the comment in #info for more details.

usage example(s):

     Filename currentDirectory linkInfo
     '/dev/null' asFilename linkInfo
     'Make.proto' asFilename linkInfo
     'Make.proto' asFilename linkInfo path
     'source/Point.st' asFilename linkInfo
     '../../libbasic/Point.st' asFilename linkInfo
     '/usr/tmp' asFilename linkInfo

o  modificationTime
return a timeStamp containing the file's modification time.

usage example(s):

     Filename currentDirectory modificationTime

o  type
return the symbolic type of the file.
For symbolic links it is the type of the linked-to file.

usage example(s):

     Filename currentDirectory type

file utilities
o  edit
start an editView on the file represented by the receiver

usage example(s):

     'smalltalk.rc' asFilename edit

o  fileIn
load source code from the file

inspecting
o  inspector2TabContentsView
( an extension from the stx:libtool package )
provide an additional tab, which presents the file's contents.
'.' asFilename inspect
'smalltalk.rc' asFilename inspect

instance creation
o  / subname
Same as construct: Taking the receiver as a directory name, construct a new
filename for an entry within this directory
(i.e. for a file or a subdirectory in that directory).
The argument may not specify an absolute path name.
Please do not use this to create filenames with suffixes,
since some systems require special naming conventions.
See also: #withSuffix: (which is different, but often needed).
Thanks to Jan Vrany for this idea.

usage example(s):

     '/tmp' asFilename / 'foo'
     '/' asFilename / 'foo' / 'bar' / 'baz'
     '/foo/bar' asFilename / ('baz' asFilename)

     Bad example; works on UNIX, but may not on others:
       'foo/bar.baz' / '.suff'

o  construct: subname
taking the receiver as a directory name, construct a new
filename for an entry within this directory
(i.e. for a file or a subdirectory in that directory).
The argument may not specify an absolute path name.
Please do not use this to create filenames with suffixes,
since some systems require special naming conventions.
See also: #withSuffix: (which is different, but often needed).

usage example(s):

     '/tmp' asFilename construct:'foo'
     '/' asFilename construct:'foo'
     '/usr/tmp' asFilename construct:'foo'
     '/foo/bar' asFilename construct:'baz'
     '/foo/bar' asFilename construct:'baz' asFilename

     Bad example; works on UNIX, but may not on others:
       'foo/bar.baz' asFilename construct:'.suff'

o  constructDirectory: subname
same as #construct: on most systems.
(may allow different/relaxed name syntax of the argument on some systems)

o  constructDirectoryString: subName
same as #constructString: on most systems.
(may allow different/relaxed name syntax of the argument on some systems)

o  constructString: subName
taking the receiver as a directory name, construct a new
filename-string for an entry within this directory
(i.e. for a file or a subdirectory in that directory).
The argument may not specify an absolute path name.
The code below works for UNIX & MSDOS;
other filename classes (i.e. VMS) may want to redefine this method.

usage example(s):

     '/tmp' asFilename constructString:'foo'
     '/' asFilename constructString:'foo'
     '/usr/tmp' asFilename constructString:'foo'
     '/foo/bar' asFilename constructString:'baz'
     '' asFilename constructString:'baz'

o  filenameFor: fileName
return a filename representing the argument, fileName
either in myself (if the arg is a releative path) or absolute otherwise.

usage example(s):

     '/tmp' asFilename filenameFor:'foo'
     '/tmp' asFilename filenameFor:'/foo'

o  secureConstruct: subname
taking the receiver as a directory name, construct a new
filename for an entry within this directory
(i.e. for a file or a subdirectory in that directory).
The argument may not specify an absolute path name.
Please do not use this to create filenames with suffixes,
since some systems require special naming conventions.
See also: #withSuffix: (which is different, but often needed).

This method differs from #construct:, by not permitting subName
to navigate above the current filename (via '..') and is used eg.
by the documentation viewer and other services to prevent remote
access outside some predefined root folder.

usage example(s):

     '/tmp' asFilename secureConstruct:'foo'
     '/tmp' asFilename secureConstruct:'../foo'
     '/tmp' asFilename secureConstruct:'/./foo'
     '/tmp' asFilename secureConstruct:'foo/../bar'
     '/' asFilename secureConstruct:'foo'
     '/usr/tmp' asFilename secureConstruct:'foo'
     '/foo/bar' asFilename secureConstruct:'baz'
     '/foo/bar' asFilename secureConstruct:'baz' asFilename

     Bad example; works on UNIX, but may not on others:
       'foo/bar.baz' secureConstruct:'.suff'

o  secureConstructString: subName
taking the receiver as a directory name, construct a new
filename-string for an entry within this directory
(i.e. for a file or a subdirectory in that directory).

This method differs from #constructString:, by not permitting subName
to navigate above the current filename (via '..') and is used eg.
by the documentation viewer and other services to prevent remote
access outside some predefined root folder.

The code below works for UNIX & MSDOS;
other filename classes (i.e. VMS) have to redefine this method.

usage example(s):

     '/tmp' asFilename secureConstructString:'fooŠ'
     '/tmp' asFilename secureConstructString:'../foo'
     '/tmp' asFilename secureConstructString:'foo/../bla'
     '/tmp' asFilename secureConstructString:'foo/./bla'
     '/tmp' asFilename secureConstructString:'/bla/foo/../../foo'
     '/' asFilename secureConstructString:'foo'
     '/usr/tmp' asFilename secureConstructString:'foo'
     '/foo/bar' asFilename secureConstructString:'baz'
     '' asFilename secureConstructString:'baz'
     '' asFilename secureConstructString:'/baz'

misc
o  , aString
this allows filenames to understand how names are concatenated.
Returns a string consisting of the receiver's name, concatenated
by aString. Notice this is NOT the same as construct:, which inserts
a directory delimiter and returns a new fileName instance.
See also: #withSuffix: which is new and better.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  canonicalize
normalize a filename by removing all empty path components or dots,
and by resolving parent directory '..' references.

The code below works for UNIX & MSDOS;
other filename classes (i.e. VMS) may want to redefine this method.

usage example(s):

        '/tmp/bla' asFilename canonicalize.
        '/tmp/bla/../fasel' asFilename canonicalize.
        '/tmp/bla/.././/fasel' asFilename canonicalize.
        '..' asFilename canonicalize.
        'bla/../fasel' asFilename canonicalize.
        '//bla/../fasel' asFilename canonicalize.

os shell
o  openExplorer
open a file-explorer on the directory represented by the receiver.
On osx systems, a finder is opened.
On other systems, a filebrowser is opened

usage example(s):

     Filename currentDirectory openExplorer

o  openFinder
open a finder on the directory represented by the receiver.
On non-osx systems, an error is raised

o  openTerminal
open a terminal window on the directory represented by the receiver;
on osx, a terminal app is opened,
on windows a cmd.exe window,
on unix, an xterm is opened.

printing & storing
o  displayOn: aStream
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.

o  printOn: aStream
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.
Here, I print myself as a string, so I can be easily embedded in bind-with strings.

o  storeOn: aStream
append a printed representation of the receiver to aStream,
which allows reconstructing it via readFrom:

private-accessing
o  getName
get the raw filename

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  nameString
raw access to nameString - req'd for xml-store/reload

o  nameString: aString
raw access to nameString - req'd for xml-store/reload

o  setName: aString
set the filename

queries
o  directories
return a collection of directories contained in the directory represented by the receiver.

usage example(s):

     '.' asFilename directories.

o  exists
return true, if such a file exists.

usage example(s):

     '/foo/bar' asFilename exists
     '/tmp' asFilename exists
     'Makefile' asFilename exists

o  filenamesMatching: aPattern
VW compatibility

usage example(s):

     '/etc' asFilename filenamesMatching:'a*;c*'

o  files
return a collection of regular files
contained in the directory represented by the receiver.

usage example(s):

     '.' asFilename files.

o  filesMatching: aPattern
given the receiver, representing a directory;
return a collection of files matching a pattern.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

usage example(s):

     '/etc' asFilename filesMatching:'a*;c*'

o  filesMatching: aPattern caseSensitive: caseSensitive
given the receiver, representing a directory;
return a collection of files matching a pattern.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

usage example(s):

     '/etc' asFilename filesMatching:'a*;c*' caseSensitive:false

o  filesMatching: aPattern caseSensitive: caseSensitive do: aBlock
given the receiver, representing a directory;
evaluate aBlock for files which match a pattern.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

usage example(s):

     '/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f]

o  filesMatching: aPattern do: aBlock
given the receiver, representing a directory;
evaluate aBlock for files which match a pattern.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

usage example(s):

     '/etc' asFilename filesMatching:'a*;c*' do:[:f | Transcript showCR:f]
     '/etc' asFilename filesMatching:'a*;c*'

o  filesMatchingGLOB
Interpreting myself as a GLOB pattern,
Return filenames matching me

usage example(s):

     '../../*/A*' asFilename filesMatchingGLOB.

o  filesMatchingWithoutDotDirs: aPattern
given the receiver, representing a directory;
return a collection of files matching a pattern.
Exclude '.' and '..' from the returned list.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

usage example(s):

     Filename currentDirectory filesMatching:'.*'
     Filename currentDirectory filesMatchingWithoutDotDirs:'*.*'
     '/etc' asFilename filesMatchingWithoutDotDirs:'*'

o  filesMatchingWithoutDotDirs: aPattern caseSensitive: caseSensitive do: aBlock
given the receiver, representing a directory;
evaluate aBlock for files matching a pattern.
Exclude '.' and '..'.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

o  filesMatchingWithoutDotDirs: aPattern do: aBlock
given the receiver, representing a directory;
evaluate aBlock for files matching a pattern.
Exclude '.' and '..'.
The pattern may be a simple matchPattern, or a set of
multiple patterns separated by semicolons.

o  filesWithSuffix: suffix
return a collection of regular files (i.e. not subdirectories)
with a given suffix which are contained in the directory
represented by the receiver.

usage example(s):

     '.' asFilename filesWithSuffix:'so'.
     'packages' asFilename filesWithSuffix:'so'.

o  fullAlternativePathName
some filesystems (aka: windows) have alternative (short) filenames.
Those systems redefine this method to return it.
Otherwise, the same as the regular name is returned here

o  isExecutable
return true, if such a file exists and is executable (by Unix's definition).
For directories, true is returned if the directory can be entered.
See isExecutableProgram for a related check.

usage example(s):

     '/foo/bar' asFilename isExecutable
     '/tmp' asFilename isExecutable
     'Makefile' asFilename isExecutable
     '/bin/ls' asFilename isExecutable

o  isExecutableProgram
return true, if such a file exists and is an executable program.
(i.e. for directories, false is returned.)

usage example(s):

     '/tmp' asFilename isExecutable
     '/bin/ls' asFilename isExecutable
     '/tmp' asFilename isExecutableProgram
     '/bin/ls' asFilename isExecutableProgram
     
     'ls' asFilename isExecutableProgram
     OperatingSystem canExecuteCommand:'ls'

o  isHidden
return true, if the receiver represents a hidden file.
The definitions of hidden files depends on the OS used;
on UNIX, a name starting with a period is considered hidden;
on MSDOS, the file's hidden attribute is also used.
VMS has no concept of hidden files.

o  isMountPoint: aPathName
return true, if I represent a mount-point.
Warning:
the receiver must be an absolute pathname,
because a realPath is not used/generated for the query (to avoid automounting).
Aka: do not ask: '../../' asFilename isMountPoint;

o  isReadable
return true, if such a file exists and is readable.

usage example(s):

     '/foo/bar' asFilename isReadable
     '/tmp' asFilename isReadable
     'Makefile' asFilename isReadable

o  isSharedLibrary
return true, if such a file exists and is a shared library.

usage example(s):

     'libstx_libbasic.so' asFilename isSharedLibrary
     'libstx_libbasic.dll' asFilename isSharedLibrary
     '/tmp' asFilename isSharedLibrary
     '/tmp.dll' asFilename isSharedLibrary

o  isValidFilename
return true, if the name is a valid filename.
This does NOT check for existance - only for the name
(i.e. it checks for invalid characters in the filename)

usage example(s):

     'abc' asFilename isValidFilename
     'abc/' asFilename isValidFilename
     ('abc' copyWith:Character return) asFilename isValidFilename

o  isWritable
return true, if such a file exists and is writable.

usage example(s):

     '/foo/bar' asFilename isWritable
     '/tmp' asFilename isWritable
     'Makefile' asFilename isWritable

o  isWritableDirectory
return true, if such a directory exists and is writable.
Don't believe #isWritable, since on an NFS mounted filesystem
with UID mapping and attribute cache enabled, there may be false negatives.

usage example(s):

     '/foo/bar' asFilename isWritableDirectory
     '/tmp' asFilename isWritableDirectory
     '/etc' asFilename isWritableDirectory
     'Makefile' asFilename isWritableDirectory
     '/net/exeptn/home2/office' asFilename isWritable
     '/net/exeptn/home2/office' asFilename isWritableDirectory

o  separator
return the directory-separator character

usage example(s):

     UnixFilename separator 
     PCFilename separator

o  species
create only new instances of the concrete OS specific class.
Redefined in AutoDeletedFilename, to not create AutoDeleted instances
per default (from directories etc.)

o  withSpecialExpansions
return a new filename, expanding any OS specific macros.
Here, a ~/ prefix is expanded to the users home dir (as in bash)

usage example(s):

     '~' asFilename withSpecialExpansions
     '~/Desktop' asFilename withSpecialExpansions
     '~stefan' asFilename withSpecialExpansions
     '~stefan/Desktop' asFilename withSpecialExpansions

queries-contents
o  mimeTypeFromName
return the mimeType as guessed from the file's name/and or extension.
This could be less accurate than mimeTypeOfContents, but avoids
reading the file (is therefore much faster).
Also it works with non-existing files.
Returns nil for directories and other non-regular files.

usage example(s):

     'Makefile' asFilename mimeTypeFromName
     '.' asFilename mimeTypeFromName
     '/dev/null' asFilename mimeTypeFromName
     '/tmp/.X11-unix/X0' asFilename mimeTypeFromName
     'smalltalk.rc' asFilename mimeTypeFromName
     'bitmaps/SBrowser.xbm' asFilename mimeTypeFromName
     '../../rules/stmkmf' asFilename mimeTypeFromName
     '/bläh' asFilename mimeTypeFromName
     '/x.zip' asFilename mimeTypeFromName
     '/x.gz' asFilename mimeTypeFromName

o  mimeTypeOfContents
this tries to guess the mime type of contents of
the file. Returns nil, if the file is unreadable, not a plain file
or the contents is unknown.
This is done using some heuristics, and may need some improvement

usage example(s):

     'Makefile' asFilename mimeTypeOfContents
     '.' asFilename mimeTypeOfContents
     '/dev/null' asFilename mimeTypeOfContents
     '/tmp/.X11-unix/X0' asFilename mimeTypeOfContents
     'smalltalk.rc' asFilename mimeTypeOfContents
     'bitmaps/SBrowser.xbm' asFilename mimeTypeOfContents
     '../../rules/stmkmf' asFilename mimeTypeOfContents
     '/bläh' asFilename mimeTypeOfContents
     'C:\Dokumente und Einstellungen\cg\Favoriten\languages.lnk' asFilename mimeTypeOfContents
     'G:\A\A01.TOP' asFilename mimeTypeOfContents
     '~/work/exept/expecco/plugin/labView/docs/labview_help_371361t/lvcomm.chm' asFilename mimeTypeOfContents

queries-path & name
o  baseName
return my baseName as a string.
- that's the file/directory name without leading parent-dirs.
(i.e. '/usr/lib/st/file' asFilename baseName -> 'file'
and '/usr/lib' asFilename baseName -> lib).
This method does not check if the path is valid.
The code here should work for Unix and MSDOS, but needs to be redefined
for VMS (and maybe others as well).
See also: #pathName, #directoryName and #directoryPathName.
Compatibility note: use #tail for ST-80 compatibility.

usage example(s):

     '/foo/bar' asFilename baseName
     '/foo/bar.cc' asFilename baseName
     '.' asFilename baseName
     '..' asFilename baseName
     '../..' asFilename baseName
     '../../libbasic' asFilename baseName
     '../../libpr' asFilename baseName
     '../../libbasic/Object.st' asFilename baseName
     '/' asFilename baseName
     '\' asFilename baseName
     'c:\' asFilename baseName
     '\\idefix' asFilename baseName

o  directory
return the directory name part of the file/directory as a new filename.
- that's a filename for the directory where the file/dir represented by
the receiver is contained in.
(this is almost equivalent to #directoryName or #head, but returns
a Filename instance instead of a string ).

usage example(s):

     '/foo/bar' asFilename directory
     '/foo/bar' asFilename directoryName
     '/foo/bar' asFilename head

     '.' asFilename directory
     '..' asFilename directory
     '../..' asFilename directory

o  directoryName
return the directory name part of the file/directory as a string.
- that's the name of the directory where the file/dir represented by
the receiver is contained in.
This method does not check if the path is valid.

(i.e. '/usr/lib/st/file' asFilename directoryName -> '/usr/lib/st'
and '/usr/lib' asFilename directoryName -> /usr').

(this is almost equivalent to #directory, but returns
a string instead of a Filename instance).

See also: #pathName, #directoryPathName and #baseName.
Compatibility note: use #head for ST-80 compatibility.

usage example(s):

     '/home' asFilename directoryName
     '/foo/bar/' asFilename directoryName
     '/foo/bar/' asFilename directory

     '/foo/bar' asFilename directoryName
     'bitmaps' asFilename directoryName
     'bitmaps' asFilename directoryPathName
     '.' asFilename directoryName
     '.' asFilename directoryPathName
     '..' asFilename directoryName
     '..' asFilename directoryPathName
     '../..' asFilename directoryName
     '../..' asFilename directoryPathName
     '/foo/bar/baz/..' asFilename directoryName
     '/foo/bar/baz/.' asFilename directoryName
     'c:\' asFilename directoryName

o  directoryPathName
return the full directory pathname part of the file/directory as a string.
- that's the full pathname of the directory where the file/dir represented by
the receiver is contained in.
See also: #pathName, #directoryName, #directory and #baseName

usage example(s):

     '/foo/bar/' asFilename directoryPathName
     '/foo/bar' asFilename directoryPathName

     '.' asFilename directoryPathName
     '.' asFilename directoryName
     '.' asFilename directory

     '..' asFilename directoryPathName
     '..' asFilename directoryName
     '..' asFilename directory

     '../..' asFilename directoryPathName

o  encodedNameString
answer the name as passed to OS system calls

o  filenameCompletion
try to complete the receiver filename.
BAD DESIGN: has side effect on the receiver.
This method has both a return value and a side effect on the receiver:
it returns a collection of matching filename objects,
and changes the receiver's filename-string to the longest common
match.
If none matches, the returned collection is empty and the receiver is unchanged.
If there is only one match, the size of the returned collection is exactly 1,
containing the fully expanded filename and the receiver's name is changed to it.

usage example(s):

     'mak' asFilename filenameCompletion
     'Make' asFilename filenameCompletion
     'Makef' asFilename filenameCompletion;yourself
     '/u' asFilename filenameCompletion
     '../../libpr' asFilename inspect filenameCompletion

o  filenameCompletionIn: aDirectory
try to complete the receiver filename.

BAD DESIGN: has side effect on the receiver.
This method has both a return value and a side effect on the receiver:
it returns a collection of matching filename objects,
and changes the receiver's filename-string to the longest common match.
If none matches, the returned collection is empty and the receiver is unchanged.
If there is only one match, the size of the returned collection is exactly 1,
containing the fully expanded filename and the receiver's name is changed to it.
An empty baseName pattern (i.e. giving the name of a directory) will also return an empty matchset.

o  head
return the directory name as a string.
An alias for directoryName, for ST-80 compatiblity.
(this is almost equivalent to #directory, but returns
a string instead of a Filename instance)

usage example(s):

     Filename currentDirectory head
     'Makefile' asFilename head
     '/foo/bar/baz.st' asFilename head

o  isAbsolute
return true, if the receiver represents an absolute pathname
(in contrast to one relative to the current directory).

usage example(s):

     '/foo/bar' asFilename isAbsolute
     '~/bla' asFilename isAbsolute
     '..' asFilename isAbsolute
     '..' asFilename asAbsoluteFilename isAbsolute
     'source/SBrowser.st' asFilename isAbsolute
     'source/SBrowser.st' asFilename isRelative
     'SBrowser.st' asFilename isRelative

o  isBackupFilename
return true, if this name is an for a backup file

o  isExplicitRelative
return true, if this name is an explicit relative name
(i.e. starts with './' or '../', to avoid path-prepending)

o  isImplicit
return true, if the receiver represents a builtin file.
The definitions of builtin files depends on the OS used;
on UNIX, '.' and '..' are builtin names.

o  isParentDirectoryOf: aFilenameOrString
Answer true, if myself is a parent directory of aFilenameOrString.
Unexpected results may be returned, if one of myself or aFilenameOrString does
not exist and relative and absolute path names are mixed
('/' asFilename isParentDirectoryOf:'../noExistent' -> false)

Warning: maybe symbolic links must be resolved which could lead to automounting

usage example(s):

     '/etc' asFilename isParentDirectoryOf:'/etc/passwd'
     'etc' asFilename isParentDirectoryOf:'etc/passwd'
     '/etc' asFilename isParentDirectoryOf:'/etc/'
     '/etc' asFilename isParentDirectoryOf:'/etc'
     '/et' asFilename isParentDirectoryOf:'/etc'
     '/home' asFilename isParentDirectoryOf:Filename currentDirectory
     '~' asFilename isParentDirectoryOf:Filename currentDirectory
     '~' asFilename isParentDirectoryOf:'.'
     '~' asFilename isParentDirectoryOf:'..'
     '~' asFilename isParentDirectoryOf:'../smalltalk'
     '../..' asFilename isParentDirectoryOf:'../nonExistent'
     '..' asFilename isParentDirectoryOf:'../../nonExistent'
     '/' asFilename isParentDirectoryOf:'../nonExistent'
     '/' asFilename isParentDirectoryOf:'/phys/qnx'

o  isRelative
return true, if this name is interpreted relative to some
directory (opposite of absolute)

usage example(s):

     './foo/bar' asFilename isRelative
     '../../foo/bar' asFilename isRelative
     '/foo/bar' asFilename isRelative
     'bar' asFilename isRelative

o  isRootDirectory
return true, if I represent the root directory
(i.e. I have no parentDir)

o  isVolumeAbsolute
return true, if the receiver represents an absolute pathname
on some disk volume (MSDOS only)

o  localPathName
return the full pathname of the file represented by the receiver,
but without any volume information.
Only makes a difference on MSDOS & VMS systems.

o  name
return the name of the file represented by the receiver as a string.
This may or may not be a relative name (i.e. include ..'s).
See also: pathName

usage example(s):

     '/foo/bar' asFilename name
     '/foo/bar' asFilename pathName
     '.' asFilename name
     '.' asFilename pathName
     '../..' asFilename name
     '../..' asFilename pathName
     'bitmaps' asFilename name
     'bitmaps' asFilename pathName
     '/tmp/../usr' asFilename name
     '/tmp/../usr' asFilename pathName
     'source/..' asFilename name
     'source/..' asFilename pathName
     '/tmp/..' asFilename name
     '/tmp/..' asFilename pathName

o  pathName
return the full pathname of the file represented by the receiver,
as a string. This will not include ..'s.
If the path represented by the receiver does NOT represent a valid path,
no compression will be done (for now; this may change).
See also: name

usage example(s):

     '/foo/bar' asFilename pathName
     '.' asFilename pathName
     '../..' asFilename pathName
     '../..' asFilename name
     '/tmp/../usr' asFilename pathName
     '/././usr' asFilename pathName
     '~/..' asFilename pathName
     '$JAVA_HOME/bin/java' asFilename pathName

o  pathNameRelativeFrom: anotherDirectoriesFilename
return the pathname of the receiver,
but relative from another directory.
I.e. if the receiver is /a/b/c
and the argument is /a/x/y,
then the relative path to the receiver as seen from the argument is ../../b/c

usage example(s):

     self assert:('/a' asFilename pathNameRelativeFrom:'/') = 'a'  
     self assert:('/a/b' asFilename pathNameRelativeFrom:'/') = 'a/b'  

     self assert:('/a' asFilename pathNameRelativeFrom:'/a') = '.'  
     self assert:('/a/b' asFilename pathNameRelativeFrom:'/a') = 'b'  
     self assert:('/a/b/c' asFilename pathNameRelativeFrom:'/a') = 'b/c'  

     self assert:('/a/' asFilename pathNameRelativeFrom:'/a') = '.'  
     self assert:('/a/b/' asFilename pathNameRelativeFrom:'/a') = 'b'  
     self assert:('/a/b/c/' asFilename pathNameRelativeFrom:'/a') = 'b/c'  

     self assert:('/a' asFilename pathNameRelativeFrom:'/a/') = '.'  
     self assert:('/a/b' asFilename pathNameRelativeFrom:'/a/') = 'b'  
     self assert:('/a/b/c' asFilename pathNameRelativeFrom:'/a/') = ''b/c''  

     self assert:('/a/' asFilename pathNameRelativeFrom:'/a/') = '.'  
     self assert:('/a/b/' asFilename pathNameRelativeFrom:'/a/') = 'b'  
     self assert:('/a/b/c/' asFilename pathNameRelativeFrom:'/a/') = 'b/c'  

     self assert:('/a' asFilename pathNameRelativeFrom:'/b') = '../a'  
     self assert:('/a/b/' asFilename pathNameRelativeFrom:'/b') = '../a/b'  
     self assert:('/a/b/c/' asFilename pathNameRelativeFrom:'/b') = '../a/b/c'  

     self assert:('/a/b/' asFilename pathNameRelativeFrom:'/a') = 'b'  
     self assert:('/a/b/c/' asFilename pathNameRelativeFrom:'/a') = 'b/c'  

     self assert:('/a/b/c/d' asFilename pathNameRelativeFrom:'/a/x/y/z') = '../../../b/c/d'  

o  physicalFilename
return the fileName representing the physical file as represented by the receiver,
If the receiver represents a symbolic link, that's the fileName of the
final target. Otherwise, its the receiver's pathName itself.
If any file along the symbolic path does not exist (i.e. is a broken link),
nil is returned.

usage example(s):

     '/foo/bar' asFilename physicalFilename

o  physicalPathName
return the full pathname of the physical file represented by the receiver,
If the receiver represents a symbolic link, that's the fileName of the
final target. Otherwise, its the receiver's pathName itself.
If any file along the symbolic path does not exist (i.e. is a broken link),
nil is returned.

usage example(s):

     '/foo/bar' asFilename physicalPathName
     '.' asFilename physicalPathName
     '../..' asFilename physicalPathName
     '/usr/tmp' asFilename physicalPathName

o  tail
the file's name without directory prefix as a string.
An alias for baseName, for ST-80 compatiblity.

usage example(s):

     Filename currentDirectory tail
     'Makefile' asFilename tail
     '/foo/bar/baz.st' asFilename tail

o  tail: nComponents
return the last n components of myself.
- that's the file/directory name without leading parent-dirs.
(i.e. '/usr/lib/st/file' asFilename tail:2 -> 'st/file'
and '/usr/lib' asFilename tail:1 -> lib).
This method does not check if the path is valid.
The code here should work for Unix and MSDOS, but needs to be redefined
for VMS (and maybe others as well).
See also: #pathName, #directoryName and #directoryPathName.

usage example(s):

     '/foo/bar' asFilename tail:1
     '/foo/bar' asFilename tail:2
     '/foo/bar' asFilename tail:3
     '/foo/bar.cc' asFilename tail:2
     '.' asFilename tail:3
     '..' asFilename tail:3
     '../..' asFilename tail:2
     '../../libbasic' asFilename tail:2
     '../../libbasic' asFilename asCanonicalizedFilename tail:2
     '../../libpr' asFilename tail:2
     '../../libbasic/Object.st' asFilename asCanonicalizedFilename tail:2
     '/' asFilename tail:2
     '\' asFilename tail:2
     'c:\' asFilename tail:2
     '\\idefix' asFilename tail:2

o  volume
return the disc volume part of the name or an empty string.
This is only used with MSDOS and VMS filenames
- by default (and on unix), an empty string is returned

queries-type
o  isDirectory
return true, if the receiver represents an existing,
readable directories pathname.
Symbolic links pointing to a directory answer true.

usage example(s):

     '/foo/bar' asFilename isDirectory
     '/tmp' asFilename isDirectory
     'Makefile' asFilename isDirectory
     'c:\' asFilename isDirectory
     'd:\' asFilename isDirectory
     '\\host\dir' asFilename isDirectory
     OperatingSystem isDirectory:'\\host\dir'

o  isNonEmptyDirectory
return true, if the receiver represents an existing,
readable directories pathname, and the directory is not empty.

usage example(s):

     '/foo/bar' asFilename isNonEmptyDirectory
     '/tmp' asFilename isNonEmptyDirectory
     '/tmp/empty' asFilename makeDirectory; isNonEmptyDirectory.
     '/tmp/empty' asFilename removeDirectory.
     'Makefile' asFilename isNonEmptyDirectory
     'c:\' asFilename isNonEmptyDirectory
     'd:\' asFilename isNonEmptyDirectory

o  isRegularFile
return true, if the receiver represents a plain, regular file.
Symbolic links pointing to a regular file answer true.

usage example(s):

     '/foo/bar' asFilename isRegularFile
     '/tmp' asFilename isRegularFile
     'Makefile' asFilename isRegularFile
     'c:\' asFilename isRegularFile
     'd:\' asFilename isRegularFile
     '/dev/null' asFilename isRegularFile

o  isSpecialFile
return true, if the receiver represents a socket, named pipe, fifo
or device special file (i.e. anything non regular and non-directory).
Symbolic links pointing to a special file answer true.

usage example(s):

     '/foo/bar' asFilename isSpecialFile
     '/tmp' asFilename isSpecialFile
     'Makefile' asFilename isSpecialFile
     'c:\' asFilename isSpecialFile
     'd:\' asFilename isSpecialFile
     '/dev/null' asFilename isSpecialFile

o  isSymbolicLink
return true, if the file represented by the receiver is a symbolic
link. Notice that not all OS's support symbolic links;
those that do not will always return false.

usage example(s):

     'Make.proto' asFilename isSymbolicLink
     'Makefile' asFilename isSymbolicLink

reading-directories
o  directoryContents
return the contents of the directory as a collection of strings.
This excludes any entries for '.' or '..'.
Returns nil for non-existing directories; however, this behavior
may be changed in the near future, to raise an exception instead.
So users of this method better test for existing directory before.
Notice:
this returns the file-names as strings;
see also #directoryContentsAsFilenames, which returns fileName instances.

usage example(s):

     '.' asFilename directoryContents
     '/XXXdoesNotExist' asFilename directoryContents

o  directoryContentsAsFilenames
return the contents of the directory as a collection of filenames.
This excludes any entries for '.' or '..'.
Returns nil for non-existing directories; however, this behavior
may be changed in the near future, to raise an exception instead.
So users of this method better test for existing directory before.
Notice:
this returns the file-names as fileName instances;
see also #directoryContents, which returns strings.

usage example(s):

     '.' asFilename directoryContentsAsFilenames
     '/XXXdoesNotExist' asFilename directoryContentsAsFilenames

o  fullDirectoryContents
return the full contents of the directory as a collection of strings.
This is much like #directoryContents, but includes an entry for the
parent directory, if there is one.
Returns nil for non-existing directories; however, this behavior
may be changed in the near future, to raise an exception instead.
So users of this method better test for existing directory before.

usage example(s):

     '.' asFilename fullDirectoryContents
     '/XXXdoesNotExist' asFilename fullDirectoryContents
     'd:\FET' asFilename fullDirectoryContents

o  isEmptyDirectory
answer true, if this is an empty directory.
Raise an exception, if this is not a directory.

usage example(s):

     '.' asFilename isEmptyDirectory
     'Make.proto' asFilename isEmptyDirectory
     '/XXXdoesNotExist' asFilename isEmptyDirectory

o  recursiveDirectoryContents
return the contents of the directory and all subdirectories
as a collection of strings.
This excludes any entries for '.' or '..'.
Subdirectory files are included with a relative pathname.
Notice:
this returns the file-names as strings;
see also #recursiveDirectoryContentsAsFilenames, which returns fileName instances.

Warning: this may take a long time to execute.

usage example(s):

     '.' asFilename recursiveDirectoryContents
     '../../clients' asFilename recursiveDirectoryContents

o  recursiveDirectoryContentsAsFilenames
return the contents of the directory and all subdirectories
as a collection of filenames.
This excludes any entries for '.' or '..'.
Returns nil for non-existing directories; however, this behavior
may be changed in the near future, to raise an exception instead.
So users of this method better test for existing directory before.
Notice:
this returns the file-names as fileName instances;
see also #recursiveDirectoryContents, which returns strings.

Warning: this may take a long time to execute.

usage example(s):

     '.' asFilename recursiveDirectoryContentsAsFilenames
     '/XXXdoesNotExist' asFilename recursiveDirectoryContentsAsFilenames

reading-files
o  binaryContents
an alias.
return the binary contents of the file (as a byteArray);
Raises an error, if the file is unreadable/non-existing.

o  binaryContentsOfEntireFile
return the binary contents of the file (as a byteArray);
Raises an error, if the file is unreadable/non-existing.

usage example(s):

     'Makefile' asFilename binaryContentsOfEntireFile
     'foobar' asFilename binaryContentsOfEntireFile

o  contents
Return the contents of the file as a collection of lines.
Raise an error if the file is unreadable/non-existing.
See also #contentsOfEntireFile, which returns a string for textFiles.
CAVEAT: bad naming - but req'd for VW compatibility.

usage example(s):

     'Makefile' asFilename contents
     'foobar' asFilename contents

o  contentsAsString
to compensate for the bad naming, use this to make things explicit.
See also #contents, which returns the lines as stringCollection for textFiles.

usage example(s):

     'Makefile' asFilename contentsAsString
     'foobar' asFilename contentsAsString

o  contentsOfEntireFile
return the contents of the file as a string;
Raises an error, if the file is unreadable/non-existing.
See also #contents, which returns the lines as stringCollection for textFiles.
CAVEAT: bad naming - but req'd for VW compatibility.

usage example(s):

     'Makefile' asFilename contentsOfEntireFile
     'smalltalk.rc' asFilename contentsOfEntireFile
     'foobar' asFilename contentsOfEntireFile

o  readingFileDo: aBlock
Create a read stream on the receiver file, evaluate aBlock, passing that stream as arg,
and return the block's value.
If the file cannot be opened, an exception is raised or
(old behavior, will vanish:)the block is evaluated with a nil argument.
Ensures that the stream is closed.

o  readingFileWithEncoding: encodingNameSymbol do: aBlock
Create a read stream on the receiver file, evaluate aBlock, passing that stream as arg,
and return the block's value.
If the file cannot be opened, an exception is raised or
(old behavior, will vanish:)the block is evaluated with a nil argument.
Ensures that the stream is closed.
The file is decoded on the fly.

usage example(s):

     'Make.proto' asFilename 
        readingFileWithEncoding:#utf8 
        do:[:stream |
            stream upToEnd
        ]

o  readingLinesDo: aBlock
Create a read stream on the receiver file and
evaluate aBlock for each line read from the stream.
If the file cannot be opened, an error is raised.
Ensures that the stream is closed.

usage example(s):

    '/etc/passwd' asFilename
        readingLinesDo:[:eachLine |
            Transcript showCR:eachLine.
        ].

usage example(s):

    '/etc/xxxxx' asFilename
        readingLinesDo:[:eachLine |
            Transcript showCR:eachLine.
        ].

special accessing
o  osName
special - return the OS's name for the receiver.
Note: this may return an absolute pathName, if there are
place holders in the name.
Otherwise it keeps the name relative or absolute as it is.

o  osNameForAccess
internal - return the OS's name for the receiver to
access its fileInfo.
This may be redefined for systems, where a special suffix must be
added in order to access directories (or others) as a file.
(i.e. under VMS, a '.dir' suffix is added to access directories)

o  osNameForDirectory
internal - return the OS's name for the receiver to
access it as a directory.
Note: this may return an absolute pathName, if there are
place holders in the name.
Otherwise it keeps the name relative or absolute as it is.

usage example(s):

        '.' asFilename osNameForDirectory
        '.' asFilename pathName

o  osNameForDirectoryContents
internal - return the OS's name for the receiver to
access it as a directory when reading its contents.
Note: this may return an absolute pathName, if there are
place holders in the name.
Otherwise it keeps the name relative or absolute as it is.

o  osNameForFile
internal - return the OS's name for the receiver to
access it as a file.
Note: this may return an absolute pathName, if there are
place holders in the name.
Otherwise it keeps the name relative or absolute as it is.

suffixes
o  addSuffix: aSuffix
return a new filename for the receiver's name with a additional suffix.
The new suffix is simply appended to the name,
regardless whether there is already an existing suffix.
See also #withSuffix:

usage example(s):

     'abc.st' asFilename addSuffix:nil
     'a.b.c' asFilename addSuffix:nil
     '.b.c.' asFilename addSuffix:nil
     '.b.c' asFilename addSuffix:nil
     '.c.' asFilename addSuffix:nil
     '.c' asFilename addSuffix:nil
     'c.' asFilename addSuffix:nil
     '.' asFilename addSuffix:nil

     'abc.st' asFilename addSuffix:'o'
     'abc' asFilename addSuffix:'o'
     'a.b.c' asFilename addSuffix:'o'
     'a.b.c.' asFilename addSuffix:'o'
     '.b.c.' asFilename addSuffix:'o'
     '.c.' asFilename addSuffix:'o'
     '.c' asFilename addSuffix:'o'
     'c.' asFilename addSuffix:'o'
     '.' asFilename addSuffix:'o'
     '/foo/bar/baz.st' asFilename addSuffix:'c'
     '/foo/bar/baz.c' asFilename addSuffix:'st'
     '/foo/bar.c/baz.c' asFilename addSuffix:'st'
     '/foo/bar.c/baz' asFilename addSuffix:'st'

o  hasSuffix: aSuffixString
return true if my suffix is the same as aString.
This cares for systems, where case is ignored in filenames

usage example(s):

     'abc.st' asFilename hasSuffix:'st'
     'abc.ST' asFilename hasSuffix:'st'
     '.ST' asFilename hasSuffix:'st'              -- false expected here in Unix, true in Windows
     '.foorc' asFilename hasSuffix:'foorc'        -- false expected here
     '.foorc.sav' asFilename hasSuffix:'sav'

o  nameWithoutSuffix
return the receiver's name without the suffix.
If the name has no suffix, the original name is returned.

usage example(s):

     'abc.st' asFilename nameWithoutSuffix
     'abc' asFilename nameWithoutSuffix
     '/abc' asFilename nameWithoutSuffix
     '/abc.d' asFilename nameWithoutSuffix
     './abc' asFilename nameWithoutSuffix
     './abc.d' asFilename nameWithoutSuffix
     './.abc' asFilename nameWithoutSuffix
     'a.b.c' asFilename nameWithoutSuffix
     'a.b.' asFilename nameWithoutSuffix
     '.b.c' asFilename nameWithoutSuffix
     '.b.' asFilename nameWithoutSuffix
     '.b' asFilename nameWithoutSuffix
     '/foo/bar/baz.c' asFilename nameWithoutSuffix
     '/foo/bar.x/baz.c' asFilename nameWithoutSuffix
     '/foo/bar.x/baz' asFilename nameWithoutSuffix
     '/foo/bar/baz/foo.c/bar' asFilename nameWithoutSuffix
     '/foo/bar/baz/foo.c/bar.c' asFilename nameWithoutSuffix

o  prefix
return my prefix.
The suffix is the namepart after the final period character,
or the empty string, if the name does not contain a period.

usage example(s):

     'abc.st' asFilename prefix
     'abc' asFilename prefix
     'a.b.c' asFilename prefix
     'a.b.c' asFilename prefix
     'a.' asFilename prefix
     '.a' asFilename prefix

o  prefixAndSuffix
return an array consisting of my prefix and suffix.
The suffix is the namepart after the final period character,
the prefix everything before, except for the period.
The directory name part is stripped off (i.e. the returned prefix
will consist of the file's basename only.)
(on some systems, the suffix-character may be different from a period).
For example, foo.bar.baz has a prefix of 'foo.bar' and a suffix of '.baz'.
An exception to the above: if the name starts with the suffixCharacter,
that part is NOT considered a suffix. Thus, '.foorc' has no suffix and a prefix of
'.foorc'.
See also: #withoutSuffix and #withSuffix
Notice:
there is currently no known system which uses other than
the period character as suffixCharacter.

usage example(s):

     'abc.st' asFilename prefixAndSuffix
     'abc' asFilename prefixAndSuffix
     'a.b.c' asFilename prefixAndSuffix
     '/foo/bar.c/baz.c' asFilename prefixAndSuffix
     'a.' asFilename prefixAndSuffix
     '.a' asFilename prefixAndSuffix

     |parts|
     parts := 'Object.st' asFilename prefixAndSuffix.
     ((parts at:1) , '.o') asFilename

o  suffix
return my suffix.
The suffix is the namepart after the final period character,
or the empty string, if the name does not contain a period.

usage example(s):

     'abc.st' asFilename suffix
     'abc' asFilename suffix
     'a.b.c' asFilename suffix
     'a.b.c' asFilename suffix
     'a.' asFilename suffix
     '.a' asFilename suffix

o  withSuffix: aSuffix
return a new filename for the receiver's name with a different suffix.
If the name already has a suffix, the new suffix replaces it;
otherwise, the new suffix is simply appended to the name.

usage example(s):

     'abc.st' asFilename withSuffix:nil
     'a.b.c' asFilename withSuffix:nil
     '.b.c.' asFilename withSuffix:nil
     '.b.c' asFilename withSuffix:nil
     '.c.' asFilename withSuffix:nil
     '.c' asFilename withSuffix:nil
     'c.' asFilename withSuffix:nil
     '.' asFilename withSuffix:nil

     'abc.st' asFilename withSuffix:'o'
     'abc' asFilename withSuffix:'o'
     'a.b.c' asFilename withSuffix:'o'
     'a.b.c.' asFilename withSuffix:'o'
     '.b.c.' asFilename withSuffix:'o'
     '.c.' asFilename withSuffix:'o'
     '.c' asFilename withSuffix:'o'
     'c.' asFilename withSuffix:'o'
     '.' asFilename withSuffix:'o'
     '/foo/bar/baz.st' asFilename withSuffix:'c'
     '/foo/bar/baz.c' asFilename withSuffix:'.st'
     '/foo/bar.c/baz.c' asFilename withSuffix:'st'
     '/foo/bar.c/baz' asFilename withSuffix:'st'

o  withoutSuffix
return a new filename for the receiver's name without the suffix.
If the name has no suffix, a filename representing the same file as the receiver is returned.

usage example(s):

     'abc.st' asFilename withoutSuffix
     'abc' asFilename withoutSuffix
     '/abc' asFilename withoutSuffix
     '/abc.d' asFilename withoutSuffix
     './abc' asFilename withoutSuffix
     './abc.d' asFilename withoutSuffix
     './.abc' asFilename withoutSuffix
     'a.b.c' asFilename withoutSuffix
     'a.b.' asFilename withoutSuffix
     '.b.c' asFilename withoutSuffix
     '.b.' asFilename withoutSuffix
     '.b' asFilename withoutSuffix
     '/foo/bar/baz.c' asFilename withoutSuffix
     '/foo/bar.x/baz.c' asFilename withoutSuffix
     '/foo/bar.x/baz' asFilename withoutSuffix
     '/foo/bar/baz/foo.c/bar' asFilename withoutSuffix
     '/foo/bar/baz/foo.c/bar.c' asFilename withoutSuffix

testing
o  isFilename
return true, if the receiver is some kind of filename;
false is returned here - the method is redefined from Object.

writing-files
o  appendingFileDo: aBlock
create a append-stream on the receiver file, evaluate aBlock, passing that stream as arg,
and return the block's value.
If the file cannot be opened, an exception is raised.
Ensures that the stream is closed.

usage example(s):

     'ttt' asFilename appendingFileDo:[:s |
        s nextPutLine:'hello'.
        s nextPutLine:'world'.
     ]

o  contents: aStringOrByteArrayOrCollectionOfLines
create (or overwrite) a file given its contents as a collection of lines.
Raises an error, if the file is unwritable.

usage example(s):

     'foo1' asFilename contents:#('one' 'two' 'three')
     'foo2' asFilename contents:'Hello world'
     'foo3' asFilename contents:#[1 2 3 4 5]

o  writingFileDo: aBlock
create a write-stream on the receiver file, evaluate aBlock,
passing that stream as arg,
and return the block's value.
If the file cannot be opened, an exception is raised.
Ensures that the stream is closed.

usage example(s):

     'ttt' asFilename writingFileDo:[:s |
        s nextPutLine:'hello'.
        s nextPutLine:'world'.
     ]


Examples:


does a file/directory exist ?:
    |f|

    f := 'foobar' asFilename.
    ^ f exists
is it a directory ?:
    |f|

    f := '/tmp' asFilename.
    ^ f isDirectory.
get the working directory:
    ^ Filename defaultDirectory
get a files full pathname (caring for relative names or symbolic links):
    |f|

    f := '..' asFilename.
    ^ f pathName
get a directories directory:
    |f|

    f := Filename defaultDirectory.
    ^ f directory
get a files directory:
    |f|

    f := './smalltalk' asFilename.
    ^ f directory
getting access & modification times:
    |f|

    f := '/tmp' asFilename.
    ^ f dates
access time only:
    |f|

    f := '/tmp' asFilename.
    ^ f dates at:#accessed
getting all information on a file/directory:
    |f|

    f := '/tmp' asFilename.
    ^ f info
getting a temporary file (unique name):
    |f|

    f := Filename newTemporary.
    ^ f
creating, writing, reading and removing a temporary file:
    |f writeStream readStream|

    f := Filename newTemporary.
    writeStream := f writeStream.
    writeStream nextPutAll:'hello world'.
    writeStream cr.
    writeStream close.

    'contents (as seen by unix''s cat command:' printNL.
    OperatingSystem executeCommand:('cat ' , f pathName).

    readStream := f readStream.
    Transcript showCR:'contents as seen by smalltalk:'.
    Transcript showCR:(readStream upToEnd).
    readStream close.

    f delete.
getting a directories contents:
    |f files|

    f := Filename currentDirectory.
    files := f directoryContents.
    Transcript showCR:'the files are:'.
    Transcript showCR:(files printString).
editing a file:
    |f|

    f := Filename newTemporary.
    (f writeStream) nextPutAll:'hello world'; close.

    f edit


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 19 Apr 2024 05:31:06 GMT