Giter VIP home page Giter VIP logo

tiny-vfs's Introduction

Tiny VFS

A tiny virtual file system library for C++.

NOTE: Tiny VFS only works with C++11 and newer!

Tiny VFS maps virtual directories to physical ones.

Getting started

First, you need to clone the Tiny VFS repository:

git clone https://github.com/anthony-y/tiny-vfs.git

Next, move the tinyvfs source files into a suitable location. You will compile the library into your project as if it were part of your own codebase:

#include "tinyvfs.hpp"

To mount a directory:

TinyVFS::FS()->MountDir("Virtual/Directory", "Physical/Directory");

Resolving a physical directory is as simple as:

std::string physicalDir = TinyVFS::FS()->ResolvePhysicalDir("Virtual/Directory");

This works the same with files too:

std::string physicalDirOfFile = TinyVFS::FS()->ResolvePhysicalDir("Virtual/Directory/File.extension");

Tiny VFS also has a simple method for reading text files from a virtual directory:

std::string fileContents;
TinyVFS::FS()->ReadTextFile("Virtual/Directory/Text File.txt", fileContents);

This method returns a boolean value as to whether the read failed or not.

if (!TinyVFS::FS()->ReadTextFile("Virtual/Directory/Text File.txt", fileContents))
{
    std::cout << "Read failed!" << std::endl;
    return 1;
}

std::cout << "Read succeeded! File contents: " << fileContents << std::endl;

return 0;

To compile, just build the .cpp file into your binary:

g++ -o yourexecutable.exe -std=c++11 yourfile.cpp tinyvfs.cpp

Check out the samples directory for a full example of usage.

tiny-vfs's People

Contributors

anthony-y avatar dontbelieveme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

darcyg linecode

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.