fs

package module
v0.0.0-...-3ef35b6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

FS Abstraction Layer

Project status Proposal
API Status Not frozen

Reasons

In development you need to manage file uploads in different environments. Different environments means different disks, raids or even different storage providers.

But every storage provider provides same features and ideas: the same "read file", "open dir", "created at", "modified at", "create file", etc.

I didn't find a solution made in a way I need it, so I decided to build my own.

Main idea of FS Abstraction Layer is to provide simple library that will allow to plug-in complex storage providers like Akamai NetStorage or AWS S3 without need to change any source code except configuration files.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic interface {
	DirExists(path string) (exists bool, err error)
	ReadFile(path string) (body []byte, err error)
	OpenFile(path string) (f File, err error)

	FileExists(path string) (exists bool, err error)
	ReadFilesInDir(path string) (files []File, err error)
	OpenDir(path string) (d Dir)

	Chroot(path string) Basic
}

type Chmoder

type Chmoder interface {
	Chmod(path string, perm os.FileMode) (changed bool, err error)
}

type Chowner

type Chowner interface {
	Chown(path string, uid interface{}, gid interface{}) (changed bool, err error)
}

type Dir

type Dir interface {
	Object

	CreateFile(path string, perm os.FileMode, body ...[]byte) (f File, err error)
	CreateDir(path string, perm os.FileMode) (d Dir, err error)
	Read() ([]Object, error)
	ReadFiles() ([]File, error)
}

type File

File interface describes a generic file methods.

type Object

type Object interface {
	CreatedAt() time.Time
	UpdatedAt() time.Time
	Readable() (bool, error)
	Writeable() (bool, error)

	IsFile() (f File, ok bool)
	IsDir() (d Dir, ok bool)
}

type Permissions

type Permissions interface {
	Permissions() os.FileMode
}

type Unchrooter

type Unchrooter interface {
	Unchroot(path string)
}

Jump to

Keyboard shortcuts

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