Added initFs.
This commit is contained in:
+1
-13
@@ -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)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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,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
|
||||
Reference in New Issue
Block a user