Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Directory ¶
type Directory interface { Chmod(ctx context.Context, chmodOptions *filesoptions.ChmodOptions) (err error) CopyContentToDirectory(ctx context.Context, destinationDir Directory) (err error) Create(ctx context.Context, options *filesoptions.CreateOptions) (err error) CreateSubDirectory(ctx context.Context, subDirectoryName string, options *filesoptions.CreateOptions) (createdSubDirectory Directory, err error) Delete(ctx context.Context, options *filesoptions.DeleteOptions) (err error) Exists(ctx context.Context) (exists bool, err error) GetBaseName() (baseName string, err error) GetDirName() (dirName string, err error) GetFileInDirectory(pathToFile ...string) (file File, err error) GetHostDescription() (hostDescription string, err error) // Returns the path on the local machine. If the path is not available locally an error is returned. GetLocalPath() (localPath string, err error) GetParentDirectory() (parentDirectory Directory, err error) // Returns the absolute path to the file without any indication of the host. GetPath() (dirPath string, err error) // TODO rename GetSubDirectory with GetDirectoryByPath to make it consistent. GetSubDirectory(path ...string) (subDirectory Directory, err error) IsLocalDirectory() (isLocalDirectory bool, err error) ListFiles(ctx context.Context, listFileOptions *parameteroptions.ListFileOptions) (files []File, err error) ListSubDirectories(options *parameteroptions.ListDirectoryOptions) (subDirectories []Directory, err error) // All methods below this line can be implemented by embedding the `DirectoryBase` struct: CheckExists(ctx context.Context) (err error) CreateFileInDirectory(ctx context.Context, path string, options *filesoptions.CreateOptions) (createdFile File, err error) GetFilePathInDirectory(path ...string) (filePath string, err error) GetPathAndHostDescription() (dirPath string, hostDescription string, err error) DeleteFilesMatching(ctx context.Context, listFileOptons *parameteroptions.ListFileOptions) (err error) FileInDirectoryExists(ctx context.Context, path ...string) (exists bool, err error) ListFilePaths(ctx context.Context, listFileOptions *parameteroptions.ListFileOptions) (filePaths []string, err error) ListSubDirectoryPaths(options *parameteroptions.ListDirectoryOptions) (subDirectoryPaths []string, err error) ReadFileInDirectoryAsInt64(path ...string) (content int64, err error) ReadFileInDirectoryAsLines(path ...string) (content []string, err error) ReadFileInDirectoryAsString(path ...string) (content string, err error) ReadFirstLineOfFileInDirectoryAsString(path ...string) (firstLine string, err error) WriteStringToFile(ctx context.Context, path string, content string, options *filesoptions.WriteOptions) (writtenFile File, err error) }
type File ¶
type File interface { AppendBytes(toWrite []byte, verbose bool) (err error) AppendString(toWrite string, verbose bool) (err error) Chmod(ctx context.Context, options *filesoptions.ChmodOptions) (err error) Chown(options *parameteroptions.ChownOptions) (err error) CopyToFile(destFile File, verbose bool) (err error) Create(ctx context.Context, options *filesoptions.CreateOptions) (err error) Delete(ctx context.Context, options *filesoptions.DeleteOptions) (err error) Exists(ctx context.Context) (exists bool, err error) GetAccessPermissions() (permission int, err error) GetAccessPermissionsString() (permissionString string, err error) GetBaseName() (baseName string, err error) GetDeepCopy() (deepCopy File) GetHostDescription() (hostDescription string, err error) GetLocalPath() (localPath string, err error) GetLocalPathOrEmptyStringIfUnset() (localPath string, err error) GetParentDirectory() (parentDirectory Directory, err error) GetPath() (path string, err error) GetSizeBytes() (fileSize int64, err error) GetUriAsString() (uri string, err error) MoveToPath(destPath string, useSudo bool, verbose bool) (movedFile File, err error) ReadAsBytes() (content []byte, err error) SecurelyDelete(ctx context.Context) (err error) String() (path string) Truncate(newSizeBytes int64, verbose bool) (err error) WriteBytes(ctx context.Context, toWrite []byte, options *filesoptions.WriteOptions) (err error) // All methods below this line can be implemented by embedding the `FileBase` struct: AppendLine(line string, verbose bool) (err error) CheckIsLocalFile(verbose bool) (err error) ContainsLine(line string) (containsLine bool, err error) CreateParentDirectory(verbose bool) (err error) EnsureLineInFile(line string, verbose bool) (err error) EnsureEndsWithLineBreak(verbose bool) (err error) GetCreationDateByFileName(verbose bool) (creationDate *time.Time, err error) GetFileTypeDescription(verbose bool) (fileTypeDescription string, err error) GetMimeType(verbose bool) (mimeType string, err error) GetNumberOfLinesWithPrefix(prefix string, trimLines bool) (nLines int, err error) GetNumberOfNonEmptyLines() (nLines int, err error) GetParentDirectoryPath() (parentDirectoryPath string, err error) GetPathAndHostDescription() (path string, hostDescription string, err error) GetSha256Sum() (sha256sum string, err error) GetTextBlocks(verbose bool) (textBlocks []string, err error) GetValueAsInt(key string) (value int, err error) GetValueAsString(key string) (value string, err error) IsContentEqualByComparingSha256Sum(other File, verbose bool) (isMatching bool, err error) IsEmptyFile() (isEmpty bool, err error) IsLocalFile(verbose bool) (isLocalFile bool, err error) IsMatchingSha256Sum(sha256sum string) (isMatching bool, err error) IsPgpEncrypted(verbose bool) (isPgpEncrypted bool, err error) IsYYYYmmdd_HHMMSSPrefix() (hasDatePrefix bool, err error) MustIsMatchingSha256Sum(sha256sum string) (isMatching bool) MustIsPgpEncrypted(verbose bool) (isPgpEncrypted bool) MustIsYYYYmmdd_HHMMSSPrefix() (hasDatePrefix bool) MustPrintContentOnStdout() MustReadAsBool() (content bool) MustReadAsFloat64() (content float64) MustReadAsInt() (content int) MustReadAsInt64() (content int64) MustReadAsLines() (contentLines []string) MustReadAsLinesWithoutComments() (contentLines []string) MustReadAsTimeTime() (time *time.Time) MustReadAsString() (content string) MustReadFirstLine() (firstLine string) MustReadFirstLineAndTrimSpace() (firstLine string) MustReadLastCharAsString() (lastChar string) MustReadFirstNBytes(numberOfBytesToRead int) (firstBytes []byte) MustRemoveLinesWithPrefix(prefix string, verbose bool) MustReplaceLineAfterLine(lineToFind string, replaceLineAfterWith string, verbose bool) (changeSummary *changesummary.ChangeSummary) PrintContentOnStdout() (err error) ReadAsBool() (content bool, err error) ReadAsFloat64() (content float64, err error) ReadAsInt() (content int, err error) ReadAsInt64() (content int64, err error) ReadAsLines() (contentLines []string, err error) ReadAsLinesWithoutComments() (contentLines []string, err error) ReadAsString() (content string, err error) ReadAsTimeTime() (time *time.Time, err error) ReadFirstLine() (firstLine string, err error) ReadFirstNBytes(numberOfBytesToRead int) (firstBytes []byte, err error) ReadFirstLineAndTrimSpace() (firstLine string, err error) ReadLastCharAsString() (lastChar string, err error) RemoveLinesWithPrefix(prefix string, verbose bool) (err error) ReplaceLineAfterLine(lineToFind string, replaceLineAfterWith string, verbose bool) (changeSummary *changesummary.ChangeSummary, err error) SortBlocksInFile(verbose bool) (err error) TrimSpacesAtBeginningOfFile(verbose bool) (err error) WriteInt64(toWrite int64, verboe bool) (err error) WriteLines(linesToWrite []string, verbose bool) (err error) WriteString(ctx context.Context, content string, options *filesoptions.WriteOptions) (err error) WriteTextBlocks(textBlocks []string, verbose bool) (err error) }
A File represents any kind of file regardless if a local file or a remote file.
Click to show internal directories.
Click to hide internal directories.