2911
|
1 |
'From Smalltalk/X, Version:3.1.9 on 9-sep-1997 at 11:56:06 pm' !
|
2907
|
2 |
|
|
3 |
Filename subclass:#UnixFilename
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'OS-Unix'
|
|
8 |
!
|
|
9 |
|
2911
|
10 |
!UnixFilename class methodsFor:'documentation'!
|
|
11 |
|
2931
|
12 |
copyright
|
|
13 |
"
|
|
14 |
COPYRIGHT (c) 1997 by eXept Software AG
|
|
15 |
All Rights Reserved
|
|
16 |
|
|
17 |
This software is furnished under a license and may be used
|
|
18 |
only in accordance with the terms of that license and with the
|
|
19 |
inclusion of the above copyright notice. This software may not
|
|
20 |
be provided or otherwise made available to, or used by, any
|
|
21 |
other person. No title to or ownership of the software is
|
|
22 |
hereby transferred.
|
|
23 |
"
|
|
24 |
!
|
|
25 |
|
2911
|
26 |
documentation
|
|
27 |
"
|
|
28 |
Filenames in Unix.
|
|
29 |
"
|
|
30 |
|
|
31 |
! !
|
|
32 |
|
2907
|
33 |
!UnixFilename class methodsFor:'queries'!
|
|
34 |
|
|
35 |
isBadCharacter:aCharacter
|
|
36 |
"return true, if aCharacter is unallowed in a filename."
|
|
37 |
|
|
38 |
aCharacter == $/ ifTrue:[^ true].
|
|
39 |
^ super isBadCharacter:aCharacter
|
|
40 |
|
|
41 |
"Created: 8.9.1997 / 00:13:14 / cg"
|
|
42 |
!
|
|
43 |
|
2908
|
44 |
isCaseSensitive
|
|
45 |
"return true, if filenames are case sensitive.return true, if filenames are case sensitive."
|
|
46 |
|
|
47 |
^ true
|
|
48 |
!
|
|
49 |
|
|
50 |
parentDirectoryName
|
|
51 |
"return the name used for the parent directory.
|
|
52 |
This is '..' for unix and dos-like systems.
|
|
53 |
(there may be more in the future."
|
|
54 |
|
|
55 |
^ '..'
|
|
56 |
!
|
|
57 |
|
2907
|
58 |
separator
|
|
59 |
"return the file/directory separator."
|
|
60 |
|
|
61 |
^ $/
|
|
62 |
|
|
63 |
"
|
|
64 |
Filename concreteClass separator
|
|
65 |
"
|
|
66 |
|
|
67 |
"Created: 8.9.1997 / 00:18:14 / cg"
|
|
68 |
! !
|
|
69 |
|
|
70 |
!UnixFilename methodsFor:'file queries'!
|
|
71 |
|
|
72 |
fileType
|
|
73 |
"this returns a string describing the type of contents of
|
|
74 |
the file. This is done using the unix 'file' command,
|
|
75 |
(which usually is configurable by /etc/magic).
|
|
76 |
On non-unix systems, this may return an empty string, not knowning
|
|
77 |
about the contents.
|
|
78 |
Since the returned string differs among systems (and language settings),
|
|
79 |
it is only useful for user-information; NOT as a tag to be used by a program."
|
|
80 |
|
|
81 |
|stream typeString|
|
|
82 |
|
|
83 |
"/ since executing 'file' takes some time, do the most common
|
|
84 |
"/ ones are checked first, using the general fileType implementation.
|
|
85 |
"/ (also, the file-command is only available on Unix systems.
|
|
86 |
|
|
87 |
typeString := super fileType.
|
|
88 |
typeString ~= 'file' ifTrue:[^ typeString].
|
|
89 |
|
|
90 |
stream := PipeStream readingFrom:('file ' , self pathName).
|
|
91 |
stream notNil ifTrue:[
|
|
92 |
typeString := stream contents asString.
|
|
93 |
stream close.
|
|
94 |
typeString := typeString copyFrom:(typeString indexOf:$:) + 1.
|
|
95 |
typeString := typeString withoutSeparators
|
|
96 |
].
|
|
97 |
^ typeString
|
|
98 |
|
|
99 |
"
|
|
100 |
'Makefile' asFilename fileType
|
|
101 |
'.' asFilename fileType
|
|
102 |
'/dev/null' asFilename fileType
|
|
103 |
'smalltalk.rc' asFilename fileType
|
|
104 |
'bitmaps/SBrowser.xbm' asFilename fileType
|
|
105 |
"
|
|
106 |
|
|
107 |
"Modified: 7.9.1997 / 23:43:03 / cg"
|
|
108 |
! !
|
|
109 |
|
2931
|
110 |
!UnixFilename methodsFor:'queries'!
|
|
111 |
|
|
112 |
isExplicitRelative
|
|
113 |
"return true, if this name is an explicit relative name
|
|
114 |
(i.e. starts with './' or '../', to avoid path-prepending)"
|
|
115 |
|
|
116 |
(nameString startsWith:'./') ifTrue:[
|
|
117 |
^ true
|
|
118 |
].
|
|
119 |
(nameString startsWith:'../') ifTrue:[
|
|
120 |
^ true
|
|
121 |
].
|
|
122 |
^ false
|
|
123 |
!
|
|
124 |
|
|
125 |
isHidden
|
|
126 |
"return true, if the receiver represents a hidden file.
|
|
127 |
On UNIX, a name starting with a period is considered hidden."
|
|
128 |
|
|
129 |
^ self baseName startsWith:'.'
|
|
130 |
! !
|
|
131 |
|
2911
|
132 |
!UnixFilename class methodsFor:'documentation'!
|
2907
|
133 |
|
2911
|
134 |
version
|
2931
|
135 |
^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.4 1997-09-15 21:02:50 cg Exp $'
|
2907
|
136 |
! !
|