Documentation ¶
Index ¶
- Variables
- func DefaultUrlMIME() *types.MIME
- func Exists(fileName string) bool
- func Ext(m *types.MIME) string
- func Header(f *types.FileItem) textproto.MIMEHeader
- func IsAudio(m *types.MIME) bool
- func IsFile(fileName string) bool
- func IsImage(m *types.MIME) bool
- func IsMedia(m *types.MIME) bool
- func IsPDF(m *types.MIME) bool
- func IsUrl(m *types.MIME) bool
- func IsVideo(m *types.MIME) bool
- func NewFileItem(path string, tbuf []byte) (*types.Payload_Item, error)
- func NewMime(path string) (*types.MIME, error)
- func NewThumbnail(path string, tbuf []byte, mime *types.MIME, ch chan *types.Thumbnail)
- func PermitsThumbnail(m *types.MIME) bool
- func SetPathFromFolder(f *types.FileItem, folder Folder) (string, error)
- func ToTransferItem(f *types.FileItem) *types.Payload_Item
- type FilePathOptFunc
- type FilePathOption
- type Folder
- func (f Folder) Create(fileName string) (*os.File, error)
- func (f Folder) CreateFolder(dirName string) (Folder, error)
- func (f Folder) Delete(fileName string) error
- func (f Folder) Exists(fileName string) bool
- func (f Folder) GenPath(path string, opts ...FilePathOption) (string, error)
- func (f Folder) JoinPath(ps ...string) string
- func (f Folder) MkdirAll() error
- func (f Folder) Path() string
- func (f Folder) ReadFile(fileName string) ([]byte, error)
- func (f Folder) WriteFile(fileName string, data []byte) error
- type Role
Constants ¶
This section is empty.
Variables ¶
var ( ErrParentDirNotExists = errors.New("FileItem's Parent Directory does not exist") ErrEmptyData = errors.New("Passed Buffer is Empty") )
var ( // Determined/Provided Paths Home Folder // ApplicationDocumentsDir on Mobile, HOME_DIR on Desktop Support Folder // AppSupport Directory Temporary Folder // AppCache Directory // Calculated Paths Database Folder // Device DB Folder Downloads Folder // Temporary Directory on Mobile for Export, Downloads on Desktop Wallet Folder // Encrypted Storage Directory ThirdParty Folder // Sub-Directory of Support, used for Textile // Path Manipulation Errors ErrDuplicateFilePathOption = errors.New("Duplicate file path option") ErrPrefixSuffixSetWithReplace = errors.New("Prefix or Suffix set with Replace.") ErrSeparatorLength = errors.New("Separator length must be 1.") ErrNoFileNameSet = errors.New("File name was not set by options.") // Device ID Errors ErrEmptyDeviceID = errors.New("Device ID cannot be empty") ErrMissingEnvVar = errors.New("Cannot set EnvVariable with empty value") // Directory errors ErrDirectoryInvalid = errors.New("Directory Type is invalid") ErrDirectoryUnset = errors.New("Directory path has not been set") ErrDirectoryJoin = errors.New("Failed to join directory path") )
Functions ¶
func DefaultUrlMIME ¶ added in v0.18.2
** ─────────────────────────────────────────────────────── ** ─── MIME Management ─────────────────────────────────── ** ─────────────────────────────────────────────────────── DefaultUrlMIME is the standard MIME type for URLs
func Header ¶ added in v0.18.2
func Header(f *types.FileItem) textproto.MIMEHeader
Header returns the header of the FileItem
func NewFileItem ¶ added in v0.18.2
func NewFileItem(path string, tbuf []byte) (*types.Payload_Item, error)
NewFileItem creates a new transfer file item
func NewThumbnail ¶ added in v0.18.2
NewThumbnail creates a new thumbnail for the given file
func PermitsThumbnail ¶ added in v0.18.2
PermitsThumbnail Checks if Mime Type Allows Thumbnail Generation. Image, Video, Audio, and PDF are allowed.
func SetPathFromFolder ¶ added in v0.18.2
SetPathFromFolder sets the path of the FileItem
func ToTransferItem ¶ added in v0.18.2
func ToTransferItem(f *types.FileItem) *types.Payload_Item
ToTransferItem Returns Transfer for FileItem
Types ¶
type FilePathOptFunc ¶
type FilePathOptFunc func(path string) FilePathOption
FilePathOptFunc is a function that returns a FilePathOption.
var WithPrefix FilePathOptFunc = func(path string) FilePathOption {
return &filePathOpt{
filePathOptType: filePathOptionTypePrefix,
value: path,
}
}
WithPrefix sets the prefix for the file path.
var WithReplace FilePathOptFunc = func(path string) FilePathOption {
return &filePathOpt{
filePathOptType: filePathOptionTypeReplace,
value: path,
}
}
WithReplace sets the replace string for the file path.
var WithSeparator FilePathOptFunc = func(path string) FilePathOption {
return &filePathOpt{
filePathOptType: filePathOptionTypeSeparator,
value: path,
}
}
WithSeparator sets the separator for the file path.
var WithSuffix FilePathOptFunc = func(path string) FilePathOption {
return &filePathOpt{
filePathOptType: filePathOptionTypeSuffix,
value: path,
}
}
WithSuffix sets the suffix for the file path.
type FilePathOption ¶
type FilePathOption interface {
Apply() *filePathOptions
}
FilePathOption is a function option for FilePath.
type Folder ¶
type Folder string
func (Folder) CreateFolder ¶
CreateFolder creates a folder.
func (Folder) GenPath ¶
func (f Folder) GenPath(path string, opts ...FilePathOption) (string, error)
GenPath generates a path from a folder and a file name.