mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 09:11:11 +08:00
vfs: add flags parameter to Dir.Create
This commit is contained in:
parent
517bdc719b
commit
a80d8a21dc
|
@ -299,7 +299,7 @@ func (fsys *FS) Create(filePath string, flags int, mode uint32) (errc int, fh ui
|
|||
if errc != 0 {
|
||||
return errc, fhUnset
|
||||
}
|
||||
file, err := parentDir.Create(leaf)
|
||||
file, err := parentDir.Create(leaf, flags)
|
||||
if err != nil {
|
||||
return translateError(err), fhUnset
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ var _ fusefs.NodeCreater = (*Dir)(nil)
|
|||
// Create makes a new file
|
||||
func (d *Dir) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (node fusefs.Node, handle fusefs.Handle, err error) {
|
||||
defer log.Trace(d, "name=%q", req.Name)("node=%v, handle=%v, err=%v", &node, &handle, &err)
|
||||
file, err := d.Dir.Create(req.Name)
|
||||
file, err := d.Dir.Create(req.Name, int(req.Flags))
|
||||
if err != nil {
|
||||
return nil, nil, translateError(err)
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ func (d *Dir) Open(flags int) (fd Handle, err error) {
|
|||
}
|
||||
|
||||
// Create makes a new file node
|
||||
func (d *Dir) Create(name string) (*File, error) {
|
||||
func (d *Dir) Create(name string, flags int) (*File, error) {
|
||||
// fs.Debugf(path, "Dir.Create")
|
||||
if d.vfs.Opt.ReadOnly {
|
||||
return nil, EROFS
|
||||
|
|
|
@ -281,7 +281,7 @@ func TestDirCreate(t *testing.T) {
|
|||
defer r.Finalise()
|
||||
vfs, dir, _ := dirCreate(t, r)
|
||||
|
||||
file, err := dir.Create("potato")
|
||||
file, err := dir.Create("potato", os.O_WRONLY|os.O_CREATE)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(0), file.Size())
|
||||
|
||||
|
@ -306,7 +306,7 @@ func TestDirCreate(t *testing.T) {
|
|||
assert.Equal(t, int64(5), file2.Size())
|
||||
|
||||
vfs.Opt.ReadOnly = true
|
||||
_, err = dir.Create("sausage")
|
||||
_, err = dir.Create("sausage", os.O_WRONLY|os.O_CREATE)
|
||||
assert.Equal(t, EROFS, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ func (vfs *VFS) OpenFile(name string, flags int, perm os.FileMode) (fd Handle, e
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = dir.Create(leaf)
|
||||
node, err = dir.Create(leaf, flags)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user