dir

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MimeTypeDirectory is the mime type for directory
	MimeTypeDirectory = "inode/directory"
)
View Source
const (

	// S_IFDIR is the mode for directory
	S_IFDIR = 0040000
)

Variables

View Source
var (
	// ErrInvalidDirectoryName is returned when the directory name is invalid
	ErrInvalidDirectoryName = errors.New("invalid directory name")
	// ErrTooLongDirectoryName is returned when the directory name is too long
	ErrTooLongDirectoryName = errors.New("too long directory name")
	// ErrDirectoryAlreadyPresent is returned when the directory is already present
	ErrDirectoryAlreadyPresent = errors.New("directory name already present")
	// ErrDirectoryNotPresent is returned when the directory is not present
	ErrDirectoryNotPresent = errors.New("directory not present")
	// ErrInvalidFileOrDirectoryName is returned when the file or directory name is invalid
	ErrInvalidFileOrDirectoryName = errors.New("invalid file or directory name")
)
View Source
var (
	// ErrResourceDeleted is returned when the resource is deleted
	ErrResourceDeleted = errors.New("resource was deleted")
)
View Source
var (
	// MetaVersion is the version of the metadata for directories
	MetaVersion uint8 = 2
)

Functions

This section is empty.

Types

type Directory

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

Directory is the type used to define a directory in a pod

func NewDirectory

func NewDirectory(podName string, client blockstore.Client, fd *feed.API, user utils.Address,
	file f.IFile, m taskmanager.TaskManagerGO, logger logging.Logger) *Directory

NewDirectory the main directory object that handles all the directory related functions.

func (*Directory) AddEntryToDir added in v0.5.3

func (d *Directory) AddEntryToDir(parentDir, podPassword, itemToAdd string, isFile bool) error

AddEntryToDir adds a new entry (directory/file) to a given directory. This is typically called when a new directory is created under the given directory or a new file is uploaded under the given directory.

func (*Directory) AddRootDir added in v0.6.2

func (d *Directory) AddRootDir(podName, podPassword string, podAddress utils.Address, fd *feed.API) error

AddRootDir adds the root directory to the directory map

func (*Directory) AddToDirectoryMap

func (d *Directory) AddToDirectoryMap(path string, dirInode *Inode)

AddToDirectoryMap adds a directory in the path

func (*Directory) Chmod added in v0.9.2

func (d *Directory) Chmod(dirNameWithPath, podPassword string, mode uint32) error

Chmod does all the validation for the existence of the file and changes file mode

func (*Directory) DirStat

func (d *Directory) DirStat(podName, podPassword, dirNameWithPath string) (*Stats, error)

DirStat returns all the information related to a given directory.

func (*Directory) GetDirFromDirectoryMap

func (d *Directory) GetDirFromDirectoryMap(path string) *Inode

GetDirFromDirectoryMap returns the directory Inode of the given path

func (*Directory) GetInode added in v0.9.3

func (d *Directory) GetInode(podPassword, dirNameWithPath string) (*Inode, error)

GetInode returns the inode of the given directory

func (*Directory) IsDirectoryPresent added in v0.5.3

func (d *Directory) IsDirectoryPresent(directoryNameWithPath, podPassword string) bool

IsDirectoryPresent this function check if a given directory is present inside the pod.

func (*Directory) ListDir

func (d *Directory) ListDir(dirNameWithPath, podPassword string) ([]Entry, []string, error)

ListDir given a directory, this function lists all the children (directory) inside the given directory. it also creates a list of files inside the directory and gives it back, so that the file listing function can give information about those files.

func (*Directory) MkDir added in v0.5.3

func (d *Directory) MkDir(dirToCreateWithPath, podPassword string, mode uint32) error

MkDir creates a directory in the given path

func (*Directory) MkRootDir added in v0.5.3

func (d *Directory) MkRootDir(podName, podPassword string, podAddress utils.Address, fd *feed.API) error

MkRootDir creates the root directory for the pod

func (*Directory) RemoveAllFromDirectoryMap added in v0.5.3

func (d *Directory) RemoveAllFromDirectoryMap()

RemoveAllFromDirectoryMap resets user dirMap

func (*Directory) RemoveEntryFromDir added in v0.5.3

func (d *Directory) RemoveEntryFromDir(parentDir, podPassword, itemToDelete string, isFile bool) error

RemoveEntryFromDir removes an entry (directory/file) under the given directory. This is typically called when a directory is deleted under the given directory or a file is removed under the given directory.

func (*Directory) RemoveFromDirectoryMap

func (d *Directory) RemoveFromDirectoryMap(path string)

