Added initFs.

This commit is contained in:
2015-09-07 03:25:04 -05:00
parent 1ed0991f3b
commit 3d68fa45e5
10 changed files with 44 additions and 16 deletions
+1 -13
View File
@@ -1,15 +1,3 @@
cmake_minimum_required(VERSION 2.8.8)
add_library(
Memphis
memfs.cpp
_memops.cpp
)
install(
FILES
memfs.hpp
_memops.hpp
DESTINATION
include/Memphis
)
add_subdirectory(memphis)
+15
View File
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8.8)
add_library(
Memphis
memfs.cpp
_memops.cpp
)
install(
FILES
memfs.hpp
_memops.hpp
DESTINATION
include/Memphis
)
+6
View File
@@ -15,6 +15,12 @@ namespace memphis {
uint32_t MemFs::version = 0;
uint8_t *initFs(uint8_t *buffer, size_t size, bool hasDirectories) {
auto fs = (MemFsHeader*) (buffer ? buffer : malloc(size));
fs->version = MemFs::version;
return (uint8_t*) fs;
}
MemFsPtr MemFs::Record::size() {
return offsetof(MemFs::Record, m_id) + dataLen;
}
+8 -2
View File
@@ -8,14 +8,18 @@
#ifndef MEMPHIS_MEMFS_HPP
#define MEMPHIS_MEMFS_HPP
#include "types.hpp"
#include "_types.hpp"
namespace memphis {
typedef uint32_t MemFsPtr;
typedef uint32_t RecordId;
struct MemFsHeader {
uint32_t version;
bool hasDirectories;
};
class MemFs {
public:
static uint32_t version;
@@ -124,6 +128,8 @@ T MemFs::ptr(MemFsPtr ptr) {
return (T) m_begin + ptr;
}
uint8_t *initFs(uint8_t *buffer, size_t size, bool hasDirectories);
}
#endif