-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from filecoin-project/fix/not-cover-config
fix: not set flag value to config
- Loading branch information
Showing
4 changed files
with
110 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func MakeDir(path string) error { | ||
fi, err := os.Stat(path) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
err = os.MkdirAll(path, 0o755) | ||
if err != nil { | ||
return fmt.Errorf("make dir: %w", err) | ||
} | ||
} else { | ||
return fmt.Errorf("stat dir: %w", err) | ||
} | ||
} else { | ||
if !fi.IsDir() { | ||
return fmt.Errorf("path %s is not a dir", path) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func Exist(path string) (bool, error) { | ||
_, err := os.Stat(path) | ||
if err == nil { | ||
return true, nil | ||
} else if !os.IsNotExist(err) { | ||
return false, err | ||
} | ||
return false, nil | ||
} |