Giter VIP home page Giter VIP logo

cvfs's Introduction

CVFS

Overview

CVFS, which stands for Class Virtual File System, is a one header only library. which lets you create a simple node based in-memory-filesystem.

How to use the library?

You need to add the VFS.hpp to your include paths.

Example of how to use this library.

A example is provided inside the main.cpp file.

How to build the example project?

First you need cmake from https://cmake.org/. After you have installed cmake you need to create a build directory inside this directory. Open a terminal and navigate to the build directory, alternative you can use the cmake-gui, but I will describe the terminal version. Since cmake supports many build system I used in this example ninja, but you can use whatever you want.

cmake .. -G "Ninja"
ninja -j4

Now you can execute the compiled project.

License

This library is under the MIT License

cvfs's People

Contributors

tostc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cvfs's Issues

Quick Questions for the readme.md

Hi there!

a) Does support nested directories, ie: /tmp/tmpdir/file.txt ?

   Seems not, but possible to implement?  Like nest a VFS in a file, inside a directory?

b) Does support binary files ?

   How to get size?

Cheers,
Hippy

Deserialize: Merging

Hi There!

I have implemented a function to deserialize a filesystem created with Serialize...

// deserialize show file
bool LoadFileSystem(std::string FileName = "")
{
    if (FileName.size() == 0)
        FileName = "last.fs";

    ifstream in(FileName, ios::in | ios::binary);

    if (in.is_open())
    {
        in.seekg(0, std::ios::end);
        std::streampos length = in.tellg();
        in.seekg(0, std::ios::beg);

        std::vector<char> buffer(length);
        in.read(&buffer[0], length);
        in.close();

        try
        {
            g_VFS.Deserialize(buffer);
        }
        catch (VFS::CVFSException e)
        {
          //  spdlog::error("Failed to deserialize: '{}' -> {}",FileName, e.what());     
            return false;
        }

        return true;
    }

    // spdlog::error("Could not open file: {}", FileName);
    return false;
}

This is working, but say create some default directories, eg "/sys", I save the file system, then load a file system, I have now in PrintDirs two "/sys" folders.

Is there a simple way to merge or overlay these?

Also is there a better way to load, so I don't load the entire thing into memory here when loading? I couldn't really think of one.

Cheers,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.