Documentation
¶
Index ¶
- Constants
- func ListVaults() ([]string, error)
- func RemoveAll(vault string) error
- func Root() string
- func RootData() string
- func SplitExt(path string) (base, ext string)
- type FileDirectory
- func (fd *FileDirectory) AllFileVersions() ([]FileVersion, error)
- func (fd *FileDirectory) CloseItemVersion(version FileVersion)
- func (fd *FileDirectory) CloseLatestsVersion()
- func (fd *FileDirectory) CreateDirectory() error
- func (fd *FileDirectory) DeleteAll() error
- func (fd *FileDirectory) DeleteVersion(item int16) error
- func (fd FileDirectory) FileList() FileList
- func (fd FileDirectory) ImportNewFile(fname string) error
- func (fd FileDirectory) LatestProperties() []FileProperties
- func (fd *FileDirectory) LatestVersion() FileVersion
- func (fd FileDirectory) NewVersion() (*FileVersion, error)
- func (fd *FileDirectory) OpenItemVersion(version FileVersion)
- func (fd *FileDirectory) OpenLatestsVersion()
- func (fd FileDirectory) Properties(version FileVersion) []FileProperties
- func (fd FileDirectory) SetLatestProperties(props []FileProperties)
- func (fd FileDirectory) SetProperties(version FileVersion, props []FileProperties)
- func (fd FileDirectory) StoreData(version FileVersion, descr, longDescr string)
- type FileIndex
- func (fi *FileIndex) AddItem(dirName, fileName string) (*FileList, error)
- func (fi *FileIndex) ContainerNumberDir(containerNumber string) (string, error)
- func (fi *FileIndex) ContainerNumberRemove(containerNumber string) error
- func (fi *FileIndex) ContainerNumberToFileList(containerNumber string) (FileList, error)
- func (fi *FileIndex) ContainerNumberToFileName(containerNumber string) (string, error)
- func (fi *FileIndex) FileNameToContainerNumber(dir, fileName string) (string, error)
- func (fi *FileIndex) FileNameToFileList(dir, fileName string) (FileList, error)
- func (fi *FileIndex) MoveItem(src FileList, directory string) error
- func (fi *FileIndex) Read() error
- func (fi *FileIndex) Write() error
- type FileInfo
- func (fi FileInfo) Description() string
- func (fi FileInfo) DirSort() int
- func (fi FileInfo) IsDir() bool
- func (fi FileInfo) IsLocked() bool
- func (fi FileInfo) LockedOutBy() string
- func (fi FileInfo) Name() string
- func (fi FileInfo) Path() string
- func (fi FileInfo) Properties() []FileProperties
- func (fi FileInfo) SecondDescription() string
- func (fi FileInfo) String() string
- func (fi FileInfo) Version() string
- type FileList
- type FileProperties
- type FileSystem
- func (fs FileSystem) AbsNormal(absolutePath string) (string, error)
- func (fs *FileSystem) Allocate(dstDir string) (*FileList, error)
- func (fs *FileSystem) Assign(containerNumber, fileName string) error
- func (fs *FileSystem) Chdir(dir string) error
- func (fs *FileSystem) CheckIn(fl FileList, version FileVersion, descr, longdescr string) error
- func (fs *FileSystem) CheckOut(fl FileList, version FileVersion) error
- func (fs *FileSystem) DataWriteFile(name string, data []byte) error
- func (fs FileSystem) DirExists(dir string) bool
- func (fs *FileSystem) DirectoryCopy(src, dst string) error
- func (fs FileSystem) DirectoryRename(src, dst string) error
- func (fs *FileSystem) FileCopy(src, dst string) error
- func (fs *FileSystem) FileRemove(containerNumber string) error
- func (fs *FileSystem) FileRemoveVersion(containerNumber string, version int16) error
- func (fs *FileSystem) FileRename(src, dst string) error
- func (fs FileSystem) GetItem(dir, file string) (FileList, error)
- func (fs FileSystem) Getwd() string
- func (fs *FileSystem) ImportFile(dstDir, fileName string) (*FileList, error)
- func (fs *FileSystem) ImportUrl(dstDir, url string) (*FileList, error)
- func (fs FileSystem) IsLocked(containerNumber string, version FileVersion) string
- func (fs FileSystem) IsLockedItem(containerNumber string) string
- func (fs FileSystem) ListDir(dirName string) ([]FileInfo, error)
- func (fs FileSystem) ListTree(dirName string) ([]FileInfo, error)
- func (fs FileSystem) ListWD() ([]FileInfo, error)
- func (fs FileSystem) Mkdir(dir string) error
- func (fs *FileSystem) NewVersion(fl FileList) (*FileVersion, error)
- func (fs *FileSystem) ReadLockedIndex() error
- func (fs *FileSystem) VaultDir() string
- func (fs *FileSystem) VaultName() string
- func (fs FileSystem) Verify(fl FileList) error
- func (fs *FileSystem) WriteLockedIndex() error
- type FileVersion
- type LockedIndex
Constants ¶
const ( Properties = "Properties.txt" Description = "Description.txt" LongDescription = "LongDescription.txt" Ver = "VER.txt" )
Some handy file names
const ( LockedFileCsv = "LockedFiles.csv" EmptyFile = ".empty_file" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileDirectory ¶
type FileDirectory struct {
// contains filtered or unexported fields
}
File Directory related struct.
func NewFileDirectory ¶
func NewFileDirectory(fs *FileSystem, fl FileList) FileDirectory
Initializes the FileDirectory struct. Parameters: fs is necessary because of this struct containerNumber means the directory in where to put the file structure fileNumber means the file number, which is an int64
func (*FileDirectory) AllFileVersions ¶
func (fd *FileDirectory) AllFileVersions() ([]FileVersion, error)
Returns all file versions name from file or an error.
func (*FileDirectory) CloseItemVersion ¶
func (fd *FileDirectory) CloseItemVersion(version FileVersion)
Closes item number for editing.
func (*FileDirectory) CloseLatestsVersion ¶
func (fd *FileDirectory) CloseLatestsVersion()
Closes the latest version for editing.
func (*FileDirectory) CreateDirectory ¶
func (fd *FileDirectory) CreateDirectory() error
Creates a new directory inside the container directory.
func (*FileDirectory) DeleteAll ¶ added in v0.1.3
func (fd *FileDirectory) DeleteAll() error
Delete all versions and files of the container from disk. Returns nil or an error.
func (*FileDirectory) DeleteVersion ¶
func (fd *FileDirectory) DeleteVersion(item int16) error
TODO: How? Delete one version of the container. Returns nil or an error.
func (FileDirectory) FileList ¶
func (fd FileDirectory) FileList() FileList
Returns the FileList because this field is unexported
func (FileDirectory) ImportNewFile ¶
func (fd FileDirectory) ImportNewFile(fname string) error
Imports a file from an external source.
func (FileDirectory) LatestProperties ¶
func (fd FileDirectory) LatestProperties() []FileProperties
Returns the file properties of the latest version
func (*FileDirectory) LatestVersion ¶
func (fd *FileDirectory) LatestVersion() FileVersion
Returns the latest version.
func (FileDirectory) NewVersion ¶
func (fd FileDirectory) NewVersion() (*FileVersion, error)
Creates a new version from copying the previous version.
func (*FileDirectory) OpenItemVersion ¶
func (fd *FileDirectory) OpenItemVersion(version FileVersion)
Opens the item number for editing. This "Checks Out" the item.
func (*FileDirectory) OpenLatestsVersion ¶
func (fd *FileDirectory) OpenLatestsVersion()
Opens the latest item for editing the SMB mount. This "Checks Out" the item.
func (FileDirectory) Properties ¶
func (fd FileDirectory) Properties(version FileVersion) []FileProperties
Returns the file properties of the specific version
func (FileDirectory) SetLatestProperties ¶
func (fd FileDirectory) SetLatestProperties(props []FileProperties)
Sets the file properties of the latest version
func (FileDirectory) SetProperties ¶
func (fd FileDirectory) SetProperties(version FileVersion, props []FileProperties)
Sets the file properties of the specific version
func (FileDirectory) StoreData ¶
func (fd FileDirectory) StoreData(version FileVersion, descr, longDescr string)
Stores the description and long description text.
type FileIndex ¶
type FileIndex struct {
// contains filtered or unexported fields
}
File Index Files in the root
func NewFileIndex ¶
func NewFileIndex(fs *FileSystem) (fi FileIndex, err error)
func (*FileIndex) AddItem ¶
Adds the filename to the filelist. Returns the index number, and an error. It does not add a file on disk.
func (*FileIndex) ContainerNumberDir ¶
Returns the complete directory name of a container number, or an error when not found.
func (*FileIndex) ContainerNumberRemove ¶ added in v0.1.3
Removes the container number from the list, or an error.
func (*FileIndex) ContainerNumberToFileList ¶
Returns the FileList struct from an container number, or an error when not found.
func (*FileIndex) ContainerNumberToFileName ¶
Returns the file name of a container number.
func (*FileIndex) FileNameToContainerNumber ¶
Returns the index number of the file name in directory, or an error when the file is not found.
func (*FileIndex) FileNameToFileList ¶
Input parameter is the file name. Returns the FileList and an error when not found.
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
The FileInfo struct
func (FileInfo) Description ¶
func (FileInfo) LockedOutBy ¶
func (FileInfo) Properties ¶
func (fi FileInfo) Properties() []FileProperties
func (FileInfo) SecondDescription ¶
type FileList ¶
type FileList struct { ContainerNumber string Name string PreviousName string Path string PreviousPath string }
The FileList is a struct with five fields: * The container number. * The file name. * The previous name of the file. * The dir name of the storage. This is an offset of "mainPdmDir". * The previous directory name.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
File System related Class
func NewFileSystem ¶
func NewFileSystem(vaultDir, userName string) (fs *FileSystem, err error)
Constructor
func (FileSystem) AbsNormal ¶
func (fs FileSystem) AbsNormal(absolutePath string) (string, error)
AbsNormal returns a "normalized" path, with the offset from the vault directory
func (*FileSystem) Allocate ¶ added in v0.1.3
func (fs *FileSystem) Allocate(dstDir string) (*FileList, error)
Allocates an empty file container. This can be handy if you want to setup a structure. The new container inside the PDM gets a revision number automatically and is checked out. The function returns the FileList structure of the imported file or an error.
func (*FileSystem) Assign ¶ added in v0.1.3
func (fs *FileSystem) Assign(containerNumber, fileName string) error
Assigns the file name to the container. The new container inside the PDM gets a revision number automatically. The function returns the FileList structure of the imported file or an error.
func (*FileSystem) Chdir ¶
func (fs *FileSystem) Chdir(dir string) error
Chdir creates a directory or an error
func (*FileSystem) CheckIn ¶
func (fs *FileSystem) CheckIn(fl FileList, version FileVersion, descr, longdescr string) error
Checkin means unlocking a container number. The description and long description are meant for storage.
func (*FileSystem) CheckOut ¶
func (fs *FileSystem) CheckOut(fl FileList, version FileVersion) error
Checkout means locking a conainer number so that only you can use it.
func (*FileSystem) DataWriteFile ¶ added in v0.1.3
func (fs *FileSystem) DataWriteFile(name string, data []byte) error
Writes a file in a read-only directory structure
func (*FileSystem) DirectoryCopy ¶
func (fs *FileSystem) DirectoryCopy(src, dst string) error
Copy a directory.
func (FileSystem) DirectoryRename ¶
func (fs FileSystem) DirectoryRename(src, dst string) error
Move a directory.
func (*FileSystem) FileCopy ¶
func (fs *FileSystem) FileCopy(src, dst string) error
Copy the latest file from src to dst and returns an error.
func (*FileSystem) FileRemove ¶ added in v0.1.3
func (fs *FileSystem) FileRemove(containerNumber string) error
Removes the container from disk. Returns nil or an error.
func (*FileSystem) FileRemoveVersion ¶ added in v0.1.3
func (fs *FileSystem) FileRemoveVersion(containerNumber string, version int16) error
Removes the version of a container from disk. Returns nil or an error.
func (*FileSystem) FileRename ¶
func (fs *FileSystem) FileRename(src, dst string) error
Rename a file, for instance when the user wants to use a file with a specified numbering system
func (FileSystem) GetItem ¶
func (fs FileSystem) GetItem(dir, file string) (FileList, error)
Returns the number of an item
func (*FileSystem) ImportFile ¶
func (fs *FileSystem) ImportFile(dstDir, fileName string) (*FileList, error)
import a file inside the PDM. The file name needs to be complete. When you import a file the attributes also gets imported, which means uploaded to the server. When you import a file or files you are placing the new file in the directory dstDir. The new file inside the PDM gets a revision number automatically. The function returns the FileList structure of the imported file or an error.
func (*FileSystem) ImportUrl ¶
func (fs *FileSystem) ImportUrl(dstDir, url string) (*FileList, error)
import a url inside the PDM. For the rest it works the same as ImportFile()
func (FileSystem) IsLocked ¶
func (fs FileSystem) IsLocked(containerNumber string, version FileVersion) string
Check whether the conatiner number is locked. Returns the name of the user who locked it or empty when not locked.
func (FileSystem) IsLockedItem ¶
func (fs FileSystem) IsLockedItem(containerNumber string) string
Check whether the container number is locked. Returns the name of the user who locked it or empty when not locked.
func (FileSystem) ListDir ¶
func (fs FileSystem) ListDir(dirName string) ([]FileInfo, error)
ListDir lists the sorted directories and files within the specified directory name, as long as the directory is inside the vault.
func (FileSystem) ListTree ¶
func (fs FileSystem) ListTree(dirName string) ([]FileInfo, error)
ListTree lists the sorted directories and files within the specified directory name, including subdirectories, as long as the directory is inside the vault.
func (FileSystem) ListWD ¶
func (fs FileSystem) ListWD() ([]FileInfo, error)
ListWD lists the sorted directories and files of the current working directory.
func (FileSystem) Mkdir ¶
func (fs FileSystem) Mkdir(dir string) error
Creates a new directory inside the current directory, with the correct uid and gid.
func (*FileSystem) NewVersion ¶
func (fs *FileSystem) NewVersion(fl FileList) (*FileVersion, error)
Generates a new version of a file. Returns the FileVersion and an error.
func (*FileSystem) ReadLockedIndex ¶
func (fs *FileSystem) ReadLockedIndex() error
Updates the locked index by reading from the lockedTxt file.
func (*FileSystem) VaultName ¶
func (fs *FileSystem) VaultName() string
VaultName returns the name of the current vault
func (FileSystem) Verify ¶
func (fs FileSystem) Verify(fl FileList) error
Verifies wether the operation succeeded well. It checks the location and also the entry inside the FileList.
func (*FileSystem) WriteLockedIndex ¶
func (fs *FileSystem) WriteLockedIndex() error
type FileVersion ¶
File versions struct
field: 'number', an increment field: 'pretty' means a version presentation, such as A.1, 2.5.0, 4.0, 3 or A.
See https://github.com/grd/FreePDM/discussions/93 for a proposal
TODO This functionality hasn't been implemented yet...
For the time being it just reports the string presentation of 'number'
field: 'date' means the time of a new version with the format "YYYY-MM-DD H:M:S"
type LockedIndex ¶
type LockedIndex struct {
// contains filtered or unexported fields
}
LockedIndex is the list of locked files