Skip to content

Commit

Permalink
cloning files now works too
Browse files Browse the repository at this point in the history
  • Loading branch information
scrouthtv committed Oct 14, 2020
1 parent f7509b1 commit 8b887fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
9 changes: 7 additions & 2 deletions src/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ func copyLoop() {
done_amount += 1;
} else if i < len(fileOrder) {
var sourcePath string = fileOrder[i];
var destPath string = filepath.Join(targets[sourcePath],
filepath.Base(sourcePath));
var destPath string;
if createFoldersInTarget {
destPath = filepath.Join(targets[sourcePath],
filepath.Base(sourcePath));
} else {
destPath = targets[sourcePath];
}
filesLock.Unlock();

// check if file already exists and we even care about that:
Expand Down
13 changes: 4 additions & 9 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main;
import "os";
import "sync";
import "path/filepath";
import "fmt";

var createFoldersInTarget bool;

Expand Down Expand Up @@ -77,6 +78,8 @@ func iteratePaths() {
} else if stat.Mode().IsRegular() {
filesLock.Lock();
fileOrder = append(fileOrder, next);
fmt.Println(FGColors.Blue + next);
fmt.Println(uPTargets[next] + Textstyle.Reset);
targets[next] = uPTargets[next];
filesLock.Unlock();
full_size += uint64(stat.Size());
Expand Down Expand Up @@ -110,14 +113,6 @@ func iteratePaths() {
drawLoop();
}

// copy works as follows:
// 1. open source for reading
// 2. stat target,
// if it is file, open it for writing (check if it exists & we want to overwrite)
// if it is directory, create a new file in it with the same name as source
// 3. copy it over
// 4. eventually delete the source file

func main() {
initColors(autoColors());
parseArgs();
Expand Down Expand Up @@ -150,7 +145,7 @@ func main() {
}
}
if len(unsearchedPaths) == 1 {
folders = append(folders, targetBase);
//folders = append(folders, targetBase);
uPTargets[unsearchedPaths[0]] = targetBase;
createFoldersInTarget = false;
} else {
Expand Down

0 comments on commit 8b887fc

Please sign in to comment.