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() {
...
@@ -18,13 +18,16 @@ func main() {
flag
.
Parse
()
flag
.
Parse
()
if
flag
.
NArg
()
<
2
{
if
flag
.
NArg
()
<
2
{
// TODO - where to get program name?
fmt
.
Fprintf
(
os
.
Stderr
,
"usage: %s MOUNTPOINT ZIP-FILE
\n
"
,
os
.
Args
[
0
])
fmt
.
Println
(
"usage: main MOUNTPOINT ZIP-FILE"
)
os
.
Exit
(
2
)
os
.
Exit
(
2
)
}
}
var
fs
fuse
.
FileSystem
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
()
debugFs
:=
fuse
.
NewFileSystemDebug
()
if
*
latencies
{
if
*
latencies
{
...
...
zipfs/multizip.go
View file @
8704b7c6
...
@@ -42,10 +42,10 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f
...
@@ -42,10 +42,10 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f
zipFile
:=
string
(
nameBytes
)
zipFile
:=
string
(
nameBytes
)
zipFile
=
strings
.
Trim
(
zipFile
,
"
\n
"
)
zipFile
=
strings
.
Trim
(
zipFile
,
"
\n
"
)
fs
:=
NewZipArchiveFileSystem
(
zipFile
)
fs
,
err
:=
NewZipArchiveFileSystem
(
zipFile
)
if
fs
=
=
nil
{
if
err
!
=
nil
{
// TODO
// TODO
log
.
Println
(
"NewZipArchiveFileSystem
returned nil"
)
log
.
Println
(
"NewZipArchiveFileSystem
failed:"
,
err
)
me
.
zfs
.
pendingZips
[
me
.
Basename
]
=
false
,
false
me
.
zfs
.
pendingZips
[
me
.
Basename
]
=
false
,
false
return
0
,
fuse
.
ENOSYS
return
0
,
fuse
.
ENOSYS
}
}
...
...
zipfs/zipfs.go
View file @
8704b7c6
...
@@ -100,18 +100,18 @@ func zipFilesToTree(files []*zip.File) *ZipDirTree {
...
@@ -100,18 +100,18 @@ func zipFilesToTree(files []*zip.File) *ZipDirTree {
return
t
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
)
z
:=
new
(
ZipArchiveFileSystem
)
r
,
err
:=
zip
.
OpenReader
(
name
)
r
,
err
:=
zip
.
OpenReader
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
// TODO - return os.Error instead.
return
nil
,
err
log
.
Println
(
"NewZipArchiveFileSystem(): "
+
err
.
String
())
return
nil
}
}
z
.
ZipFileName
=
name
z
.
ZipFileName
=
name
z
.
zipReader
=
r
z
.
zipReader
=
r
z
.
tree
=
zipFilesToTree
(
r
.
File
)
z
.
tree
=
zipFilesToTree
(
r
.
File
)
return
z
return
z
,
nil
}
}
const
zip_DIRMODE
uint32
=
fuse
.
S_IFDIR
|
0700
const
zip_DIRMODE
uint32
=
fuse
.
S_IFDIR
|
0700
...
...
zipfs/zipfs_test.go
View file @
8704b7c6
...
@@ -9,7 +9,10 @@ import (
...
@@ -9,7 +9,10 @@ import (
func
TestZipFs
(
t
*
testing
.
T
)
{
func
TestZipFs
(
t
*
testing
.
T
)
{
wd
,
err
:=
os
.
Getwd
()
wd
,
err
:=
os
.
Getwd
()
CheckSuccess
(
err
)
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
)
connector
:=
fuse
.
NewFileSystemConnector
(
zfs
)
mountPoint
:=
fuse
.
MakeTempDir
()
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