--- a/UnixOperatingSystem.st Thu Apr 25 13:22:42 2013 +0200
+++ b/UnixOperatingSystem.st Thu Apr 25 13:42:17 2013 +0200
@@ -5021,51 +5021,66 @@
|p path command|
path = '.' ifTrue:[
- ^ self getCurrentDirectory.
+ ^ self getCurrentDirectory.
].
"some systems have a convenient function for this ..."
path := self primPathNameOf:(self encodePath:pathName).
path notNil ifTrue:[
- path := self decodePath:path.
+ path := self decodePath:path.
] ifFalse:[
- (self isValidPath:pathName) ifFalse:[
- p := pathName.
- [(p size > 1)
- and:[p endsWith:(self fileSeparator)]
- ] whileTrue:[
- p := p copyWithoutLast:1.
- ].
- ^ p
- ].
-
- (SlowFork==true or:[PipeFailed==true]) ifFalse:[
- PipeStream openErrorSignal handle:[:ex |
- PipeFailed := true.
- 'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
- ex return.
- ] do:[
- "have to fall back ..."
- command := 'cd "' , pathName , '"; pwd'.
- p := PipeStream readingFrom:command.
- ].
-
- (p isNil or:[p atEnd]) ifTrue:[
- ('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
- ] ifFalse:[
- path := p nextLine.
- p close.
- ]
- ].
- path isNil ifTrue:[
- "/
- "/ return the original - there is nothing else can we do
- "/
- path := pathName
- ].
- (SlowFork==true or:[ForkFailed==true]) ifTrue:[
- path := self compressPath:path
- ]
+ (self isValidPath:pathName) ifFalse:[
+ p := pathName.
+ [(p size > 1)
+ and:[p endsWith:(self fileSeparator)]
+ ] whileTrue:[
+ p := p copyWithoutLast:1.
+ ].
+ ^ p
+ ].
+
+ (SlowFork==true or:[PipeFailed==true]) ifFalse:[
+ |directoryName fileBaseName|
+
+ (self isDirectory:pathName) ifTrue:[
+ directoryName := pathName.
+ fileBaseName := nil.
+ ] ifFalse:[
+ |pathFilename|
+ pathFilename := pathName asFilename.
+ directoryName := pathFilename directoryName.
+ fileBaseName := pathFilename baseName.
+ ].
+
+ PipeStream openErrorSignal handle:[:ex |
+ PipeFailed := true.
+ 'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
+ ex return.
+ ] do:[
+ "have to fall back ..."
+ command := 'cd "' , directoryName , '"; pwd'.
+ p := PipeStream readingFrom:command.
+ ].
+
+ (p isNil or:[p atEnd]) ifTrue:[
+ ('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
+ ] ifFalse:[
+ path := p nextLine.
+ p close.
+ ].
+ fileBaseName notNil ifTrue:[
+ path := path, '/', fileBaseName.
+ ].
+ ].
+ path isNil ifTrue:[
+ "/
+ "/ return the original - there is nothing else can we do
+ "/
+ path := pathName
+ ].
+ (SlowFork==true or:[ForkFailed==true]) ifTrue:[
+ path := self compressPath:path
+ ]
].
^ path.
@@ -5169,6 +5184,7 @@
} else {
error = @symbol(argument); // argument is not a string
}
+ fprintf(stderr, "stx[warning]: realpath(\"%s\") failed\n", __stringVal(pathName));
%}.
"/ Does not work as of 2013-04 (UNLIMITEDSTACK problem?)
"/ error notNil ifTrue:[
@@ -13506,11 +13522,11 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.312 2013-04-25 09:23:16 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.313 2013-04-25 11:42:17 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.312 2013-04-25 09:23:16 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.313 2013-04-25 11:42:17 stefan Exp $'
! !