atylar

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: Zlib Imports: 11 Imported by: 2

README

Atylar

Atylar is an opinionated file storage system with version history. It uses a flat directory structure (no subdirectories). To start, initialize a new Store using the function New(), supplying the store's root directory path as the argument. All functions which may be used to modify the files automatically copy the current file to the .history directory in the current store. Historic versions are marked with an @ sign and the version number after the file name. The numbers are designated based on the generation, an always-increasing counter characteristic for the store.

Documentation

Overview

Package atylar is an opinionated file storage system with version history. It uses a flat directory structure (no subdirectories). To start, initialize a new Store using the function New(), supplying the store's root directory path as the argument. All functions which may be used to modify the files automatically copy the current file to the `.history` directory in the current store. Historic versions are marked with an @ sign and the version number after the file name. The numbers are designated based on the generation, an always-increasing counter characteristic for the store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	Directory  string // Path to store root
	Generation uint64 // Used to set files' versions
}

func New

func New(root string) (Store, error)

New opens or creates a new store.

func (*Store) Copy

func (S *Store) Copy(from, to string) error

Copy copies a file.

func (*Store) GetGeneration

func (S *Store) GetGeneration(increment bool) uint64

GetGeneration increments current generation if the argument is true and returns it.

func (*Store) History

func (S *Store) History(file string) ([]uint64, error)

History returns generations available for the given file. The name is normalized

func (*Store) List

func (S *Store) List(history bool) ([]string, error)

List lists all files. If history is true, returns all backed up files' names, without the version string.

func (*Store) Move

func (S *Store) Move(from, to string) error

Move moves a file.

func (*Store) Open

func (S *Store) Open(file string, generation uint64) (*os.File, error)

Open opens given file for reading. If generation is non-zero, it opens a historic version.

func (*Store) Overwrite

func (S *Store) Overwrite(file string) (*os.File, error)

Overwrite returns a file descriptor for writing. If the file exists, it is truncated.

func (*Store) Remove

func (S *Store) Remove(file string) error

Remove removes a file.

func (*Store) Stat

func (S *Store) Stat(file string, history bool) (fs.FileInfo, error)

Stat runs os.Stat on the specified file.

Jump to

Keyboard shortcuts

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