fs

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: BSL-1.0 Imports: 5 Imported by: 0

README

fs

Go Reference Go Report Card

About

Package fs provides various file functions. Package fs is published on https://codeberg.org/vbsw/go-lib.

Copyright 2026, Vitali Baumtrok (vbsw@mailbox.org).

fs is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

fs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

References

Documentation

Overview

Package fs provides various file functions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBufferOutOfMemory = errors.New("buffer out of memory")
)

Functions

func IsExist

func IsExist(path string) bool

IsExist returns true when file exists. Mode is ignored.

func IsHidden

func IsHidden(path string) bool

IsHidden returns true when file is hidden.

Types

type File

type File struct {
	Err  error
	Info os.FileInfo
}

func (*File) IsDir

func (file *File) IsDir(path string) bool

IsDir returns true when path is a directory. Error is stored in Err.

func (*File) IsEmpty

func (file *File) IsEmpty(path string) bool

IsEmpty returns whether directory or file is empty. A directory is empty if it has only empty directories and empty files. A file is empty if it is a regular file with size 0.

func (*File) IsRegular

func (file *File) IsRegular(path string) bool

IsRegular returns true when path is a regular file. Error is stored in Err.

func (*File) Stat

func (file *File) Stat(path string) bool

Stat calls os.Stat(path) and stores result in Info. Returns true when file exists and is readable. Error is stored in Err.

type FileReader

type FileReader struct {
	File
	Offset int64

	Buffer []byte
	NRead  int
	// contains filtered or unexported fields
}

FileReader reads files into buffer.

func (*FileReader) Close

func (reader *FileReader) Close()

Close closes the file. Err is set only if it was previously nil.

func (*FileReader) CopyNTo

func (reader *FileReader) CopyNTo(path string, n int64) bool

CopyTo copies n bytes from FileReader to path. Error is stored in Err.

func (*FileReader) CopyTo

func (reader *FileReader) CopyTo(path string) bool

CopyTo copies all bytes from FileReader to path. Error is stored in Err.

func (*FileReader) IsOpen

func (reader *FileReader) IsOpen() bool

IsOpen returns whether file is open.

func (*FileReader) Open

func (reader *FileReader) Open(path string) bool

Open opens file for reading and initializes Info. Returns true if file was successfully opened. Error is stored in Err.

func (*FileReader) Read

func (reader *FileReader) Read(keepN int) bool

Read copies the last keepN bytes to the beginning of the buffer and then reads from the file into the buffer. Buffer is starting at offset keepN. Returns true if any bytes have been read and no error encountered. Error is stored in Err unless it is io.EOF.

func (*FileReader) Seek

func (reader *FileReader) Seek(offset int64) bool

Seek sets the offset for the next Read on file. Returns true when seek was successful. Error is stored in Err.

type FileWriter

type FileWriter struct {
	File
	Offset int64

	NWritten int
	// contains filtered or unexported fields
}

FileWriter writes files.

func (*FileWriter) Close

func (writer *FileWriter) Close()

Close closes the file. Err is set only if it was previously nil.

func (*FileWriter) CopyFrom

func (writer *FileWriter) CopyFrom(path string) bool

CopyFrom copies all bytes from path to FileWriter. Error is stored in Err.

func (*FileWriter) CopyNFrom

func (writer *FileWriter) CopyNFrom(path string, n int64) bool

CopyFrom copies n bytes from path to FileWriter. Error is stored in Err.

func (*FileWriter) IsOpen

func (writer *FileWriter) IsOpen() bool

IsOpen returns whether file is open.

func (*FileWriter) Open

func (writer *FileWriter) Open(path string) bool

Open opens file with FileMode 0666 for writing and initializes Info. Returns true when file was successfully opened. Error is stored in Err.

func (*FileWriter) Seek

func (writer *FileWriter) Seek(offset int64) bool

Seek sets the offset for the next Write on file. Returns true when seek was successful. Error is stored in Err.

func (*FileWriter) StdoutWrite

func (writer *FileWriter) StdoutWrite(bytes []byte) bool

Write writes bytes to file. Error is stored in Err.

func (*FileWriter) Write

func (writer *FileWriter) Write(bytes []byte) bool

Write writes bytes to file. Error is stored in Err.

Jump to

Keyboard shortcuts

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