Skip to content

Commit

Permalink
Export Rewrite function and automatically grab File.Info if nil
Browse files Browse the repository at this point in the history
  • Loading branch information
lflare committed Dec 26, 2021
1 parent 3abb816 commit 6a1b4c1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import (

const BLOCKSIZE = 128_000

func rewrite(path string, info os.FileInfo, err error) error {
func Rewrite(path string, info os.FileInfo, err error) error {
// Get file info if empty
if info == nil {
info, err = os.Stat(path)
if err != nil {
return err
}
}

// Return early if error
if err != nil {
return err
Expand Down Expand Up @@ -99,7 +107,7 @@ func rewrite(path string, info os.FileInfo, err error) error {

func main() {
// Get all files and folders
err := filepath.Walk(os.Args[1], rewrite)
err := filepath.Walk(os.Args[1], Rewrite)
if err != nil {
log.Println(err)
}
Expand Down

0 comments on commit 6a1b4c1

Please sign in to comment.