|
@@ -494,9 +494,9 @@ func FileCopy(srcFsh *FileSystemHandler, src string, destFsh *FileSystemHandler,
|
|
|
}
|
|
|
|
|
|
//Check if the copy destination file already have an identical file
|
|
|
- copiedFilename := filepath.Base(src)
|
|
|
+ copiedFilename := arozfs.Base(src)
|
|
|
|
|
|
- if destFshAbs.FileExists(filepath.Join(dest, filepath.Base(src))) {
|
|
|
+ if destFshAbs.FileExists(filepath.Join(dest, arozfs.Base(src))) {
|
|
|
if mode == "" {
|
|
|
//Do not specific file exists principle
|
|
|
return errors.New("Destination file already exists.")
|
|
@@ -507,7 +507,7 @@ func FileCopy(srcFsh *FileSystemHandler, src string, destFsh *FileSystemHandler,
|
|
|
} else if mode == "overwrite" {
|
|
|
//Continue with the following code
|
|
|
//Check if the copy and paste dest are identical
|
|
|
- if filepath.ToSlash(filepath.Clean(src)) == filepath.ToSlash(filepath.Clean(filepath.Join(dest, filepath.Base(src)))) {
|
|
|
+ if filepath.ToSlash(filepath.Clean(src)) == filepath.ToSlash(filepath.Clean(filepath.Join(dest, arozfs.Base(src)))) {
|
|
|
//Source and target identical. Cannot overwrite.
|
|
|
return errors.New("Source and destination paths are identical.")
|
|
|
|
|
@@ -515,12 +515,12 @@ func FileCopy(srcFsh *FileSystemHandler, src string, destFsh *FileSystemHandler,
|
|
|
|
|
|
} else if mode == "keep" {
|
|
|
//Keep the file but saved with 'Copy' suffix
|
|
|
- newFilename := strings.TrimSuffix(filepath.Base(src), filepath.Ext(src)) + " - Copy" + filepath.Ext(src)
|
|
|
+ newFilename := strings.TrimSuffix(arozfs.Base(src), filepath.Ext(src)) + " - Copy" + filepath.Ext(src)
|
|
|
//Check if the newFilename already exists. If yes, continue adding suffix
|
|
|
duplicateCounter := 0
|
|
|
for destFshAbs.FileExists(filepath.Join(dest, newFilename)) {
|
|
|
duplicateCounter++
|
|
|
- newFilename = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src)) + " - Copy(" + strconv.Itoa(duplicateCounter) + ")" + filepath.Ext(src)
|
|
|
+ newFilename = strings.TrimSuffix(arozfs.Base(src), filepath.Ext(src)) + " - Copy(" + strconv.Itoa(duplicateCounter) + ")" + filepath.Ext(src)
|
|
|
if duplicateCounter > 1024 {
|
|
|
//Maxmium loop encountered. For thread safty, terminate here
|
|
|
return errors.New("Too many copies of identical files.")
|