[PATCH] Give error on " directory / '' "

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Give error on " directory / '' "

Paolo Bonzini-2
Empty filenames are bad -- but it turns out that scripts/Package.st was
relying on them in one place.

Paolo

2008-08-06  Paolo Bonzini  <[hidden email]>

        * kernel/FilePath.st: Prohibit accessing files with a '' filename.
        * scripts/Package.st: ... which we were doing here.

diff --git a/kernel/FilePath.st b/kernel/FilePath.st
index b3e11ad..bbad254 100644
--- a/kernel/FilePath.st
+++ b/kernel/FilePath.st
@@ -46,7 +46,9 @@ size and timestamps.'>
 
  <category: 'file name management'>
  directory isEmpty ifTrue: [^fileName].
- fileName isEmpty ifTrue: [^directory].
+ fileName isEmpty ifTrue: [
+    SystemExceptions.InvalidArgument signalOn: fileName
+ reason: 'empty filenames are invalid' ].
  Directory pathSeparator == $\
     ifFalse: [(fileName at: 1) isPathSeparator ifTrue: [^fileName]]
     ifTrue:
diff --git a/scripts/Package.st b/scripts/Package.st
index 94b6660..41c92c0 100644
--- a/scripts/Package.st
+++ b/scripts/Package.st
@@ -432,8 +432,8 @@ Command subclass: PkgInstall [
 
         files := pkg allFiles.
                 dirs := files collect: [ :file | File pathFor: file ].
-        dirs asSet asSortedCollection do: [ :dir |
-            (baseDir / dir) emitMkdir ].
+        (dirs asSet remove: '' ifAbsent: []; asSortedCollection)
+    do: [ :dir | (baseDir / dir) emitMkdir ].
 
                 files do: [ :file || srcFile |
             srcFile := (aPackage fullPathOf: file).

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk