Merge branch 'master' of github.com:wombatant/ox

This commit is contained in:
2016-12-14 22:44:15 -06:00
4 changed files with 20 additions and 20 deletions
+17 -17
View File
@@ -16,13 +16,13 @@ template<typename FsT>
class FileStore { class FileStore {
public: public:
typedef uint16_t InodeId_t; typedef uint16_t InodeId_t;
typedef FsT FsSize_t; typedef FsT FsSize_t;
struct StatInfo { struct StatInfo {
InodeId_t inodeId; InodeId_t inodeId;
FsSize_t size; FsSize_t size;
uint8_t fileType; uint8_t fileType;
}; };
private: private:
@@ -31,13 +31,13 @@ class FileStore {
FsSize_t prev, next; FsSize_t prev, next;
FsSize_t dataLen; FsSize_t dataLen;
InodeId_t id; InodeId_t id;
uint8_t refs; uint8_t refs;
uint8_t fileType; uint8_t fileType;
FsSize_t left, right; FsSize_t left, right;
FsSize_t size(); FsSize_t size();
void setId(InodeId_t); void setId(InodeId_t);
void setData(void *data, FsSize_t size); void setData(void *data, FsSize_t size);
void *data(); void *data();
}; };
@@ -52,7 +52,7 @@ class FileStore {
* @param data the contents of the file * @param data the contents of the file
* @param dataLen the number of bytes data points to * @param dataLen the number of bytes data points to
*/ */
int write(void *data, FsSize_t dataLen, uint8_t fileType = 0); int write(void *data, FsSize_t dataLen, uint8_t fileType = 0);
/** /**
* Writes the given data to a "file" with the given id. * Writes the given data to a "file" with the given id.
@@ -60,7 +60,7 @@ class FileStore {
* @param data the contents of the file * @param data the contents of the file
* @param dataLen the number of bytes data points to * @param dataLen the number of bytes data points to
*/ */
int write(InodeId_t id, void *data, FsSize_t dataLen, uint8_t fileType = 0); int write(InodeId_t id, void *data, FsSize_t dataLen, uint8_t fileType = 0);
/** /**
* Removes the inode of the given ID. * Removes the inode of the given ID.
@@ -92,9 +92,9 @@ class FileStore {
*/ */
FsSize_t size(); FsSize_t size();
static uint8_t version(); static uint8_t version();
static uint8_t *format(uint8_t *buffer, FsSize_t size, uint32_t fsType = 0); static uint8_t *format(uint8_t *buffer, FsSize_t size, uint32_t fsType = 0);
private: private:
/** /**
@@ -166,11 +166,11 @@ class FileStore {
*/ */
void updateInodeAddress(InodeId_t id, FsSize_t addr); void updateInodeAddress(InodeId_t id, FsSize_t addr);
uint8_t *begin() { uint8_t *begin() {
return (uint8_t*) this; return (uint8_t*) this;
} }
uint8_t *end() { uint8_t *end() {
return begin() + this->m_size; return begin() + this->m_size;
} }
@@ -411,10 +411,10 @@ FsSize_t FileStore<FsSize_t>::nextInodeAddr() {
template<typename FsSize_t> template<typename FsSize_t>
void *FileStore<FsSize_t>::alloc(FsSize_t size) { void *FileStore<FsSize_t>::alloc(FsSize_t size) {
FsSize_t next = nextInodeAddr(); FsSize_t next = nextInodeAddr();
if ((next + size) > (uint64_t) end()) { if ((next + size) > (uint64_t) end()) {
compress(firstInode()); compress(firstInode());
next = nextInodeAddr(); next = nextInodeAddr();
if ((next + size) > (uint64_t) end()) { if ((next + size) > (uint64_t) end()) {
return nullptr; return nullptr;
} }
} }
@@ -480,7 +480,7 @@ FsSize_t FileStore<FsSize_t>::ptr(void *ptr) {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4244) #pragma warning(disable:4244)
#endif #endif
return ((uint8_t*) ptr) - begin(); return ((uint8_t*) ptr) - begin();
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(default:4244) #pragma warning(default:4244)
#endif #endif
@@ -512,7 +512,7 @@ uint8_t *FileStore<FsSize_t>::format(uint8_t *buffer, FsSize_t size, uint32_t fs
((Inode*) (fs + 1))->prev = fs->firstInode(); ((Inode*) (fs + 1))->prev = fs->firstInode();
fs->lastInode()->next = sizeof(FileStore<FsSize_t>); fs->lastInode()->next = sizeof(FileStore<FsSize_t>);
return (uint8_t*) buffer; return (uint8_t*) buffer;
} }
typedef FileStore<uint16_t> FileStore16; typedef FileStore<uint16_t> FileStore16;
+1 -1
View File
@@ -206,7 +206,7 @@ int FileSystemTemplate<FileStore>::write(uint64_t inode, void *buffer, uint64_t
#endif #endif
template<typename FileStore> template<typename FileStore>
uint8_t *FileSystemTemplate<FileStore>::format(void *buffer, typename FileStore::FsSize_t size, bool useDirectories) { uint8_t *FileSystemTemplate<FileStore>::format(void *buffer, typename FileStore::FsSize_t size, bool useDirectories) {
buffer = FileStore::format((uint8_t*) buffer, size, FS_TYPE); buffer = FileStore::format((uint8_t*) buffer, size, (uint32_t) FileSystemTemplate<FileStore>::FS_TYPE);
auto fs = createFileSystem(buffer); auto fs = createFileSystem(buffer);
if (buffer && useDirectories) { if (buffer && useDirectories) {
+1 -1
View File
@@ -72,7 +72,7 @@ size_t bytes(const char *str) {
} }
} }
const auto retval = ((size_t) ox_atoi(copy)) * multiplier; const auto retval = ((size_t) ox_atoi(copy)) * multiplier;
delete copy; delete []copy;
return retval; return retval;
} }
+1 -1
View File
@@ -14,7 +14,7 @@ typedef unsigned short uint16_t;
typedef int int32_t; typedef int int32_t;
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
typedef unsigned uint_t; typedef unsigned uint_t;
typedef long long int64_t; typedef long int64_t;
typedef unsigned long long uint64_t; typedef unsigned long long uint64_t;
namespace ox { namespace ox {