Skip to content

package filesystem

import "kaiju/filesystem"

Functions

CopyDirectory

func CopyDirectory(src, dst string) error

CopyDirectory copies the directory at the source path to the destination path.

CopyFile

func CopyFile(src, dst string) error

CopyFile copies the file from the source path to the destination path. If the destination file already exists, an error will be returned.

CopyGoSourceFile

func CopyGoSourceFile(src, dst string) error

CopyGoSourceFile copies go specific source code from the source path to the destination path. If the destination file already exists, an error will be returned. This function is used to ensure that the generated files have the correct header.

CreateDirectory

func CreateDirectory(path string) error

CreateDirectory creates a directory at the specified path with full permissions.

DeleteDirectory

func DeleteDirectory(path string) error

DeleteDirectory deletes the directory at the specified path.

DirectoryExists

func DirectoryExists(path string) bool

DirectoryExists returns true if the directory exists at the specified path.

FileExists

func FileExists(path string) bool

FileExists returns true if the file exists at the specified path.

ImageDirectory

func ImageDirectory() (string, error)

ImageDirectory will attempt to find the default user directory where images are stored. This function is OS specific.

ListFilesRecursive

func ListFilesRecursive(path string) ([]string, error)

ListFilesRecursive returns a list of all files in the specified, it walks through all of the subdirectories as well.

ListFoldersRecursive

func ListFoldersRecursive(path string) ([]string, error)

ListFoldersRecursive returns a list of all directories in the specified, it walks through all of the subdirectories as well.

ListRecursive

func ListRecursive(path string) ([]string, error)

ListRecursive returns a list of all files and directories in the specified, it walks through all of the subdirectories as well.

ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads the binary data from the file at the specified path. If the file does not exist, an error will be returned.

ReadTextFile

func ReadTextFile(path string) (string, error)

ReadTextFile reads the text data from the file at the specified path. If the file does not exist, an error will be returned.

WriteFile

func WriteFile(path string, data []byte) error

WriteFile writes the binary data to the file at the specified path. This will use permissions 0644 for the file. If the file already exists, it will be overwritten.

WriteTextFile

func WriteTextFile(path string, data string) error

WriteTextFile writes the text data to the file at the specified path. This will use permissions 0644 for the file. If the file already exists, it will be overwritten.