GFileable

package module
v0.0.0-...-3260da6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 7 Imported by: 0

README

FileKit

CircleCI Go Linux supported Go Report Card

GFileable is originated to Fileable for Swift. It enables to mange files or directories efficiently and easily.

Installation

You can also use go get command instead of any other package manager.

go get -u github.com/shotastage/GFileable

⌘ APIs

Function
func Pwd() string Get current directory path as a string.
func Home() string Get home directory path.
func (f Fileable) IsFile() bool Check the file exists or not.
func (f Fileable) IsDir() bool Check the directory exists or not.
func (f Fileable) Extension() string Get file extension.
func Cd(to string) Change directory like a cd command.
func Mkdir(path string) error Make directory.
func (f Fileable) Rm() error Remove directory or file.
func (f Fileable) Mv(to string) error Move file or directory.
func Touch(name string) error Create empty file.
func (f Fileable) Chmod(mode os.FileMode) error Change file permission.

License

Fileable is licensed under the MIT. You can use this library free of charge. See LICENSE for detail.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cd

func Cd(to string) error

Cd changes the current directory.

func Home

func Home() (string, error)

Home returns the home directory path.

func Mkdir

func Mkdir(path string) error

Mkdir creates a new directory.

func Pwd

func Pwd() (string, error)

Pwd returns the current directory path.

func Touch

func Touch(name string) error

Touch creates a new empty file.

func Unzip

func Unzip(src string, dest string) error

func Zip

func Zip(srcFiles []string, dest string) error

Types

type Fileable

type Fileable struct {
	Path string
}

Fileable represents a file or directory.

func Join

func Join(path ...interface{}) *Fileable

func Path

func Path(path string) *Fileable

Path is a constructor.

func (Fileable) Check

func (f Fileable) Check(files ...string) bool

Check files existence

func (Fileable) Chmod

func (f Fileable) Chmod(mode os.FileMode) error

Chmod changes the mode or permission of a file or directory.

func (Fileable) Extension

func (f Fileable) Extension() (string, error)

Extension returns the file extension.

func (Fileable) IsDir

func (f Fileable) IsDir() (bool, error)

IsDir returns whether the path is a directory.

func (Fileable) IsFile

func (f Fileable) IsFile() (bool, error)

IsFile returns whether the path is a file.

func (Fileable) Mv

func (f Fileable) Mv(to string) error

Mv renames or moves a file or directory.

func (Fileable) Rm

func (f Fileable) Rm() error

Rm removes a file or directory.

func (Fileable) WriteString

func (f Fileable) WriteString(str string) error

Write string to file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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