Permalink
Browse files
FileSystem>>move:to: do nothing if the source and destination are the…
- Loading branch information
Showing
with
4 additions
and
2 deletions.
-
+4
−2
src/FileSystem-Core/FileSystem.class.st
|
@@ -610,17 +610,19 @@ FileSystem >> move: sourcePath to: destination [ |
|
|
If destPath is a file, raise FileExists. |
|
|
If destPath is a directory, move the sourcePath in to the directory" |
|
|
|
|
|
| fullDestination | |
|
|
| fullDestination destinationPath | |
|
|
|
|
|
destination isFile ifTrue: [ FileExists signalWith: destination ]. |
|
|
destination isDirectory |
|
|
ifTrue: [ fullDestination := destination / sourcePath basename ] |
|
|
ifFalse: [ fullDestination := destination ]. |
|
|
self = destination fileSystem ifTrue: |
|
|
[ |
|
|
destinationPath := fullDestination resolve path. |
|
|
sourcePath = destinationPath ifTrue: [ ^fullDestination ]. |
|
|
"Ideally we would test whether the source and destination are on the same filesystem from the OSs perspective. |
|
|
Since we can't do that, just try rename, and if that fails, copy and delete." |
|
|
[ self rename: sourcePath to: fullDestination resolve path ] |
|
|
[ self rename: sourcePath to: destinationPath ] |
|
|
on: Error |
|
|
do: [ :error | self copyAndDelete: sourcePath to: fullDestination ]. |
|
|
] ifFalse: |
|
|
0 comments on commit
232472a