fs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package fs provides a primitive virtual file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindASN1Files

func FindASN1Files(dir string) []string

FindASN1Files returns a list of ASN.1 files (.asn, asn1).

func FindCFiles

func FindCFiles(dir string) []string

FindCFiles returns a list of C/C++ files (.c, .cc, .cxx, .cpp).

func FindTTCN3Files

func FindTTCN3Files(dir string) []string

FindTTCN3Files returns a list of TTCN-3 source files (.ttcn3, .ttcn). FindTTCN3Files will return a nil slice on any error.

func HasASN1Extension

func HasASN1Extension(file string) bool

HasASN1Extension returns true if file has suffix .asn or .asn1

func HasCExtension

func HasCExtension(file string) bool

HasCExtension returns true if file has suffix .c, .cc, .cxx or .cpp

func HasTTCN3Extension

func HasTTCN3Extension(file string) bool

HasTTCN3Extension returns true if file has suffix .ttcn3 or .ttcn

func PathSlice

func PathSlice(files ...*File) []string

PathSlice returns a string slice of the File objects passed as argument.

Types

type File

type File struct {

	// We export the handle until we have better alternatives for cache invalidation.
	Handle *memoize.Handle
	// contains filtered or unexported fields
}

A File represents a open file

func Open

func Open(path string) *File

Open a file.

path can be any identifier, URL, ...

func (*File) Bytes

func (f *File) Bytes() ([]byte, error)

Bytes returns the contents of File. If content was not specified using SetBytes, Bytes will try reading the file path's content from disk.

func (*File) Close

func (f *File) Close()

Closes a file and removes it from the store

func (*File) ID

func (f *File) ID() string

ID returns an identifier.

func (*File) Path

func (f *File) Path() string

Path returns the file system path (if possible).

func (*File) Reset

func (f *File) Reset()

Reset sets the content to zero. This is identcal to SetBytes(nil)

func (*File) SetBytes

func (f *File) SetBytes(b []byte)

SetBytes set the contents of the file.

func (*File) String

func (f *File) String() string

String returns the file path as it was using during creation: If File was created as URI, String will return an URI, if File was created as relative path, String will return this relative path.

func (*File) URI

func (f *File) URI() span.URI

URI returns returns the absolute file path with a "file://" prefix.

type Store

type Store struct {
	// contains filtered or unexported fields
}

A Store holds all open files.

func (*Store) Open

func (s *Store) Open(path string) *File

Open a file and add it to the store.

Jump to

Keyboard shortcuts

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