vfsbilly

package module
v2.0.0-...-c4c657d Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package vfsbilly provides a compatibility layer between github.com/twpayne/go-vfs and github.com/src-d/go-billy.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BillyFS

type BillyFS struct {
	vfs.FS
}

A BillyFS implements github.com/src-d/go-billy.Filesystem.

func NewBillyFS

func NewBillyFS(fs vfs.FS) *BillyFS

NewBillyFS returns a new BillyFS.

Example
package main

import (
	"testing"

	vfsbilly "github.com/danielmmetz/go-vfsbilly/v2"
	billyutil "github.com/go-git/go-billy/v5/util"
	"github.com/twpayne/go-vfs/vfst"
)

func main() {

	Test := func(t *testing.T) {

		fs, cleanup, err := vfst.NewTestFS(map[string]interface{}{
			"/home/user/.bashrc": "# contents of .bashrc\n",
		})
		if err != nil {
			t.Fatal(err)
		}
		defer cleanup()

		billyFS := vfsbilly.NewBillyFS(fs)
		if err := billyutil.WriteFile(billyFS, "/home/user/foo", []byte("bar"), 0666); err != nil {
			t.Errorf("billyutil.WriteFile(...) == %v, want <nil>", err)
		}

		vfst.RunTests(t, fs, "",
			vfst.TestPath("/home/user/foo",
				vfst.TestContentsString("bar"),
			),
		)

	}

	Test(&testing.T{})
}
Output:

func (*BillyFS) Capabilities

func (b *BillyFS) Capabilities() billy.Capability

Capabilities implements billy.Filesystem.Capabilities.

func (*BillyFS) Chroot

func (b *BillyFS) Chroot(path string) (billy.Filesystem, error)

Chroot implements billy.Chroot.Chroot.

func (*BillyFS) Create

func (b *BillyFS) Create(filename string) (billy.File, error)

Create implements billy.Basic.Create.

func (*BillyFS) Join

func (b *BillyFS) Join(elem ...string) string

Join implements billy.Basic.Join.

func (*BillyFS) MkdirAll

func (b *BillyFS) MkdirAll(filename string, perm os.FileMode) error

MkdirAll implements billy.Dir.MkdirAll.

func (*BillyFS) Open

func (b *BillyFS) Open(filename string) (billy.File, error)

Open implements billy.Basic.Open.

func (*BillyFS) OpenFile

func (b *BillyFS) OpenFile(filename string, flag int, perm os.FileMode) (billy.File, error)

OpenFile implements billy.Basic.OpenFile.

func (*BillyFS) Root

func (b *BillyFS) Root() string

Root implements billy.Chroot.Root.

func (*BillyFS) TempFile

func (b *BillyFS) TempFile(dir, prefix string) (billy.File, error)

TempFile implements billy.TempFile.TempFile.

Jump to

Keyboard shortcuts

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