osutil

package
v0.0.0-...-40f42d4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MkdirAll

func MkdirAll(mode fsutil.PathType, path string, perm fs.FileMode) error

MkdirAll creates a directory with the given package name and operation. It joins the operation path with the package name, replacing any '/' with the OS-specific path separator. The directory is created with permissions to read, write, and execute for all users.

Args:

mode (fsutil.PathType): The type of path to construct (e.g., relative or root).
path (string): The path to the directory to create.
perm (fs.FileMode): The permissions to apply to the created directory.

Returns:

error: An error if the directory cannot be created, or nil if successful.

func ReadFile

func ReadFile(mode fsutil.PathType, path string) ([]byte, error)

ReadFile reads the contents of a file at the specified path. The path is resolved based on the provided mode, which can be either Relative or Root.

Args:

mode (fsutil.PathType): The type of path to resolve.
path (string): The path to the file.

Returns:

([]byte, error): The contents of the file as a byte slice, or an error if the file cannot be read.

func ReadFiles

func ReadFiles(paths []fsutil.Path, sem gtools.Semaphore) ([][]byte, error)

ReadFiles reads the contents of multiple files concurrently.

Args:

paths ([]fsutil.Path): A slice of file paths to read.
sem (gtools.Semaphore): A semaphore to limit concurrency.

Returns:

([][]byte, error): A slice of byte slices containing the file contents, or an error if any file cannot be read.

func ReadPartial

func ReadPartial(mode fsutil.PathType, path string, start int64, end int64) ([]byte, error)

ReadPartial reads a partial content of a file.

It takes a file path, a start position, and an end position as input, and returns the content of the file within the specified range. If an error occurs during the read operation, it returns an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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