Documentation ¶
Overview ¶
Package gdrive provides an afero Fs interface to Google Drive API
Index ¶
- Variables
- func IsNotExist(e error) bool
- type APIWrapper
- type DriveAPICallError
- type DriveStreamError
- type File
- func (f *File) AsAfero() afero.File
- func (f *File) Close() error
- func (f *File) Read(p []byte) (int, error)
- func (f *File) ReadAt(p []byte, off int64) (n int, err error)
- func (f *File) Readdir(count int) ([]os.FileInfo, error)
- func (f *File) Readdirnames(n int) ([]string, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (os.FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Truncate(int64) error
- func (f *File) Write(p []byte) (int, error)
- func (f *File) WriteAt(p []byte, off int64) (n int, err error)
- func (f *File) WriteString(s string) (ret int, err error)
- type FileExistError
- type FileHasMultipleEntriesError
- type FileInfo
- func (i *FileInfo) CreateTime() time.Time
- func (i *FileInfo) DriveFile() *drive.File
- func (i *FileInfo) IsDir() bool
- func (i *FileInfo) ModTime() time.Time
- func (i *FileInfo) Mode() os.FileMode
- func (i *FileInfo) Name() string
- func (i *FileInfo) ParentPath() string
- func (i *FileInfo) Path() string
- func (i *FileInfo) Size() int64
- func (i *FileInfo) Sys() interface{}
- type FileIsDirectoryError
- type FileIsNotDirectoryError
- type FileNotExistError
- type GDriver
- func (d *GDriver) AsAfero() afero.Fs
- func (d *GDriver) Chmod(path string, mode os.FileMode) error
- func (d *GDriver) Chown(string, int, int) error
- func (d *GDriver) Chtimes(path string, atime time.Time, mTime time.Time) error
- func (d *GDriver) Create(name string) (afero.File, error)
- func (d *GDriver) DeleteDirectory(path string) error
- func (d *GDriver) ListTrash(filePath string, _ int) ([]*FileInfo, error)
- func (d *GDriver) Mkdir(path string, perm os.FileMode) error
- func (d *GDriver) MkdirAll(path string, _ os.FileMode) error
- func (d *GDriver) Name() string
- func (d *GDriver) Open(name string) (afero.File, error)
- func (d *GDriver) OpenFile(path string, flag int, _ os.FileMode) (afero.File, error)
- func (d *GDriver) Remove(path string) error
- func (d *GDriver) RemoveAll(path string) error
- func (d *GDriver) Rename(oldPath, newPath string) error
- func (d *GDriver) SetRootDirectory(path string) (*FileInfo, error)
- func (d *GDriver) Stat(path string) (os.FileInfo, error)
- type HashMethod
- type NoFileInformationError
- type Option
- type WriteBufferType
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyPath = errors.New("path cannot be empty")
ErrEmptyPath is returned when an empty path is sent
var ErrForbiddenOnRoot = errors.New("forbidden for root directory")
ErrForbiddenOnRoot is returned when an operation is performed on the root node
var ErrInvalidSeek = errors.New("invalid seek offset")
ErrInvalidSeek is returned when the seek operation is not doable
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented is returned when this operation is not (yet) implemented
var ErrNotSupported = errors.New("google drive doesn't support this operation")
ErrNotSupported is returned when this operations is not supported by Google Drive
var ErrOpenMissingFlag = errors.New("you need to specify a read or write flag")
ErrOpenMissingFlag is returned when neither read nor write flags are passed
var ErrReadAndWriteNotSupported = errors.New("option O_RDWR is not supported")
ErrReadAndWriteNotSupported is returned when the O_RDWR flag is passed
var ErrReadOnly = errors.New("we're in a read-only mode")
ErrReadOnly means a write operation was performed on a file opened in read-only
var ErrUnknownBufferType = errors.New("unknown buffer type")
ErrUnknownBufferType is returned when a un unknown buffer is specified
var ErrWriteOnly = errors.New("we're in write-only mode")
ErrWriteOnly means a write operation was performed on a file opened in write-only
Functions ¶
func IsNotExist ¶
IsNotExist returns true if the error is an FileNotExistError
Types ¶
type APIWrapper ¶ added in v0.2.0
type APIWrapper struct { UseCache bool // contains filtered or unexported fields }
APIWrapper allows to wrap some GDrive API calls to perform some caching
func NewAPIWrapper ¶ added in v0.2.0
func NewAPIWrapper(srv *drive.Service, logger log.Logger) *APIWrapper
NewAPIWrapper instantiates a new APIWrapper
func (*APIWrapper) TotalNbCalls ¶ added in v0.2.0
func (a *APIWrapper) TotalNbCalls() int
TotalNbCalls returns the total number of calls performed to the API
type DriveAPICallError ¶
type DriveAPICallError struct {
Err error
}
DriveAPICallError wraps an error that was returned by the Google Drive API
func (*DriveAPICallError) Error ¶
func (e *DriveAPICallError) Error() string
func (*DriveAPICallError) Unwrap ¶
func (e *DriveAPICallError) Unwrap() error
Unwrap exposes the Google Drive API returned error
type DriveStreamError ¶
type DriveStreamError struct {
Err error
}
DriveStreamError wraps an error that happened while using a stream opened from the Google Drive API
func (*DriveStreamError) Error ¶
func (e *DriveStreamError) Error() string
func (*DriveStreamError) Unwrap ¶
func (e *DriveStreamError) Unwrap() error
Unwrap exposes the underlying stream error
type File ¶
type File struct { *FileInfo // FileInfo contains the core fileInfo Path string // Path is the complete path of hte file // contains filtered or unexported fields }
File represents the managed file structure
func (*File) Readdirnames ¶
Readdirnames provides a list of directory names
func (*File) Truncate ¶
Truncate should truncate a file to a specific size. But this method is not supported by the google drive API.
type FileExistError ¶
type FileExistError struct {
Path string
}
FileExistError will be thrown if an File exists
func (FileExistError) Error ¶
func (e FileExistError) Error() string
type FileHasMultipleEntriesError ¶
type FileHasMultipleEntriesError struct {
Path string
}
FileHasMultipleEntriesError will be returned when the same file name is present multiple times in the same directory.
func (FileHasMultipleEntriesError) Error ¶
func (e FileHasMultipleEntriesError) Error() string
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo represents File information for a File or directory
func (*FileInfo) CreateTime ¶
CreateTime returns the time when this File was created
func (*FileInfo) ParentPath ¶
ParentPath returns the parent path of the File or directory
type FileIsDirectoryError ¶
type FileIsDirectoryError struct {
Path string
}
FileIsDirectoryError will be thrown if a File is a directory
func (FileIsDirectoryError) Error ¶
func (e FileIsDirectoryError) Error() string
type FileIsNotDirectoryError ¶
FileIsNotDirectoryError will be thrown if a File is not a directory
func (FileIsNotDirectoryError) Error ¶
func (e FileIsNotDirectoryError) Error() string
type FileNotExistError ¶
type FileNotExistError struct {
Path string
}
FileNotExistError will be thrown if a File was not found
func (FileNotExistError) Error ¶
func (e FileNotExistError) Error() string
type GDriver ¶
type GDriver struct { Logger log.Logger LogReaderAndWriters bool TrashForDelete bool WriteBufferType WriteBufferType WriteBufferSize int // contains filtered or unexported fields }
GDriver can be used to access google drive in a traditional File-folder-path pattern
func New ¶
New creates a new Google Drive driver, client must me an authenticated instance for google drive
func (*GDriver) Create ¶
Create creates a file in the filesystem, returning the file and an error, if any happens.
func (*GDriver) DeleteDirectory ¶
DeleteDirectory will delete a directory and its descendants
func (*GDriver) ListTrash ¶
ListTrash lists the contents of the trash if you specify directories it will only list the trash contents of the specified directories
func (*GDriver) Mkdir ¶
Mkdir creates a directory in the filesystem, return an error if any happens.
func (*GDriver) MkdirAll ¶
MkdirAll creates a directory path and all parents that does not exist yet.
func (*GDriver) Remove ¶
Remove removes a file identified by name, returning an error, if any happens.
func (*GDriver) RemoveAll ¶
RemoveAll will delete a File or directory, if directory it will also delete its descendants
func (*GDriver) SetRootDirectory ¶
SetRootDirectory changes the working root directory use this if you want to do certain operations in a special directory path should always be the absolute real path
type NoFileInformationError ¶
NoFileInformationError is returned when a given directory didn't provide any file info. This error is bit confusing and needs reviewing.
func (NoFileInformationError) Error ¶
func (e NoFileInformationError) Error() string
type Option ¶
Option can be used to pass optional Options to GDriver
func RootDirectory ¶
RootDirectory sets the root directory for all operations
type WriteBufferType ¶ added in v0.2.0
type WriteBufferType string
WriteBufferType defines the type of buffer we want to use to read & write files
const ( // WriteBufferNone means no buffer WriteBufferNone WriteBufferType = "" // WriteBufferSimple means a simple io.Buffer WriteBufferSimple WriteBufferType = "simple" // WriteBufferAsync means an asynchronous io.Buffer WriteBufferAsync WriteBufferType = "async" // WriteBufferChan means an asynchronous channel-based set of buffers WriteBufferChan WriteBufferType = "chan" )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package cache allows to
|
Package cache allows to |
Package iohelper should brings tools to help manage IOs
|
Package iohelper should brings tools to help manage IOs |
Package oauthhelper provide an OAuth2 authentication and token management helper
|
Package oauthhelper provide an OAuth2 authentication and token management helper |
This program helps the setup of credentials for tests
|
This program helps the setup of credentials for tests |