-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split files
- Loading branch information
Showing
20 changed files
with
490 additions
and
82 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
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 |
---|---|---|
|
@@ -19,4 +19,5 @@ type Buffer interface { | |
WriteString(s string) (n int, err error) | ||
Bytes() []byte | ||
String() string | ||
Len() int | ||
} |
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,42 @@ | ||
// ================================================================= | ||
// | ||
// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved | ||
// Released as open source under the MIT License. See LICENSE file. | ||
// | ||
// ================================================================= | ||
|
||
package grw | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
homedir "github.com/mitchellh/go-homedir" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// Mkdirs create the directory at the given path and all parent directories, if they do not exist. | ||
// Mkdirs expands the home directory and resolves the path given. | ||
func Mkdirs(p string) error { | ||
|
||
if len(p) == 0 { | ||
return ErrPathMissing | ||
} | ||
|
||
pathExpanded, err := homedir.Expand(p) | ||
if err != nil { | ||
return errors.Wrapf(err, "error expanding file path %q", p) | ||
} | ||
|
||
pathAbsolute, err := filepath.Abs(pathExpanded) | ||
if err != nil { | ||
return errors.Wrapf(err, "error resolving file path %q", pathAbsolute) | ||
} | ||
|
||
err = os.MkdirAll(pathAbsolute, 0750) | ||
if err != nil { | ||
return errors.Wrapf(err, "error creating parent directories for %q", p) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.