help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Directory create: 'something' "bug"


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Directory create: 'something' "bug"
Date: Wed, 06 Sep 2006 13:28:48 +0200
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

This patch fixes the bug.

Thanks

Paolo
2006-09-06  Paolo Bonzini  <address@hidden>

        * kernel/File.st: Add #pathFor:ifNone:.
        * kernel/Directory.st: Use it in #create:.


--- orig/NEWS
+++ mod/NEWS
@@ -13,6 +13,9 @@ o   Moved gdk_draw_ functions to GdkDraw
 o   Fixed bug in methods containing both -0.0 and 0.0 (positive and negative
     floating-point zero).
 
+o   Fixed bug in Directory class>>#create:, that could not create a
+    directory relative to the current directory.
+
 o   Fixed bug in SortedCollection.  After #removeAtIndex:, adds would leave
     the collection unordered.
 


--- orig/kernel/Directory.st
+++ mod/kernel/Directory.st
@@ -147,7 +147,7 @@ allFilesMatching: aPattern do: aBlock
 
 create: dirName
     "Create a directory named dirName."
-    ^(VFS.VFSHandler for: (File pathFor: dirName))
+    ^(VFS.VFSHandler for: (File pathFor: dirName ifNone: [ Directory working 
]))
        createDir: (File stripPathFrom: dirName)
 ! !
 


--- orig/kernel/File.st
+++ mod/kernel/File.st
@@ -97,18 +97,26 @@ stripPathFrom: aString
     ^aString copyFrom: index + 1 to: aString size
 !
 
-pathFor: aString
+pathFor: aString ifNone: aBlock
     "Determine the path of the name of a file called `aString', and
      answer the result.  With the exception of the root directory, the
-     final slash is stripped."
+     final slash is stripped.  If there is no path, evaluate aBlock and
+     return the result."
     | index |
-    aString isEmpty ifTrue: [ ^'' ].
+    aString isEmpty ifTrue: [ ^aBlock value ].
     index := aString findLast: [ :each | each = Directory pathSeparator ].
-    index = 0 ifTrue: [ ^'' ].
+    index = 0 ifTrue: [ ^aBlock value ].
     index = 1 ifTrue: [ ^Directory pathSeparatorString ].
     ^aString copyFrom: 1 to: index - 1.
 !
 
+pathFor: aString
+    "Determine the path of the name of a file called `aString', and
+     answer the result.  With the exception of the root directory, the
+     final slash is stripped."
+    ^self pathFor: aString ifNone: [ '' ]
+!
+
 stripFileNameFor: aString
     "Determine the path of the name of a file called `aString', and
      answer the result as a directory name including the final slash."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]