vfsbilly

package module
v0.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

README

go-vfsbilly

GoDoc Build Status Report Card

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

This allows you to use vfst to test exisiting code that uses billy.Filesystem. See the documentation for an example.

License

The MIT License (MIT)

Copyright (c) 2018 Tom Payne

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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"
	"github.com/twpayne/go-vfs/vfst"

	billyutil "gopkg.in/src-d/go-billy.v4/util"
)

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