fsutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fsutil provides filesystem utility functions

Index

Constants

View Source
const (
	DirPerm  = 0755 // rwxr-xr-x
	FilePerm = 0644 // rw-r--r--
)

Default permissions for directories and files

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir(path string) error

EnsureDir ensures all parent directories exist for a given path

func IsDirectory

func IsDirectory(path string) bool

IsDirectory checks if the path is a directory

func IsFile

func IsFile(path string) bool

IsFile checks if the path is a regular file

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes a path for the current OS

func PathExists

func PathExists(path string) bool

PathExists checks if a path exists

func SafeCreateFile

func SafeCreateFile(path string, perm os.FileMode) (*os.File, error)

SafeCreateFile creates a file if it doesn't exist, returns error if it does

func SafeMkdir

func SafeMkdir(path string, perm os.FileMode) error

SafeMkdir creates a directory if it doesn't exist

func SanitizePath

func SanitizePath(basePath, userPath string) (string, error)

SanitizePath ensures the path is safe and doesn't escape the target directory

Types

This section is empty.

Jump to

Keyboard shortcuts

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