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
5d921aae
Commit
5d921aae
authored
Feb 04, 2011
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and use ReadOnlyFile.
parent
d01aaf4d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
19 deletions
+31
-19
examplelib/zipfs.go
examplelib/zipfs.go
+5
-18
fuse/Makefile
fuse/Makefile
+2
-1
fuse/datafile.go
fuse/datafile.go
+24
-0
No files found.
examplelib/zipfs.go
View file @
5d921aae
...
...
@@ -175,10 +175,8 @@ type ZipFile struct {
fuse
.
DefaultRawFuseFile
}
func
NewZipFile
(
f
*
zip
.
File
)
*
ZipFile
{
z
:=
ZipFile
{
data
:
make
([]
byte
,
f
.
UncompressedSize
),
}
func
NewZipFile
(
f
*
zip
.
File
)
fuse
.
RawFuseFile
{
data
:=
make
([]
byte
,
f
.
UncompressedSize
)
rc
,
err
:=
f
.
Open
()
if
err
!=
nil
{
panic
(
"zip open"
)
...
...
@@ -186,25 +184,14 @@ func NewZipFile(f *zip.File) *ZipFile {
start
:=
0
for
{
n
,
err
:=
rc
.
Read
(
z
.
data
[
start
:
])
n
,
err
:=
rc
.
Read
(
data
[
start
:
])
start
+=
n
if
err
==
os
.
EOF
{
break
}
if
err
!=
nil
&&
err
!=
os
.
EOF
{
panic
(
fmt
.
Sprintf
(
"read err: %v, n %v, sz %v"
,
err
,
n
,
len
(
z
.
data
)))
panic
(
fmt
.
Sprintf
(
"read err: %v, n %v, sz %v"
,
err
,
n
,
len
(
data
)))
}
}
return
&
z
return
fuse
.
NewReadOnlyFile
(
data
)
}
func
(
self
*
ZipFile
)
Read
(
input
*
fuse
.
ReadIn
,
bp
*
fuse
.
BufferPool
)
([]
byte
,
fuse
.
Status
)
{
end
:=
int
(
input
.
Offset
)
+
int
(
input
.
Size
)
if
end
>
len
(
self
.
data
)
{
end
=
len
(
self
.
data
)
}
return
self
.
data
[
input
.
Offset
:
end
],
fuse
.
OK
}
fuse/Makefile
View file @
5d921aae
...
...
@@ -11,7 +11,8 @@ GOFILES=misc.go\
types.go
\
pathfilesystem.go
\
bufferpool.go
\
default.go
default.go
\
datafile.go
include
$(GOROOT)/src/Make.pkg
fuse/datafile.go
0 → 100644
View file @
5d921aae
package
fuse
// A FUSE file for read-only filesystems. This assumes we already have the data in memory.
type
ReadOnlyFile
struct
{
data
[]
byte
DefaultRawFuseFile
}
func
NewReadOnlyFile
(
data
[]
byte
)
*
ReadOnlyFile
{
f
:=
new
(
ReadOnlyFile
)
f
.
data
=
data
return
f
}
func
(
self
*
ReadOnlyFile
)
Read
(
input
*
ReadIn
,
bp
*
BufferPool
)
([]
byte
,
Status
)
{
end
:=
int
(
input
.
Offset
)
+
int
(
input
.
Size
)
if
end
>
len
(
self
.
data
)
{
end
=
len
(
self
.
data
)
}
return
self
.
data
[
input
.
Offset
:
end
],
OK
}
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