"
COPYRIGHT (c) 1997 by eXept Software AG
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.
"
'From Smalltalk/X, Version:3.2.1 on 16-oct-1997 at 1:30:13 pm' !
Filename subclass:#PCFilename
instanceVariableNames:''
classVariableNames:'StandardSuffixTable'
poolDictionaries:''
category:'OS-PC'
!
!PCFilename class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1997 by eXept Software AG
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.
"
!
documentation
"
Filenames in Windows-NT / Win95.
"
! !
!PCFilename class methodsFor:'initialization'!
initStandardSuffixTable
"since there is no 'file' command to extract the type,
return a guess based upon the files suffix. The following
table defines what is returned."
StandardSuffixTable := Dictionary new.
#(
'COM' 'executable'
'DIR' 'directory'
'EXE' 'executable'
'LST' 'listing'
'OBJ' 'object file'
'TMP' 'temporary'
'BAS' 'basic source'
'C' 'c source'
'COB' 'cobol source'
'FOR' 'fortran source'
'PAS' 'pascal source'
'PL1' 'PL/1 source'
'ST' 'smalltalk source'
'STH' 'stc generated header'
'DLL' 'dynamic link library'
) pairWiseDo:[:k :v |
StandardSuffixTable at:k put:v
]
"
StandardSuffixTable := nil.
self initStandardSuffixTable
"
"Modified: 16.10.1997 / 13:12:39 / cg"
! !
!PCFilename class methodsFor:'queries'!
isBadCharacter:aCharacter
"return true, if aCharacter is unallowed in a filename."
('<>:"/\|' includes:aCharacter) ifTrue:[^ true].
^ super isBadCharacter:aCharacter
"Created: 8.9.1997 / 00:14:06 / cg"
!
isCaseSensitive
"return true, if filenames are case sensitive."
^ false
!
separator
"return the file/directory separator."
^ $\
"
Filename concreteClass separator
"
"Modified: 8.9.1997 / 00:18:03 / cg"
! !
!PCFilename methodsFor:'queries'!
fileType
"this returns a string describing the type of contents of
the file. Here, the suffix is examined for a standard
suffix and an appropriate string is returned.
Poor MSDOS - no file command."
|suff type info fmt|
StandardSuffixTable isNil ifTrue:[
self class initStandardSuffixTable
].
suff := self suffix asUppercase.
type := StandardSuffixTable at:suff ifAbsent:nil.
type isNil ifTrue:[
type := super fileType.
].
^ type
"Created: 16.10.1997 / 13:07:24 / cg"
"Modified: 16.10.1997 / 13:10:00 / cg"
!
isExecutableProgram
"return true, if such a file exists and is an executable program.
(i.e. for directories, false is returned.)"
(self hasSuffix:'exe') ifTrue:[
^ super isExecutableProgram
].
(self hasSuffix:'com') ifTrue:[
^ super isExecutableProgram
].
^ false
"Created: 16.10.1997 / 13:19:10 / cg"
!
isExplicitRelative
"return true, if this name is an explicit relative name
(i.e. starts with './' or '../', to avoid path-prepending)"
(nameString startsWith:'.\') ifTrue:[
^ true
].
(nameString startsWith:'..\') ifTrue:[
^ true
].
^ false
!
isVolumeAbsolute
"return true, if the receiver represents an absolute pathname
on some disk volume."
^ ((nameString size >= 2) and:[(nameString at:2) == $:])
"Created: 7.9.1997 / 23:54:20 / cg"
!
localNameStringFrom:aString
"ST-80 compatibility.
what does this do ? (used in FileNavigator-goody).
GUESS: does it strip off the voulume-character and initial '\' ?"
(aString at:2) == $: ifTrue:[
(aString at:3) == $\ ifTrue:[
^ aString copyFrom:4
].
^ aString copyFrom:3
].
(aString at:1) == $\ ifTrue:[
^ aString copyFrom:1
].
^ aString
!
volume
"return the disc volume part of the name or an empty string.
This is only used with DOS filenames - on unix, an empty string is returned"
(nameString at:2) == $: ifTrue:[
^ nameString copyTo:1
].
^ ''
"Created: 7.9.1997 / 23:58:06 / cg"
! !
!PCFilename class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libbasic/PCFilename.st,v 1.6 1997-10-16 11:17:03 cg Exp $'
! !