File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ package paths
2
+
3
+ import (
4
+ "io/ioutil"
5
+ "os"
6
+ "runtime"
7
+ )
8
+
9
+ // NullPath return the path to the /dev/null equivalent for the current OS
10
+ func NullPath () * Path {
11
+ if runtime .GOOS == "windows" {
12
+ return New ("nul" )
13
+ }
14
+ return New ("/dev/null" )
15
+ }
16
+
17
+ // TempDir returns the default path to use for temporary files
18
+ func TempDir () * Path {
19
+ return New (os .TempDir ())
20
+ }
21
+
22
+ // MkTempDir creates a new temporary directory in the directory
23
+ // dir with a name beginning with prefix and returns the path of
24
+ // the new directory. If dir is the empty string, TempDir uses the
25
+ // default directory for temporary files
26
+ func MkTempDir (dir , prefix string ) (* Path , error ) {
27
+ path , err := ioutil .TempDir (dir , prefix )
28
+ if err != nil {
29
+ return nil , err
30
+ }
31
+ return New (path ), nil
32
+ }
You can’t perform that action at this time.
0 commit comments