file

package module
v0.0.0-...-c316f6c Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2017 License: MIT Imports: 7 Imported by: 1

README

Local file system implementation for filesystem

This is an implementation of local file access for the filesystem API. It is mostly useful for debugging and development. The scheme used for this implementation is called "file" for mental compatibility with web browsers which also use this scheme.

There currently aren't any supported query flags.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextRespectingIoFile

type ContextRespectingIoFile struct {
	// contains filtered or unexported fields
}

ContextRespectingIoFile represents a regular file object from the OS, but with implementations of respecting deadlines and cancellations from contexts.

func NewContextRespectingIoFile

func NewContextRespectingIoFile(actualFile *os.File) *ContextRespectingIoFile

NewContextRespectingIoFile wraps a regular os.File so we get a context respecting API on it.

func (*ContextRespectingIoFile) Close

Close() provides regular close semantics, but with support for cancelling waiting for closes to finish (which may be important due to caches) or providing deadlines for them.

func (*ContextRespectingIoFile) Read

func (f *ContextRespectingIoFile) Read(ctx context.Context, p []byte) (l int, err error)

Read() provides regular read semantics, but with support for cancelling reads or providing deadlines for them.

func (*ContextRespectingIoFile) Seek

func (f *ContextRespectingIoFile) Seek(
	ctx context.Context, offset int64, whence int) (int64, error)

Seek() sets the current position in the file to the absolute offset specified.

func (*ContextRespectingIoFile) Skip

Skip() skips forward by the specified number of bytes without actually reading the data.

func (*ContextRespectingIoFile) Tell

Tell() determines the current offset inside the file and returns it.

func (*ContextRespectingIoFile) Write

func (f *ContextRespectingIoFile) Write(ctx context.Context, b []byte) (int, error)

Write() provides regular write semantics, but with support for cancelling writes or providing deadlines for them.

type FileAdapter

type FileAdapter struct {
}

File system adapter for local files. See http://github.com/childoftheuniverse/filesystem/ for details of the API and how to use it.

func (*FileAdapter) ListEntries

func (file *FileAdapter) ListEntries(ctx context.Context, dirurl *url.URL) ([]string, error)

ListEntries asynchronously reads the contents of a directory and returns the relative names of files and subdirectories in it. The actual enumeration will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.

func (*FileAdapter) OpenAppender

func (file *FileAdapter) OpenAppender(
	ctx context.Context, fileurl *url.URL) (rc filesystem.WriteCloser, err error)

Asynchronously create a writer writing to the specified file, appending to the end of existent contents. The actual opening will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.

func (*FileAdapter) OpenReader

func (file *FileAdapter) OpenReader(
	ctx context.Context, fileurl *url.URL) (rc filesystem.ReadCloser, err error)

Asynchronously create a reader reading from the specified file. The actual opening will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.

func (*FileAdapter) OpenWriter

func (file *FileAdapter) OpenWriter(
	ctx context.Context, fileurl *url.URL) (rc filesystem.WriteCloser, err error)

Asynchronously create a writer writing to the specified file, overwriting all existent contents. The actual opening will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.

func (*FileAdapter) Remove

func (file *FileAdapter) Remove(ctx context.Context, objurl *url.URL) error

Remove asynchronously deletes the object pointed to from the file system, without touching any entries below it (files, subdirectories). The actual deletion will happen in a subthread so that we have a guaranteed response time from this function in case the operation exceeds the alotted time limits.

func (*FileAdapter) WatchFile

func (file *FileAdapter) WatchFile(ctx context.Context, fileurl *url.URL, notify filesystem.FileWatchFunc) (filesystem.CancelWatchFunc, chan error, error)

Watch for changes affecting the file pointed to. Context is ignored since it probably wouldn't be meaningful in this context. The current state of the file will be notified at first as the initial change.

type FileWatcher

type FileWatcher struct {
	// contains filtered or unexported fields
}

FileWatchers are used for holding all the accounting data necessary to keep track of changes to specific files in the file system. They follow the specified semantics of the filesystem API.

func NewFileWatcher

func NewFileWatcher(ctx context.Context, path *url.URL, cb filesystem.FileWatchFunc) (
	*FileWatcher, error)

NewFileWatcher creates a new FileWatcher watching for any changes in the specified file or, when pointed to a directory, any files inside of it. Changes will be reported using the callback. The initial version of the file is also reported as a change, allowing to use this for e.g. loading a configuration file in case of modifications.

func (*FileWatcher) ErrChan

func (f *FileWatcher) ErrChan() chan error

Accessor method to get the error reporting channel.

func (*FileWatcher) Shutdown

func (f *FileWatcher) Shutdown() error

Shutdown tells the system to stop watching for changes to the file(s) and shuts down the asynchronous change watching thread.

Jump to

Keyboard shortcuts

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