Commit Graph

52 Commits

Author SHA1 Message Date
satotake ff7f3e04de rename: FilePredicateFs 2022-01-11 01:06:32 +09:00
satotake 1569f65aca Add new filtering fs: PredicateFs
A filtered view on predicates which takes file path as an argument,
any file will be treated as non-existing when the predicate returns false.
2021-06-19 21:08:07 +09:00
Vladimir Stolyarov c597fe5aa8
Add adapter to allow afero.Fs usage as io/fs.FS
It will not affect users of go older than 1.16 because files with `io/fs` import marked with build constraints
2021-03-13 21:09:09 +03:00
Mike Futerko 5207eb96b7 Fix chown pull request errors 2020-12-07 17:24:35 +02:00
L. Alberto Giménez a4ea980f2d
Add tarfs implementation (reopen #265) (#266)
* Initial commit for tarfs

* tarfs: reword "open" status field

* tarfs: use TestMain for FS setup

We want to have the FS variable available through all the tests, so we
we use a common "setup" function to initialise it.

* tarfs: test: early exit for nonexisting files

* tarfs: create test for filesystem Open

* tarfs: implement File.Stat

* tarfs: implement Fs.Open

* tarfs: return error on non-supported methods

As tarfs is a read-only filesystem backend, we return EROFS (Read-only
file system) from any method that makes modifications.

* tarfs: implement File.data as bytes.Reader

Most of the operations that we want to implement for tarfs.File are
already defined in bytes.Reader.

We could use a plain slice and implement all the seeking manually, but I
think using this is more convenient.

* tarfs: short format for simple methods

* tarfs: add missing closing brace in tests

* tarfs: add test for File.ReadAt

* tarfs: test File.ReadAt

* tarfs: add tests for File.Read

* tarfs: implement File.Read

* tarfs: add tests for File.Seek

* tarfs: implement File.Seek

* tarfs: add tests for File.Name

* tarfs: implement File.Name

* tarfs: add tests for File.Close

* tarfs: implement File.Close

* tarfs: add tests for OpenFile

* tarfs: fix test for Fs.OpenFile

If the call fails, we don't have to close the file

* tarfs: remove code not needed after using filepath.Clean

* tarfs: Open: return a copy of the internal structure

As we modify the struct fields when closing, we don't want to lose the
internal representation of the file, in case we want to reopen it.

Return a copy of the File, although we keep using the same pointers to
tar.Header and buffer.Reader. Maybe we will need to change that in the
future.

* tarfs: implement Fs.OpenFile

* tarfs: use Fatalf for unexpected error in TestFsOpen

* tarfs: add tests for Fs.Stat

* tarfs: implement Fs.Stat

* tarfs: remove TestNewFs

That test depends too much on the internal imlementation, and it is
easier to break if we change it.

* tarfs: remove unused code

* tarfs: change internal implementation

To be able to handle directories (File.Readdir, File.Readdirnames), the
naive single-map implementation makes it a bit harder to implement.

Inspired by the zipfs backend, switch to an internal implementation of a
map of directories that contains a map of files, so the directory
methods are easier to implement.

Also, treat the "virtual" filesystem as absolute, just like zipfs does.

* tarfs: use Fatal errors to avoid panics

* tarfs: add pseudoroot

* tarfs: add tests for File.Readdir

* tarfs: add pointer Fs in the File structure

For directory-related operations we will need to access the internal
structure in the Fs.

As Readdir and Readdirnames are File methods, we need to access such
structure from the File.

* tarfs: fix error

* tarfs: use just the names for TestReaddir, easier than using fill os.FileInfo entries

* tarfs: create a copy of the original entry when opening a file

We added the fs field in the File struct to reference the underlying Fs
object, but in the Open cal we were not passing it, making all the
opened files to have a nil pointer in that field.

Change to make a copy of the original file, and returning that

* tarfs: implement File.Readdir

* tarfs: add tests for File.Readdirnames

* tarfs: implement Readdirnames

* tarfs: add test for File.Name

* tarfs: change tests to use the Afero interface instead

* tarfs: add tests for Glob from zipfs

* tarfs: update main repo references to tarfs

* tarfs: use OS-specific file separator for pseudoroot

* tarfs: fix path handling in Windows systems
2020-09-14 20:44:56 +02:00
Chase Sriprajittichai 0caf874268 Fix typos in README code samples 2020-08-11 18:39:03 -07:00
Dmitry Savintsev 2f8d9cb33e
fix typo 2020-04-17 18:02:40 +02:00
Hilko Bengen 4f00b06400 Add zipfs, an archive/zip-based read-only filesystem 2020-03-30 14:44:04 +02:00
Michail Kargakis 491ff289da
Merge pull request #223 from whereswaldon/patch-1
Remove stale release notes from README
2020-03-27 21:46:00 +01:00
Michail Kargakis de012fc5f2
Merge pull request #187 from yasoob/patch-1
Fixed a small typo
2020-03-27 21:30:35 +01:00
Christopher Waldon 338097a104
Remove stale release notes from README
New users coming to the project could incorrectly assume that the project is pre-1.0 release and that it hasn't had a release in years if they assumed that the release notes in the README were up-to-date. I say this because I assumed that on my first read.
2019-11-03 14:44:18 -05:00
M.Yasoob Ullah Khalid ☺ 2236cc58df
Fixed a small typo 2018-12-04 00:59:11 -05:00
rwaweber b06a9e879d fix grammar in readme 2018-02-08 23:49:45 -05:00
Bjørn Erik Pedersen 57afd63c68
Revert "readme: Link to release notes in Releases"
Someone else will have to do this work.

This reverts commit a43378e6c4.
2017-12-28 13:50:11 +01:00
Bjørn Erik Pedersen a43378e6c4
readme: Link to release notes in Releases
Closes #151
2017-12-28 13:31:12 +01:00
Martin Bertschler e67d870304 Merge pull request #138 from dangerousHobo/patch-1
Fix some code bugs in the README.md.
2017-10-08 20:27:26 +02:00
snwfdhmp ea5fe66f02 Minor improvement 2017-10-08 18:09:09 +02:00
Michael John 3e504d357f Fix some code bugs in the README.md. 2017-10-05 21:34:59 -04:00
Theotime Leveque 596850cca5 readme: remove inferred type from AppFs declaration. 2017-03-25 18:31:14 -04:00
Laurent Charignon 944579a3fc Improve code in Readme
This patch makes the code in readme valid. The previous code had a few typos.
2016-11-09 01:08:59 +01:00
Matthieu Grieger ea7b1968a9 Fixed utility function calls in testing example 2016-06-01 21:37:16 -07:00
Hanno Hecker d660f82c74 remove MemMepFs limitation 2016-01-25 14:05:49 -05:00
Steve Francia 52ef806ebb update examples to use 'afero.' before calls 2016-01-11 21:49:09 -05:00
Steve Francia fe8e895336 Migrate all backends & readme to use constructorish New... 2016-01-11 21:41:03 -05:00
Steve Francia 4f6cfb713a Update readme to reflect migration of filters to filesystems 2016-01-11 20:48:25 -05:00
Hanno Hecker e68b257a2b add union fs 2016-01-11 14:42:14 -05:00
Hanno Hecker 205066d391 Add BasePathFs as FilterFs
* add a BasePathFs implemented as FilterFs:
  The BasePathFs restricts all operations to a given path within an Fs.
  The given file name to the operations on this Fs will be prepended
  with the base path before calling the base Fs.
  Any file name (after filepath.Clean()) outside this base path will be
  treated as non existing file.

* fix meaning of "facere" - "facio" means "I do", "facere" is the base
  form
2016-01-11 13:21:51 -05:00
Jerry Jacobs a34aa3adc4 README: Add xor-gate as author 2016-01-02 14:38:54 +01:00
Jerry Jacobs 90ff561dda Add SftpFs beta backend 2015-12-26 20:36:25 +01:00
Hanno Hecker e7cb826c1f update README to match the filters 2015-12-21 13:34:19 -05:00
Martin Bertschler 98ed0a3409 return improved errors from MemMapFs methods
MemMapFs.Mkdir now returns an error if the file or dir already exists
MemMapFs.Remove now returns an error if the file or dir doesn't exists

fixes #43
2015-12-20 22:09:09 +01:00
Hanno Hecker 36b075cbbf show how filtering is used 2015-12-15 18:18:10 +01:00
Steve Francia 99f1ddeda3 reposition gitter badge 2015-12-10 13:14:25 -05:00
The Gitter Badger fffa47e80f Add Gitter badge 2015-12-10 18:05:16 +00:00
Steve Francia 99c3e9a2c7 Release 0.10 of Afero 2015-12-10 12:26:46 -05:00
Steve Francia b5982947d7 Clarify naming in readme
fixes #28
2015-12-10 12:26:46 -05:00
Steve Francia 508533e0fc Adding utilities to readme 2015-12-10 12:26:46 -05:00
Martin Bertschler adb80c3cf7 Fix AppVeyor badge 2015-12-08 18:08:37 +01:00
Martin Bertschler b705e04d55 Add AppVeyor badge to Readme 2015-12-06 11:56:46 +01:00
Martin Bertschler 55789de153 Format Readme.md code blocks as Go code 2015-12-03 18:23:48 +01:00
Steve Francia f85f3b3779 reorganize and update readme 2015-12-01 17:10:13 -05:00
Steve Francia 4d968e2d2e Add logo image to readme 2015-11-30 21:04:23 -05:00
Steve Francia 4a72472d2c Update README.md 2015-11-30 20:54:51 -05:00
Alex Tomlins 19b2cf0372 Fix typo in README
O_TRUNC was listed twice, and O_CREATE omitted from the release notes.
2015-11-07 08:00:20 -05:00
Martin Bertschler 1407a13a63 Update README.md File interface and docs badge
Add a GoDocs badge
Change the badges to .svg
Add Sync() to File interface
2015-11-06 11:43:47 -05:00
Martin Bertschler aca753daff Update README.md Release Notes and Contributors
Add a new version 0.9.0 to Release Notes to highlight recent improvements in afero
Add mbertschler as contributor.
Rename MemFile to its actual name InMemoryFile.
2015-11-06 11:43:47 -05:00
Martin Bertschler 171091926d change Readdir test to work, update Fs and File interface in README
Readdir test worked on OS X but not on CI, because the assumption that the os.File Readdir returns files sorted by name is not true on all operating systems
2015-11-04 23:43:06 +01:00
Jamie Wilkinson af8b55cd1f Add jaqx0r to the list of contributors. 2015-05-01 17:53:54 -04:00
Wayne E. Seguin 139e50e29a 'fs' => 'afero'
Changed remaining 'fs' to 'afero' in README.
2015-02-24 11:57:06 -05:00
spf13 11dade3cc0 Adding Travis-CI support 2014-11-01 00:25:15 -04:00