RemoveFromDirectoryMap removes a directory from the path

func (*Directory) RemoveInode added in v0.10.0

func (d *Directory) RemoveInode(podPassword, dirNameWithPath string) error

RemoveInode removes the inode of the given directory

func (*Directory) RenameDir added in v0.9.1

func (d *Directory) RenameDir(dirNameWithPath, newDirNameWithPath, podPassword string) error

RenameDir renames a directory

func (*Directory) RmDir added in v0.5.3

func (d *Directory) RmDir(directoryNameWithPath, podPassword string) error

RmDir removes a given directory and all the entries (file/directory) under that.

func (*Directory) RmRootDir added in v0.7.0

func (d *Directory) RmRootDir(podPassword string) error

RmRootDir removes root directory and all the entries (file/directory) under that.

func (*Directory) SetInode added in v0.10.0

func (d *Directory) SetInode(podPassword string, iNode *Inode) error

SetInode saves the inode of the given directory

func (*Directory) SyncDirectory added in v0.5.3

func (d *Directory) SyncDirectory(dirNameWithPath, podPassword string) error

SyncDirectory syncs all the latest entries under a given directory.

func (*Directory) SyncDirectoryAsync added in v0.9.1

func (d *Directory) SyncDirectoryAsync(ctx context.Context, dirNameWithPath, podPassword string, wg *sync.WaitGroup) error

SyncDirectoryAsync syncs all the latest entries under a given directory concurrently.

type Entry added in v0.5.3

type Entry struct {
	Name             string `json:"name"`
	ContentType      string `json:"contentType"`
	Size             string `json:"size,omitempty"`
	Mode             uint32 `json:"mode"`
	BlockSize        string `json:"blockSize,omitempty"`
	CreationTime     string `json:"creationTime"`
	ModificationTime string `json:"modificationTime"`
	AccessTime       string `json:"accessTime"`
}

Entry is the structure of the directory entry

type Inode added in v0.5.3

type Inode struct {
	Meta           *MetaData `json:"meta"`
	FileOrDirNames []string  `json:"fileOrDirNames"`
}

Inode is the structure of the inode

func (*Inode) GetDirInodePathAndName added in v0.5.3

func (in *Inode) GetDirInodePathAndName() string

GetDirInodePathAndName returns full path of the node from root

func (*Inode) GetDirInodePathAndNameForRoot added in v0.5.3

func (in *Inode) GetDirInodePathAndNameForRoot() string

GetDirInodePathAndNameForRoot returns full path of the root node

func (*Inode) GetDirInodePathOnly added in v0.5.3

func (in *Inode) GetDirInodePathOnly() string

GetDirInodePathOnly returns path of the node

func (*Inode) GetFileOrDirNames added in v0.5.3

func (in *Inode) GetFileOrDirNames() []string

GetFileOrDirNames returns file and folder names in iNode skipcq: TCV-001

func (*Inode) GetMeta added in v0.5.3

func (in *Inode) GetMeta() *MetaData

GetMeta returns iNode metadata skipcq: TCV-001

func (*Inode) IsDirInodeRoot added in v0.5.3

func (in *Inode) IsDirInodeRoot() bool

IsDirInodeRoot check if the node is root dir

func (*Inode) SetFileOrDirNames added in v0.5.3

func (in *Inode) SetFileOrDirNames(fileOrDirNames []string)

SetFileOrDirNames sets file and folder names in iNode skipcq: TCV-001

func (*Inode) Unmarshal added in v0.7.0

func (in *Inode) Unmarshal(data []byte) error

Unmarshal unmarshals the data into iNode

type MetaData added in v0.5.3

type MetaData struct {
	Version          uint8  `json:"version"`
	Path             string `json:"path"`
	Name             string `json:"name"`
	CreationTime     int64  `json:"creationTime"`
	AccessTime       int64  `json:"accessTime"`
	ModificationTime int64  `json:"modificationTime"`
	Mode             uint32 `json:"mode"`
}

MetaData is the metadata of a directory

type Stats added in v0.9.1

type Stats struct {
	PodName          string `json:"podName"`
	DirPath          string `json:"dirPath"`
	DirName          string `json:"dirName"`
	Mode             uint32 `json:"mode"`
	CreationTime     string `json:"creationTime"`
	ModificationTime string `json:"modificationTime"`
	AccessTime       string `json:"accessTime"`
	NoOfDirectories  string `json:"noOfDirectories"`
	NoOfFiles        string `json:"noOfFiles"`
}

Stats represents a given directory

Jump to

Keyboard shortcuts

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