Care for UTF8 filenams in linux/unix
- do it the right way, immediately before going to the OS
--- a/UnixFilename.st Thu Nov 06 11:11:18 2008 +0100
+++ b/UnixFilename.st Thu Nov 06 11:12:33 2008 +0100
@@ -9,7 +9,6 @@
other person. No title to or ownership of the software is
hereby transferred.
"
-
"{ Package: 'stx:libbasic' }"
Filename subclass:#UnixFilename
@@ -40,29 +39,12 @@
Filenames in Unix.
"
-! !
-
-!UnixFilename class methodsFor:'instance creation'!
-
-named:aString
- "return a filename for a directory named aString.
- This is the same as 'aString asFilename'."
-
- |singleByteString|
+!
- aString bitsPerCharacter > 8 ifTrue:[
- singleByteString := aString utf8Encoded.
- ] ifFalse:[
- singleByteString := aString.
- ].
- ^ (self basicNew) setName:singleByteString
-
+examples
"
- Filename named:'/tmp/fooBar'
+ (self named:'/tmp/äöü') writeStream close
"
-
- "Modified: / 04-08-2005 / 09:21:35 / janfrog"
- "Modified: / 18-09-2006 / 22:20:51 / cg"
! !
!UnixFilename class methodsFor:'queries'!
@@ -200,8 +182,27 @@
"Modified: / 21.7.1998 / 11:10:42 / cg"
! !
+!UnixFilename methodsFor:'special accessing'!
+
+osNameForDirectory
+ "internal - return the OS's name for the receiver to
+ access it as a directory."
+
+ ^ self osNameForFile
+!
+
+osNameForFile
+ "internal - return the OS's name for the receiver to
+ access it as a file."
+
+ nameString bitsPerCharacter < 8 ifTrue:[
+ ^ nameString.
+ ].
+ ^ nameString utf8Encoded.
+! !
+
!UnixFilename class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.14 2006-09-18 20:19:54 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixFilename.st,v 1.15 2008-11-06 10:12:33 stefan Exp $'
! !