Skip to content

Commit

Permalink
increased readability
Browse files Browse the repository at this point in the history
  • Loading branch information
scrouthtv committed Mar 27, 2021
1 parent b67c302 commit ffb6a11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var buf []byte = make([]byte, buffersize)
*/
func copyLoop() {
var i int = 0

for !done {
filesLock.Lock()
if len(folders) > 0 {
Expand Down Expand Up @@ -209,6 +210,7 @@ func copyFile(source *os.File, dest *os.File, progressStorage *uint64) error {
if err != nil && !errors.Is(err, io.EOF) {
errCopying(source.Name(), dest.Name(), err)
}

if readAmount == 0 {
// when the file is fully read
break
Expand Down
5 changes: 3 additions & 2 deletions delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import "os"

// syncdel deletes a list of files synchronously.
func syncdel(files *[]string) {
var path string
var err error
for _, path = range *files {

for _, path := range *files {
currentTaskType = 4
currentFile = path
err = os.RemoveAll(path)

if err != nil {
errDeletingFile(path, err)
}
Expand Down
13 changes: 9 additions & 4 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ var doReflinks uint8 = 0
var progressLSColors bool = false

func parseKeyValue(key string, value string) {
// Trim away spaces and tabs:
key = strings.ToLower(strings.Trim(key, " \t'\""))
value = strings.ToLower(strings.Trim(value, " \t'\""))

switch key {
case "verbose":
if configInterpretBoolean(value) {
Expand Down Expand Up @@ -100,24 +102,25 @@ func parseKeyValue(key string, value string) {
doReflinks = 2
}
case "buffersize":
var val int
var err error
val, err = strconv.Atoi(value)
val, err := strconv.Atoi(value)
if err == nil {
buffersize = uint(val)
buf = make([]byte, buffersize)
} else {
warnConfig(errors.New("bad value for buffersize: " + value))
}
default:
warnBadConfigKey(key)
}
}

func parseOption(line string) {
var kv []string = strings.Split(line, "=")
kv := strings.Split(line, "=")
if len(kv) != 2 {
warnConfig(errors.New("missing '=' or too many '=' : " + line))
return
}

parseKeyValue(kv[0], kv[1])
}

Expand All @@ -126,6 +129,7 @@ func parseFlag(prefix string, flag string) {
parseOption(flag)
return
}

switch flag {
case "h", "help":
printHelp()
Expand All @@ -135,6 +139,7 @@ func parseFlag(prefix string, flag string) {
os.Exit(0)
case "V", "verbose":
verbose = VerbInfo

verbVerboseEnabled()
case "q", "quiet":
verbose = VerbQuiet
Expand Down

0 comments on commit ffb6a11

Please sign in to comment.