Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Levin Zimmermann
go-fuse
Commits
f980c761
Commit
f980c761
authored
Jul 04, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Strip slashes from prefixes in SwitchFileSystem.
parent
0a7304c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
fuse/switchfs.go
fuse/switchfs.go
+2
-0
fuse/switchfs_test.go
fuse/switchfs_test.go
+19
-0
No files found.
fuse/switchfs.go
View file @
f980c761
...
...
@@ -53,6 +53,8 @@ func NewSwitchFileSystem(fsMap []SwitchedFileSystem) *SwitchFileSystem {
me
:=
&
SwitchFileSystem
{}
for
_
,
inSwFs
:=
range
fsMap
{
swFs
:=
inSwFs
swFs
.
Prefix
=
strings
.
TrimLeft
(
swFs
.
Prefix
,
string
(
filepath
.
Separator
))
swFs
.
Prefix
=
strings
.
TrimRight
(
swFs
.
Prefix
,
string
(
filepath
.
Separator
))
me
.
fileSystems
=
append
(
me
.
fileSystems
,
&
swFs
)
}
sort
.
Sort
(
me
.
fileSystems
)
...
...
fuse/switchfs_test.go
View file @
f980c761
...
...
@@ -4,6 +4,25 @@ import (
"testing"
)
func
TestSwitchFsSlash
(
t
*
testing
.
T
)
{
fsMap
:=
[]
SwitchedFileSystem
{
SwitchedFileSystem
{
Prefix
:
""
},
SwitchedFileSystem
{
Prefix
:
"/home"
},
SwitchedFileSystem
{
Prefix
:
"usr/"
},
}
sfs
:=
NewSwitchFileSystem
(
fsMap
)
for
path
,
expectPrefix
:=
range
map
[
string
]
string
{
"home/foo/bar"
:
"home"
,
"usr/local"
:
"usr"
,
}
{
_
,
fs
:=
sfs
.
findFileSystem
(
path
)
if
fs
.
Prefix
!=
expectPrefix
{
t
.
Errorf
(
"Mismatch %s - '%s' != '%s'"
,
path
,
fs
.
Prefix
,
expectPrefix
)
}
}
}
func
TestSwitchFs
(
t
*
testing
.
T
)
{
fsMap
:=
[]
SwitchedFileSystem
{
SwitchedFileSystem
{
Prefix
:
""
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment