--- a/Filename.st Fri Oct 28 08:45:38 2011 +0100
+++ b/Filename.st Mon Oct 31 22:19:21 2011 +0000
@@ -793,7 +793,15 @@
].
].
tempDir isNil ifTrue:[
- tempDir := self named:(self defaultTempDirectoryName pathName)
+ tempDir := self named:(self defaultTempDirectoryName pathName).
+ tempDir exists ifFalse:[
+ tempDir
+ makeDirectory;
+ addAccessRights:#(readUser readGroup readOthers
+ writeUser writeGroup writeOthers
+ executeUser executeGroup executeOthers
+ removeOnlyByOwner).
+ ].
].
TempDirectory := DefaultTempDirectory := tempDir construct:'stx_tmp'.
].
@@ -822,7 +830,7 @@
"
"Created: / 07-03-1996 / 14:51:18 / cg"
- "Modified: / 29-08-2006 / 12:57:16 / cg"
+ "Modified: / 07-10-2011 / 18:39:25 / cg"
!
tempDirectory:aFilename
@@ -2847,6 +2855,56 @@
"
!
+new_recursiveRemoveAll
+ "Remove all of my subfiles/subdirectories.
+ Raise an error if not successful.
+ This one walks down the directory hierarchy, not using any OS
+ command to do the remove."
+
+ |files toRemove fileToRemove|
+
+ self isDirectory ifFalse:[^ self].
+ files := self directoryContentsAsFilenames.
+ files isEmpty ifTrue:[^ self].
+
+ toRemove := OrderedCollection new.
+ toRemove addAll:files.
+ [ toRemove notEmpty ] whileTrue:[
+ fileToRemove := toRemove removeLast.
+ Error handle:[:ex |
+ |children|
+
+ fileToRemove isDirectory ifTrue:[
+ children := fileToRemove directoryContentsAsFilenames.
+ children isEmpty ifTrue:[
+ fileToRemove remove
+ ] ifFalse:[
+ toRemove add:fileToRemove.
+ toRemove addAll:children.
+ ].
+ ] ifFalse:[
+ ex reject
+ ].
+ ] do:[
+ "/ Transcript showCR:('remove: ', fileToRemove pathName).
+ fileToRemove remove.
+ ].
+ ].
+
+ "
+ 'foo' asFilename makeDirectory.
+ 'foo/bar' asFilename writeStream close.
+ 'foo' asFilename remove
+ "
+ "
+ 'foo' asFilename makeDirectory.
+ 'foo/bar' asFilename writeStream close.
+ 'foo' asFilename recursiveRemove
+ "
+
+ "Created: / 11-10-2011 / 10:28:09 / cg"
+!
+
recursiveCopyTo:destination
"if I represent a regular file, copy it.
Otherwise, copy the directory and recursively
@@ -3035,7 +3093,8 @@
This one walks down the directory hierarchy, not using any OS
command to do the remove."
- self recursiveRemoveAll.
+ self new_recursiveRemoveAll.
+ "/ self recursiveRemoveAll.
self remove
"
@@ -3050,7 +3109,7 @@
"
"Created: / 25-02-1998 / 19:50:40 / cg"
- "Modified: / 25-01-2011 / 16:42:24 / cg"
+ "Modified: / 11-10-2011 / 10:29:20 / cg"
!
remove
@@ -3061,15 +3120,17 @@
|linkInfo osName ok|
osName := self osNameForFile.
- linkInfo := self linkInfo.
- (linkInfo notNil and:[linkInfo isDirectory]) ifTrue:[
- ok := OperatingSystem removeDirectory:osName
- ] ifFalse:[
- ok := OperatingSystem removeFile:osName
- ].
- ok ifFalse:[
- self exists ifTrue:[
- self removeError:self
+ (ok := OperatingSystem removeFile:osName) ifFalse:[
+ linkInfo := self linkInfo.
+ (linkInfo notNil and:[linkInfo isDirectory]) ifTrue:[
+ ok := OperatingSystem removeDirectory:osName
+"/ ] ifFalse:[
+"/ ok := OperatingSystem removeFile:osName
+ ].
+ ok ifFalse:[
+ self exists ifTrue:[
+ self removeError:self
+ ]
]
].
@@ -3085,8 +3146,8 @@
'foo' asFilename recursiveRemove.
"
- "Modified: / 20.11.1997 / 17:40:22 / stefan"
- "Modified: / 5.5.1999 / 13:41:12 / cg"
+ "Modified: / 20-11-1997 / 17:40:22 / stefan"
+ "Modified: / 11-10-2011 / 10:20:01 / cg"
!
removeDirectory
@@ -4175,7 +4236,7 @@
'smalltalk.rc' asFilename mimeTypeFromName
'bitmaps/SBrowser.xbm' asFilename mimeTypeFromName
'../../rules/stmkmf' asFilename mimeTypeFromName
- '/bläh' asFilename mimeTypeFromName
+ '/blh' asFilename mimeTypeFromName
'/x.zip' asFilename mimeTypeFromName
'/x.gz' asFilename mimeTypeFromName
"
@@ -4294,7 +4355,7 @@
'smalltalk.rc' asFilename mimeTypeOfContents
'bitmaps/SBrowser.xbm' asFilename mimeTypeOfContents
'../../rules/stmkmf' asFilename mimeTypeOfContents
- '/bläh' asFilename mimeTypeOfContents
+ '/blh' asFilename mimeTypeOfContents
'C:\Dokumente und Einstellungen\cg\Favoriten\languages.lnk' asFilename mimeTypeOfContents
'G:\A\A01.TOP' asFilename mimeTypeOfContents
"
@@ -5837,15 +5898,16 @@
!Filename class methodsFor:'documentation'!
version
- ^ '$Id: Filename.st 10700 2011-09-29 15:44:37Z vranyj1 $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.371 2011/10/19 14:55:37 cg Exp $'
!
version_CVS
- ^ '§Header: /cvs/stx/stx/libbasic/Filename.st,v 1.367 2011/09/07 10:22:02 cg Exp §'
+ ^ 'Header: /cvs/stx/stx/libbasic/Filename.st,v 1.371 2011/10/19 14:55:37 cg Exp '
!
version_SVN
- ^ '$Id: Filename.st 10700 2011-09-29 15:44:37Z vranyj1 $'
+ ^ '$Id: Filename.st 10729 2011-10-31 22:19:21Z vranyj1 $'
! !
Filename initialize!
+