--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/UnixFilename.st Mon Sep 08 20:10:04 1997 +0200
@@ -0,0 +1,100 @@
+'From Smalltalk/X, Version:3.1.9 on 8-sep-1997 at 12:39:54 am' !
+
+Filename subclass:#UnixFilename
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'OS-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"
+!
+
+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 methodsFor:'instance creation'!
+
+constructString:subname
+ "taking the receiver as a directory name, construct a new
+ filenames string for an entry within this directory
+ (i.e. for a file or a subdirectory in that directory)."
+
+ |sepString|
+
+ sepString := self class separator asString.
+ nameString = sepString ifTrue:[
+ "I am the root"
+ ^ sepString , subname
+ ].
+ ^ nameString , sepString , subname asString
+
+ "
+ '/tmp' asFilename constructString:'foo'
+ '/' asFilename constructString:'foo'
+ '/usr/tmp' asFilename constructString:'foo'
+ '/foo/bar' asFilename constructString:'baz'
+ "
+
+ "Modified: 7.9.1995 / 10:15:22 / claus"
+ "Modified: 29.2.1996 / 20:55:18 / cg"
+ "Created: 7.9.1997 / 23:44:55 / cg"
+! !
+