#ifndef LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
#define LIBRARIES_NACL_IO_MEMFS_MEM_FS_H_
#include "nacl_io/filesystem.h"
#include "nacl_io/typed_fs_factory.h"
namespace nacl_io {
class MemFs : public Filesystem {
protected:
MemFs();
using Filesystem::Init;
virtual Error Init(const FsInitArgs& args);
int AllocateINO();
void FreeINO(int ino);
virtual Error FindNode(const Path& path, int type, ScopedNode* out_node);
public:
virtual Error Access(const Path& path, int a_mode);
virtual Error Open(const Path& path, int mode, ScopedNode* out_node);
virtual Error Unlink(const Path& path);
virtual Error Mkdir(const Path& path, int perm);
virtual Error Rmdir(const Path& path);
virtual Error Remove(const Path& path);
virtual Error Rename(const Path& path, const Path& newpath);
private:
static const int REMOVE_DIR = 1;
static const int REMOVE_FILE = 2;
static const int REMOVE_ALL = REMOVE_DIR | REMOVE_FILE;
Error RemoveInternal(const Path& path, int remove_type);
ScopedNode root_;
friend class TypedFsFactory<MemFs>;
DISALLOW_COPY_AND_ASSIGN(MemFs);
};
}
#endif