Documentation
¶
Index ¶
- type MCFile
- type UserFS
- func (fs *UserFS) Mkdir(ctx context.Context, path string, perm os.FileMode) error
- func (fs *UserFS) OpenFile(ctx context.Context, path string, flags int, perm os.FileMode) (webdav.File, error)
- func (fs *UserFS) RemoveAll(ctx context.Context, name string) error
- func (fs *UserFS) Rename(ctx context.Context, oldName, newName string) error
- func (fs *UserFS) ResetState()
- func (fs *UserFS) Stat(ctx context.Context, path string) (os.FileInfo, error)
- type UserFSOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MCFile ¶
type MCFile struct { // If there is a real file, then this will be non-nil *os.File // contains filtered or unexported fields }
MCFile represents the underlying "/" (root), project, or file/directory in a project. Only a real project file (as opposed to a directory) will have a non-nil os.File.
func (*MCFile) Close ¶
Close will close the underlying os.File if its non-nil. Note that readonly files from UserFS.OpenFile only return a *os.File and not a MCFile. That means that close doesn't need to handle the case where the actually opened file is a file that was only read and not written.
type UserFS ¶
type UserFS struct {
// contains filtered or unexported fields
}
A UserFS represents a virtual fs to a users files and projects. It uses the Materials Commons file and project stors to determine projects, files and access. A UserFS is represented in a path as /<project-slug>/<rest-of-path>, where <project-slug> is the unique slug for a given project. For example /aging-1234/mydir/file.txt represents the path /mydir/file.txt in the project identified by the slug aging-1234.
func NewUserFS ¶
func NewUserFS(opts *UserFSOpts) *UserFS
NewUserFS creates a new UserFS. All the fields in UserFSOpts must be filled in. This is not checked.
func (*UserFS) Mkdir ¶
Mkdir creates a new directory. It determines the project and path from the path.
func (*UserFS) OpenFile ¶
func (fs *UserFS) OpenFile(ctx context.Context, path string, flags int, perm os.FileMode) (webdav.File, error)
OpenFile opens a file project file. It also handles virtual objects that don't actually but are represented in the path. For example "/", which is the base directory, and can be used by WebDAV to get a list of all the project slugs (represented as directories) for a given user. The same for /<project-slug> which represents a particular project with <project-slug> as its slug identifier.
func (*UserFS) ResetState ¶
func (fs *UserFS) ResetState()
type UserFSOpts ¶
type UserFSOpts struct { MCFSRoot string User *mcmodel.User ProjectStor stor.ProjectStor FileStor stor.FileStor ConversionStor stor.ConversionStor }
UserFSOpts are the arguments for creating a new UserFS.