@@ -35,10 +35,29 @@ var (
3535 ErrNoLink = fmt .Errorf ("dataset is not linked to the filesystem" )
3636)
3737
38+ // PathPrefix indicates paths that are using file system integration
39+ const PathPrefix = "/fsi"
40+
3841// FilesystemPathToLocal converts a qfs.Filesystem path that has an /fsi prefix
3942// to a local path
4043func FilesystemPathToLocal (qfsPath string ) string {
41- return strings .TrimPrefix (qfsPath , "/fsi" )
44+ return strings .TrimPrefix (qfsPath , PathPrefix )
45+ }
46+
47+ func localPathToFSIPath (absLocalPath string ) string {
48+ if absLocalPath == "" {
49+ return ""
50+ }
51+ if strings .HasPrefix (absLocalPath , PathPrefix ) {
52+ return absLocalPath
53+ }
54+ return fmt .Sprintf ("%s%s" , PathPrefix , absLocalPath )
55+ }
56+
57+ // IsFSIPath is a utility function that returns whether the given path is a
58+ // local filesystem path
59+ func IsFSIPath (path string ) bool {
60+ return strings .HasPrefix (path , PathPrefix )
4261}
4362
4463// GetLinkedFilesysRef returns whether a directory is linked to a dataset in your repo, and
@@ -99,18 +118,12 @@ func (fsi *FSI) ResolvedPath(ref *dsref.Ref) error {
99118 }
100119
101120 if vi .FSIPath != "" {
102- ref .Path = fmt .Sprintf ("/fsi%s" , vi .FSIPath )
121+ ref .Path = fmt .Sprintf ("%s%s" , PathPrefix , vi .FSIPath )
103122 return nil
104123 }
105124 return ErrNoLink
106125}
107126
108- // IsFSIPath is a utility function that returns whether the given path is a
109- // local filesystem path
110- func IsFSIPath (path string ) bool {
111- return strings .HasPrefix (path , "/fsi" )
112- }
113-
114127// ListLinks returns a list of linked datasets and their connected
115128// directories
116129func (fsi * FSI ) ListLinks (offset , limit int ) ([]dsref.VersionInfo , error ) {
0 commit comments