fs

package
v0.0.0-...-ec95f82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

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

func (f *MCFile) Close() error

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.

func (*MCFile) ContentType

func (f *MCFile) ContentType(ctx context.Context) (string, error)

func (*MCFile) Readdir

func (f *MCFile) Readdir(_ int) ([]fs.FileInfo, error)

Readdir returns the list of files or projects for an MCFile.

func (*MCFile) Stat

func (f *MCFile) Stat() (fs.FileInfo, error)

Stat returns the mcfile info as a fs.FileInfo.

func (*MCFile) Write

func (f *MCFile) Write(p []byte) (n int, err error)

Write to the file and update the checksum (hasher) state.

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

func (fs *UserFS) Mkdir(ctx context.Context, path string, perm os.FileMode) error

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) RemoveAll

func (fs *UserFS) RemoveAll(ctx context.Context, name string) error

func (*UserFS) Rename

func (fs *UserFS) Rename(ctx context.Context, oldName, newName string) error

func (*UserFS) ResetState

func (fs *UserFS) ResetState()

func (*UserFS) Stat

func (fs *UserFS) Stat(ctx context.Context, path string) (os.FileInfo, error)

Stat get the stat (os.FileInfo) for a file. It handles "/" and /<project-slug> paths by creating fake entries for them.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL