package
0.0.0-20240831221938-81d58bd93b8c
Repository: https://github.com/vanilla-os/sdk.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author

# Functions

AtomicSwap atomically swaps two files or directories Example: err := fs.AtomicSwap("/tmp/file1", "/tmp/file2") if err != nil { fmt.Printf("Error swapping files: %v", err) return }.
CopyFile copies the contents of one file to another Example: err := fs.CopyFile("/tmp/batman", "/tmp/robin") if err != nil { fmt.Printf("Error copying file: %v", err) return }.
CreateDirectory creates a new directory Example: err := fs.CreateDirectory("/tmp/batman") if err != nil { fmt.Printf("Error creating directory: %v", err) return }.
DeleteDirectory deletes a directory and its contents Example: err := fs.DeleteDirectory("/tmp/batman") if err != nil { fmt.Printf("Error deleting directory: %v", err) return }.
DeleteFile deletes a file Example: err := fs.DeleteFile("/tmp/batman") if err != nil { fmt.Printf("Error deleting file: %v", err) return }.
DirectoryExists checks if a directory exists Example: if fs.DirectoryExists("/tmp/batman") { fmt.Println("The directory exists!") }.
FileExists checks if a file exists Example: if fs.FileExists("/tmp/batman") { fmt.Println("The file exists!") }.
GetDiskInfo returns information about a specific disk partition Example: info, err := fs.GetDiskInfo("/dev/sda1") if err != nil { fmt.Printf("Error getting partition info: %v", err) return } fmt.Printf("Path: %s\n", info.Path) fmt.Printf("Size: %d\n", info.Size) fmt.Printf("HumanSize: %s\n", info.HumanSize).
GetDiskList returns a list of disks on the system Example: disks, err := fs.GetDiskList() if err != nil { fmt.Printf("Error getting disk list: %v", err) return } for _, disk := range disks { fmt.Printf("Disk: %s\n", disk.Path) fmt.Printf("Size: %d\n", disk.Size) fmt.Printf("HumanSize: %s\n", disk.HumanSize) for _, partition := range disk.Partitions { fmt.Printf("Partition: %s\n", partition.Path) fmt.Printf("Size: %d\n", partition.Size) fmt.Printf("HumanSize: %s\n", partition.HumanSize) fmt.Printf("Filesystem: %s\n", partition.Filesystem) fmt.Printf("Mountpoint: %s\n", partition.Mountpoint) fmt.Printf("Label: %s\n", partition.Label) fmt.Printf("UUID: %s\n", partition.UUID) fmt.Printf("PARTUUID: %s\n", partition.PARTUUID) fmt.Printf("Flags: %v\n", partition.Flags) } }.
GetFile returns the file info of the specified file.
GetFileDiff compares the content of two files and returns the changes Example: diff, err := fs.GetFileDiff("/tmp/batman", "/tmp/robin") if err != nil { fmt.Printf("Error getting file diff: %v", err) return } fmt.Printf("Added lines: %v\n", diff.AddedLines) fmt.Printf("Removed lines: %v\n", diff.RemovedLines).
GetFileExtension returns the extension of the given file Example: extension := fs.GetFileExtension("/batmans/cave/batmobile.txt") fmt.Printf("Extension: %s\n", extension).
GetFileList returns a list of files in the specified directory.
GetFileSize returns the size of the specified file in bytes Example: size := fs.GetFileSize("/batmans/cave/batmobile.txt") fmt.Printf("Size: %d\n", size).
GetFilesystemInfo returns information about the filesystem of a file or partition by reading from /etc/mtab.
GetHumanSize converts the size from bytes to a human-readable format.
GetPartitionList returns a list of disk partitions on the specified disk Example: partitions, err := fs.GetPartitionList("/dev/sda") if err != nil { fmt.Printf("Error getting partition list: %v", err) return } for _, partition := range partitions { fmt.Printf("Partition: %s\n", partition.Path) fmt.Printf("Size: %d\n", partition.Size) fmt.Printf("HumanSize: %s\n", partition.HumanSize) }.
IsDirectory checks whether the given path is a directory Example: if fs.IsDirectory("/batmans/cave") { fmt.Println("It's a directory!") }.
IsFile checks whether the given path is a regular file Example: if fs.IsFile("/batmans/cave/batmobile.txt") { fmt.Println("It's a file!") }.
IsMounted checks if the given source path is mounted in the given destination path.
ListDirectories returns a list of directories in the specified directory Example: directories, err := fs.ListDirectories("/tmp") if err != nil { fmt.Printf("Error: %v\n", err) return } for _, directory := range directories { fmt.Printf("Directory: %s\n", directory) }.
Mount mounts the given source path in the given destination path.
MountBind mounts bind the given source path in the given destination path.
MountFuseOverlay mounts the given lower, upper and work directories in the given destination path as an overlay filesystem using fuse-overlayfs.
MountOverlay mounts the given lower, upper and work directories in the given destination path as an overlay filesystem.
MoveFile moves a file from one location to another Example: err := fs.MoveFile("/tmp/batman", "/tmp/robin") if err != nil { fmt.Printf("Error moving file: %v", err) return }.
Unmount unmounts the given path.
UnmountFuseOverlay unmounts the given path using the fuse-overlayfs command- line tool.
WriteFileContent writes content to the specified file Example: err := fs.WriteFileContent("/tmp/batman", "I'm Batman!") if err != nil { fmt.Printf("Error writing file content: %v", err) return }.