Filename.st
author claus
Mon, 20 Dec 1993 18:32:29 +0100
changeset 27 d98f9dd437f7
parent 5 67342904af11
child 38 454b1b94a48e
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1992 by Claus Gittinger
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

Object subclass:#Filename
         instanceVariableNames:'name'
         classVariableNames:''
         poolDictionaries:''
         category:'ST-80 compatibility'!

Filename comment:'

COPYRIGHT (c) 1992 by Claus Gittinger
             All Rights Reserved

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

$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.4 1993-10-13 02:12:08 claus Exp $
'!

!Filename class methodsFor:'instance creation'!

currentDirectory
    ^ (self basicNew) name:(FileDirectory currentDirectory pathName)
!

named:aString
    ^ (self basicNew) name:aString
! !

!Filename class methodsFor:'queries'!

separator
    "return the file/directory separator."

     ^ OperatingSystem fileSeparator
! !

!Filename methodsFor:'instance creation'!

construct:subname
    ^ (self class basicNew) name:(name , '/' , subname)
! !

!Filename methodsFor:'converting'!

asString
    ^ name
!

asFilename
    ^ self
! !

!Filename methodsFor:'private accessing'!

name:aString
    name := aString
! !

!Filename methodsFor:'queries'!

directoryName
    "return the directoryName of the argument, aPath
     - thats the name of the directory where aPath is"

    ^ OperatingSystem directoryNameOf:name
!

baseName
    "return my baseName
     - thats the file/directory name without leading parent-dirs"

    ^ OperatingSystem baseNameOf:name
! !

!Filename methodsFor:'file access'!

renameTo:newName
    "rename the file - the argument must be convertable to a String"

    ^ OperatingSystem rename:name to:(newName asString)

    "'/tmp/foo asFileName renameTo:'/tmp/bar'"
!

exists
    "return true, if such a file exists"

    ^ OperatingSystem isValidPath:name
!

fileIn
    "load smalltalk code from the file"

    ^ self readStream fileIn
!

readStream
    "return a stream for reading"

    ^ FileStream readonlyFileNamed:name
!

writeStream
    "return a stream for writing"

    ^ FileStream newFileNamed:name
! !