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