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
8704b7c6
Commit
8704b7c6
authored
Apr 25, 2011
by
Fazlul Shahriar
Committed by
Han-Wen Nienhuys
Apr 25, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zipfs: take care of couple of TODO (better error handling)
parent
fbf3de98
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
12 deletions
+18
-12
example/zipfs/main.go
example/zipfs/main.go
+6
-3
zipfs/multizip.go
zipfs/multizip.go
+3
-3
zipfs/zipfs.go
zipfs/zipfs.go
+5
-5
zipfs/zipfs_test.go
zipfs/zipfs_test.go
+4
-1
No files found.
example/zipfs/main.go
View file @
8704b7c6
...
...
@@ -18,13 +18,16 @@ func main() {
flag
.
Parse
()
if
flag
.
NArg
()
<
2
{
// TODO - where to get program name?
fmt
.
Println
(
"usage: main MOUNTPOINT ZIP-FILE"
)
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: %s MOUNTPOINT ZIP-FILE
\n
"
,
os
.
Args
[
0
])
os
.
Exit
(
2
)
}
var
fs
fuse
.
FileSystem
fs
=
zipfs
.
NewZipArchiveFileSystem
(
flag
.
Arg
(
1
))
fs
,
err
:=
zipfs
.
NewZipArchiveFileSystem
(
flag
.
Arg
(
1
))
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"NewZipArchiveFileSystem failed: %v
\n
"
,
err
)
os
.
Exit
(
1
)
}
debugFs
:=
fuse
.
NewFileSystemDebug
()
if
*
latencies
{
...
...
zipfs/multizip.go
View file @
8704b7c6
...
...
@@ -42,10 +42,10 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f
zipFile
:=
string
(
nameBytes
)
zipFile
=
strings
.
Trim
(
zipFile
,
"
\n
"
)
fs
:=
NewZipArchiveFileSystem
(
zipFile
)
if
fs
=
=
nil
{
fs
,
err
:=
NewZipArchiveFileSystem
(
zipFile
)
if
err
!
=
nil
{
// TODO
log
.
Println
(
"NewZipArchiveFileSystem
returned nil"
)
log
.
Println
(
"NewZipArchiveFileSystem
failed:"
,
err
)
me
.
zfs
.
pendingZips
[
me
.
Basename
]
=
false
,
false
return
0
,
fuse
.
ENOSYS
}
...
...
zipfs/zipfs.go
View file @
8704b7c6
...
...
@@ -100,18 +100,18 @@ func zipFilesToTree(files []*zip.File) *ZipDirTree {
return
t
}
func
NewZipArchiveFileSystem
(
name
string
)
*
ZipArchiveFileSystem
{
// NewZipArchiveFileSystem creates a new file-system for the
// zip file named name.
func
NewZipArchiveFileSystem
(
name
string
)
(
*
ZipArchiveFileSystem
,
os
.
Error
)
{
z
:=
new
(
ZipArchiveFileSystem
)
r
,
err
:=
zip
.
OpenReader
(
name
)
if
err
!=
nil
{
// TODO - return os.Error instead.
log
.
Println
(
"NewZipArchiveFileSystem(): "
+
err
.
String
())
return
nil
return
nil
,
err
}
z
.
ZipFileName
=
name
z
.
zipReader
=
r
z
.
tree
=
zipFilesToTree
(
r
.
File
)
return
z
return
z
,
nil
}
const
zip_DIRMODE
uint32
=
fuse
.
S_IFDIR
|
0700
...
...
zipfs/zipfs_test.go
View file @
8704b7c6
...
...
@@ -9,7 +9,10 @@ import (
func
TestZipFs
(
t
*
testing
.
T
)
{
wd
,
err
:=
os
.
Getwd
()
CheckSuccess
(
err
)
zfs
:=
NewZipArchiveFileSystem
(
wd
+
"/test.zip"
)
zfs
,
err
:=
NewZipArchiveFileSystem
(
wd
+
"/test.zip"
)
if
err
!=
nil
{
t
.
Error
(
"NewZipArchiveFileSystem failed:"
,
err
)
}
connector
:=
fuse
.
NewFileSystemConnector
(
zfs
)
mountPoint
:=
fuse
.
MakeTempDir
()
...
...
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