--- a/UnixFilename.st Tue Feb 04 21:09:59 2014 +0100
+++ b/UnixFilename.st Wed Apr 01 10:20:10 2015 +0100
@@ -47,6 +47,36 @@
"
! !
+!UnixFilename class methodsFor:'defaults'!
+
+defaultTempDirectoryName
+ "return the default temp directory as a filename."
+
+ |tempDirString tempDir|
+
+ #('STX_TMPDIR' 'ST_TMPDIR' 'TMPDIR' 'TEMPDIR' 'TEMP' 'TMP') do:[:envVar |
+ tempDirString := OperatingSystem getEnvironment:envVar.
+ tempDirString notNil ifTrue:[
+ tempDir := self named:tempDirString.
+ (tempDir exists and:[ tempDir isWritable ]) ifTrue:[
+ ('Filename [info]: using tmp folder "%1" as specified by environment: "%2"'
+ bindWith:tempDir pathName with:envVar) infoPrintCR.
+ ^ tempDir asFilename.
+ ].
+ ].
+ ].
+
+ tempDir := '/tmp' asFilename.
+ ('Filename [info]: using default unix tmp folder: ',tempDir pathName) infoPrintCR.
+ ^ tempDir
+
+ "
+ Filename defaultTempDirectoryName
+ Filename defaultTempDirectoryName exists
+ Filename defaultTempDirectoryName isWritable
+ "
+! !
+
!UnixFilename class methodsFor:'queries'!
isBadCharacter:aCharacter
@@ -117,19 +147,18 @@
it is only useful for user-information;
NOT as a tag to be used by a program."
- |stream typeString|
+ |typeString|
- "/ since executing 'file' takes some time, do the most common
+ "/ since executing 'file' takes some time, the most common
"/ ones are checked first, using the general fileType implementation.
- "/ (also, the file-command is only available on Unix systems.
+ "/ (also, the file-command is only available on Unix systems,
+ "/ so this provides a reasonable fallback).
typeString := super fileType.
typeString ~= 'file' ifTrue:[^ typeString].
- stream := PipeStream readingFrom:('file "' , self pathName , '"').
- stream notNil ifTrue:[
- typeString := stream contents asString.
- stream close.
+ typeString := PipeStream outputFromCommand:('file "' , self pathName , '"').
+ typeString notNil ifTrue:[
typeString := typeString copyFrom:(typeString indexOf:$:) + 1.
typeString := typeString withoutSeparators
].
@@ -142,6 +171,7 @@
'smalltalk.rc' asFilename fileType
'bitmaps/SBrowser.xbm' asFilename fileType
'../../libtool/bitmaps/SBrowser.xbm' asFilename fileType
+ './stx' asFilename fileType
"
"Modified: / 21.7.1998 / 11:26:32 / cg"
@@ -196,10 +226,10 @@
!UnixFilename class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.20 2013-11-13 10:37:55 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.25 2014-11-18 18:59:35 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.20 2013-11-13 10:37:55 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.25 2014-11-18 18:59:35 cg Exp $'
! !