Hi.
The following gives an error: Directory create: 'hello'! while Directory create: './hello'! works. The error is: st> Directory create: 'hello'! Object: '' error: Invalid index 1: index out of range String(Object)>>#primError: SystemExceptions.IndexOutOfRange(Exception)>>#defaultAction optimized [] in Exception class>>#coreException SystemExceptions.IndexOutOfRange(Signal)>>#activateHandler: SystemExceptions.IndexOutOfRange(Exception)>>#signal SystemExceptions.IndexOutOfRange class>>#signalOn:withIndex: String(Object)>>#checkIndexableBounds: String>>#at: File class>>#fullNameFor: VFS.RealFileHandler>>#name: VFS.VFSHandler class>>#for: Directory class>>#create: UndefinedObject>>#executeStatements nil self == bug ifTrue [ 'This is a bugreport' printNl.] ifFalse [ 'What is the reason for this?' printNl.] ! Greetings, Bram _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Wednesday 06 September 2006 19:38, Bram Neijt wrote:
> Hi. > > The following gives an error: > Directory create: 'hello'! > while > Directory create: './hello'! > > works. The error is: > st> Directory create: 'hello'! > Object: '' error: Invalid index 1: index out of range > String(Object)>>#primError: > SystemExceptions.IndexOutOfRange(Exception)>>#defaultAction > optimized [] in Exception class>>#coreException > SystemExceptions.IndexOutOfRange(Signal)>>#activateHandler: > SystemExceptions.IndexOutOfRange(Exception)>>#signal > SystemExceptions.IndexOutOfRange class>>#signalOn:withIndex: > String(Object)>>#checkIndexableBounds: > String>>#at: > File class>>#fullNameFor: > VFS.RealFileHandler>>#name: > VFS.VFSHandler class>>#for: > Directory class>>#create: > UndefinedObject>>#executeStatements > nil > > > self == bug > ifTrue [ 'This is a bugreport' printNl.] > ifFalse [ 'What is the reason for this?' printNl.] ! I did a little investigation, and found following. st> Directory class sourceCodeAt: #create:! 'create: dirName "Create a directory named dirName." ^(VFS.VFSHandler for: (File pathFor: dirName)) createDir: (File stripPathFrom: dirName) ' eventually i tried st> File pathFor: 'foobar'! '' st> File pathFor: './foobar'! '.' and saw that this matched your backtrace :) so, in the end i would say it is intended behaviour, since pathFor just does what it should (if there's no path, why should it make up one?) however, Directory create: should become a little bit more intelligent, since it's clear that if you create a directory without path, it should be the current one. or maybe delegate that down to VFS.VFSHandler #for:createDir: anw, i think that should be fixed, as it may not be a bug, but it's unconvinent and not intuitive :) > VFS.VFSHandler class>>#for: > Directory class>>#create: > > Greetings, > Bram _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
> st> Directory class sourceCodeAt: #create:! > 'create: dirName > "Create a directory named dirName." > ^(VFS.VFSHandler for: (File pathFor: dirName)) > createDir: (File stripPathFrom: dirName) > ' > > eventually i tried > > st> File pathFor: 'foobar'! > '' > st> File pathFor: './foobar'! > '.' > Thanks to both of you! Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Bram Neijt
This patch fixes the bug.
Thanks Paolo 2006-09-06 Paolo Bonzini <[hidden email]> * 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." _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |