iofuncs

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FILESIZE_TB = 1 << 40
	FILESIZE_GB = 1 << 30
	FILESIZE_MB = 1 << 20
	FILESIZE_KB = 1 << 10
)

Variables

View Source
var (
	APP_PATH      = getAppPath()
	DOWNLOAD_PATH = GetDefaultDownloadPath()
)

Functions

func CleanPathName

func CleanPathName(pathName string) string

Removes any illegal characters in a path name to prevent any error with file I/O using the path name

func DirPathExists added in v1.1.0

func DirPathExists(dirPath string) bool

similar to PathExists but checks if the path exists and is a directory

func FormatFileSize added in v1.1.2

func FormatFileSize(fileSize int64) string

Returns a string representation of the estimated file size Note: uses bitwise operations to calculate the file size. Hence, the file size is an estimate.

func GetDefaultDownloadPath

func GetDefaultDownloadPath() string

Returns the download path from the config file

func GetFileSize

func GetFileSize(filePath string) (int64, error)

Returns the file size based on the provided file path

If the file does not exist or there was an error opening the file at the given file path string, -1 is returned

func GetPostFolder

func GetPostFolder(downloadPath, creatorName, postId, postTitle string) string

Returns a directory path for a post, artwork, etc. based on the user's saved download path and the provided arguments

func PathExists

func PathExists(filepath string) bool

checks if a file or directory exists

func ReadLine

func ReadLine(reader *bufio.Reader) ([]byte, error)

Uses bufio.Reader to read a line from a file and returns it as a byte slice

Mostly thanks to https://devmarkpro.com/working-big-files-golang

func RemoveExtFromFilename

func RemoveExtFromFilename(filename string) string

Returns the path without the file extension

func SetDefaultDownloadPath

func SetDefaultDownloadPath(newDownloadPath string) error

Configure and saves the config file with updated download path

Types

type ConfigFile

type ConfigFile struct {
	DownloadDir string `json:"download_directory"`
	Language    string `json:"language"`
}

Jump to

Keyboard shortcuts

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