[ANN] AXIS VFS - Simple, lightweight, virtual file system API

134 views
Skip to first unread message

milo.chr...@gmail.com

unread,
Oct 21, 2016, 4:20:15 PM10/21/16
to golang-nuts
AXIS VFS public repository

Today I am proud to announce the public release of AXIS VFS, a simple and lightweight virtual file system API. AXIS' intended purpose is to abstract file IO so that the client program does not need to know anything about the system it is running on and to allow files from dissimilar sources to be read with a unified API.

I personally use AXIS in a data file loader to support multiple source directories and loading from zip files, but this API has many other uses.

I hope you will find this simple little library useful!

ChrisLu

unread,
Oct 25, 2016, 2:48:31 PM10/25/16
to golang-nuts, milo.chr...@gmail.com
Need some examples to understand the API.

Chris

milo.chr...@gmail.com

unread,
Oct 25, 2016, 3:12:56 PM10/25/16
to golang-nuts, milo.chr...@gmail.com
// From the code to initialize AXIS in Rubble
fs := new(axis2.FileSystem)

fs.Mount("df", sources.NewOSDir(dfdir), true)
fs.Mount("rubble", sources.NewOSDir(rubbledir), true)
fs.Mount("out", sources.NewOSDir(output), true)
for i := range addonsdir {
fs.Mount("addons", sources.NewOSDir(addonsdir[i]), true)
}

// From part of the Rubble addon loader (mount and read from a zip file)
content, err := fs.ReadAll("addons/"+name+".zip")
if err != nil {
errors.RaiseWrappedError("While reading zip file:", err)
}

ds, err = zip.NewRawDir(content)
if err != nil {
errors.RaiseWrappedError("While reading zip file:", err)
}

fs.Mount("loader/pack", ds, false)
meta = loadPackMeta(fs, "loader/pack")
fs.Unmount("loader/pack", true)

// More code from the loader
for _, filepath := range fs.ListFiles(dirpath) {
content, err := fs.ReadAll(path+filepath)
if err != nil {
panic(err)
}

...
}

Have some random excerpts from Rubble (the main client for AXIS right now). Obviously there are just code snippets, but they should be helpful. I'll write some proper examples for the package sooner or later...
Reply all
Reply to author
Forward
0 new messages