[squeak-dev] The Trunk: Files-eem.137.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Aug 14 23:09:33 UTC 2014


Eliot Miranda uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-eem.137.mcz

==================== Summary ====================

Name: Files-eem.137
Author: eem
Time: 14 August 2014, 4:09:05.676 pm
UUID: 833a2130-ce18-454b-8a67-f82db8a299af
Ancestors: Files-eem.136

Fix UnixFileDirectory directoryExists: & fileOrDirectoryExists:
for cases such as 'foo/bar' '../foo/bar' etc.

=============== Diff against Files-eem.136 ===============

Item was changed:
  ----- Method: UnixFileDirectory>>directoryExists: (in category 'testing') -----
  directoryExists: filenameOrPath
+ 	"Answers true if the directory exists.  Overrides to handle the root directory /
+ 	 and relative paths."
+ 	| fName dir |
- 	"Handles the special case of testing for the root dir: there isn't a
- 	possibility to express the root dir as full pathname like '/foo'."
  
+ 	filenameOrPath = '/' ifTrue:
+ 		[^true].
+ 
+ 	DirectoryClass
+ 		splitName: filenameOrPath
+ 		to: [:filePath :name |
+ 			fName := name.
+ 			dir := filePath isEmpty
+ 					ifTrue: [self]
+ 					ifFalse:
+ 						[FileDirectory on: (filePath first = $/
+ 											ifTrue: [filePath]
+ 											ifFalse: [self fullName, '/', filePath])]].
+ 
+ 	^dir exists
+ 	  and: [(dir directoryEntryForName: fName)
+ 			ifNotNil: [:e| e isDirectory]
+ 			ifNil: [false]]!
- 	^ filenameOrPath = '/' or: [super directoryExists: filenameOrPath]!

Item was changed:
  ----- Method: UnixFileDirectory>>fileOrDirectoryExists: (in category 'testing') -----
+ fileOrDirectoryExists: filenameOrPath
+ 	"Answer true if either a file or a directory file of the given name exists. The given name
+ 	 may be either a full path name or a local name within this directory. Overrides to handle
+ 	 the root directory / and relative paths."
+ 	| fName dir |
- fileOrDirectoryExists: filenameOrPath 
- 	"Handles the special case of testing for the root dir: there isn't a 
- 	possibility to express the root dir as full pathname like '/foo'."
  
+ 	filenameOrPath = '/' ifTrue:
+ 		[^true].
+ 
+ 	DirectoryClass
+ 		splitName: filenameOrPath
+ 		to: [:filePath :name |
+ 			fName := name.
+ 			dir := filePath isEmpty
+ 					ifTrue: [self]
+ 					ifFalse:
+ 						[FileDirectory on: (filePath first = $/
+ 											ifTrue: [filePath]
+ 											ifFalse: [self fullName, '/', filePath])]].
+ 
+ 	^dir exists
+ 	  and: [(dir includesKey: fName) or: [fName isEmpty and: [dir entries size > 1]]]!
- 	^ filenameOrPath = '/' or: [super fileOrDirectoryExists: filenameOrPath]!



More information about the Squeak-dev mailing list