forked from nilslice/protolock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protopath.go
36 lines (29 loc) · 879 Bytes
/
protopath.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package protolock
import (
"path/filepath"
"strings"
)
const (
// FileSep is the string representation of the OS-specific path separator.
FileSep = string(filepath.Separator)
// ProtoSep is an OS-ambiguous path separator to encode into the proto.lock
// file. Use OsPath and ProtoPath funcs to convert.
ProtoSep = ":/:"
)
// Protopath is a type to assist in OS filepath transformations
type Protopath string
// OSPath converts a path in the Protopath format to the OS path format
func OSPath(ProtoPath Protopath) Protopath {
return Protopath(
strings.Replace(string(ProtoPath), ProtoSep, FileSep, -1),
)
}
// ProtoPath converts a path in the OS path format to Protopath format
func ProtoPath(OSPath Protopath) Protopath {
return Protopath(
strings.Replace(string(OSPath), FileSep, ProtoSep, -1),
)
}
func (p Protopath) String() string {
return string(p)
}