UnixFilename.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Sep 1997 19:35:21 +0200
changeset 2911 9964e6839a8e
parent 2908 b3be3629fcb1
child 2931 11bcbf8738c6
permissions -rw-r--r--
*** empty log message ***

'From Smalltalk/X, Version:3.1.9 on 9-sep-1997 at 11:56:06 pm'                  !

Filename subclass:#UnixFilename
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'OS-Unix'
!

!UnixFilename class methodsFor:'documentation'!

documentation
"
    Filenames in Unix.
"

! !

!UnixFilename class methodsFor:'queries'!

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

    aCharacter == $/ ifTrue:[^ true].
    ^ super isBadCharacter:aCharacter

    "Created: 8.9.1997 / 00:13:14 / cg"
!

isCaseSensitive
    "return true, if filenames are case sensitive.return true, if filenames are case sensitive."

    ^ true
!

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

    ^ '..'
!

separator
    "return the file/directory separator."

     ^ $/

     "
      Filename concreteClass separator  
     "

    "Created: 8.9.1997 / 00:18:14 / cg"
! !

!UnixFilename methodsFor:'file queries'!

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 return an empty string, not knowning
     about the contents.
     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."

    |stream typeString|

    "/ since executing 'file' takes some time, do the most common
    "/ ones are checked first, using the general fileType implementation. 
    "/ (also, the file-command is only available on Unix systems.

    typeString := super fileType.
    typeString ~= 'file' ifTrue:[^ typeString].

    stream := PipeStream readingFrom:('file ' , self pathName).
    stream notNil ifTrue:[
        typeString := stream contents asString.
        stream close.
        typeString := typeString copyFrom:(typeString indexOf:$:) + 1.
        typeString := typeString withoutSeparators
    ].
    ^ typeString

    "
     'Makefile' asFilename fileType 
     '.' asFilename fileType     
     '/dev/null' asFilename fileType        
     'smalltalk.rc' asFilename fileType    
     'bitmaps/SBrowser.xbm' asFilename fileType    
    "

    "Modified: 7.9.1997 / 23:43:03 / cg"
! !

!UnixFilename class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.3 1997-09-09 17:35:21 cg Exp $'
! !