Commit 11e662a2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Rename ReadOnlyFile to DataFile.

parent 9a8313a9
// A Go mirror of libfuse's hello.c
// A Go mirror of libfuse's hello.c
package main
......@@ -44,7 +44,7 @@ func (me *HelloFs) Open(name string, flags uint32, context *fuse.Context) (file
if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
}
return fuse.NewReadOnlyFile([]byte(name)), fuse.OK
return fuse.NewDataFile([]byte(name)), fuse.OK
}
func main() {
......
......@@ -106,7 +106,7 @@ func (me *nonseekFs) Open(name string, flags uint32, context *Context) (fuseFile
}
data := bytes.Repeat([]byte{42}, me.Length)
f := NewReadOnlyFile(data)
f := NewDataFile(data)
return &WithFlags{
File: f,
FuseFlags: FOPEN_NONSEEKABLE,
......
......@@ -8,21 +8,21 @@ import (
var _ = fmt.Println
// ReadOnlyFile is for implementing read-only filesystems. This
// DataFile is for implementing read-only filesystems. This
// assumes we already have the data in memory.
type ReadOnlyFile struct {
type DataFile struct {
data []byte
DefaultFile
}
func NewReadOnlyFile(data []byte) *ReadOnlyFile {
f := new(ReadOnlyFile)
func NewDataFile(data []byte) *DataFile {
f := new(DataFile)
f.data = data
return f
}
func (me *ReadOnlyFile) Read(input *ReadIn, bp BufferPool) ([]byte, Status) {
func (me *DataFile) Read(input *ReadIn, bp BufferPool) ([]byte, Status) {
end := int(input.Offset) + int(input.Size)
if end > len(me.data) {
end = len(me.data)
......
......@@ -28,7 +28,7 @@ func (me *NotifyFs) GetAttr(name string, context *Context) (*os.FileInfo, Status
}
func (me *NotifyFs) Open(name string, f uint32, context *Context) (File, Status) {
return NewReadOnlyFile([]byte{42}), OK
return NewDataFile([]byte{42}), OK
}
type NotifyTest struct {
......
......@@ -45,7 +45,7 @@ func (me *FileSystemDebug) Add(name string, callback getter) {
func (me *FileSystemDebug) Open(path string, flags uint32, context *Context) (fuseFile File, status Status) {
content := me.getContent(path)
if content != nil {
return NewReadOnlyFile(content), OK
return NewDataFile(content), OK
}
return me.FileSystem.Open(path, flags, context)
}
......
......@@ -322,7 +322,7 @@ func (me *AutoUnionFs) Open(path string, flags uint32, context *fuse.Context) (f
if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM
}
return fuse.NewReadOnlyFile([]byte(fuse.Version())), fuse.OK
return fuse.NewDataFile([]byte(fuse.Version())), fuse.OK
}
if path == filepath.Join(_CONFIG, _SCAN_CONFIG) {
if flags&fuse.O_ANYWRITE != 0 {
......
......@@ -89,7 +89,7 @@ func (me *memNode) Open(flags uint32, context *fuse.Context) (fuseFile fuse.File
return nil, fuse.EPERM
}
return fuse.NewReadOnlyFile(me.file.Data()), fuse.OK
return fuse.NewDataFile(me.file.Data()), fuse.OK
}
func (me *memNode) GetAttr(file fuse.File, context *fuse.Context) (*os.FileInfo, fuse.Status) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment