Skip to content

Commit

Permalink
Ignore symlinks in basic copy/move methods
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Sep 11, 2021
1 parent 80cf6de commit f6ab600
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# fsutil



This cross-platform go module provides a lightweight abstraction of common file system methods:

- `Touch(path string)`: Like the Unix [touch command](https://en.wikipedia.org/wiki/Touch_(command)). Returns a string with the absolute path of the file/directory.
Expand All @@ -19,8 +17,8 @@ This cross-platform go module provides a lightweight abstraction of common file
- `ByteSize(path string)`: Determines the size (in bytes) of a file or directory.
- `Size(path string, decimalPlaces int)`: A "pretty" label for the size of a file or directory. For example, `3.14MB`.
- `FormatSize(size int64, decimalPlaces int)`: Pretty-print the byte size, i.e. `3.14MB`.
- `Copy(source string, target string) error`: Copy a file/directory contents.
- `Move(source string, target string) error`: Move a file/directory contents.
- `Copy(source string, target string) error`: Copy a file/directory contents. Ignores symlinks.
- `Move(source string, target string) error`: Move a file/directory contents. Ignores symlinks.

## Example

Expand Down
4 changes: 2 additions & 2 deletions fsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func Move(source string, dest string) error {

if info.IsDir() {
Touch(target)
} else {
} else if !IsSymlink(path) {
err := os.Rename(path, target)
if err != nil {
return err
Expand All @@ -475,7 +475,7 @@ func Copy(source string, dest string) error {

if info.IsDir() {
Touch(target)
} else {
} else if !IsSymlink(path) {
input, err := ioutil.ReadFile(path)
if err != nil {
return err
Expand Down

0 comments on commit f6ab600

Please sign in to comment.