Cleaned up file name handling.
This commit is contained in:
@@ -6,8 +6,3 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
#include "filesystem.hpp"
|
#include "filesystem.hpp"
|
||||||
|
|
||||||
namespace ox {
|
|
||||||
namespace fs {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,8 +26,17 @@ class FileSystem {
|
|||||||
private:
|
private:
|
||||||
struct DirectoryEntry {
|
struct DirectoryEntry {
|
||||||
typename FileStore::InodeId_t inode;
|
typename FileStore::InodeId_t inode;
|
||||||
uint8_t nameLen;
|
|
||||||
char name;
|
char *getName() {
|
||||||
|
return (char*) (this + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setName(const char *name) {
|
||||||
|
auto data = getName();
|
||||||
|
auto nameLen = strlen(name);
|
||||||
|
memcpy(data, &name, nameLen);
|
||||||
|
data[nameLen] = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Directory {
|
struct Directory {
|
||||||
@@ -88,8 +97,7 @@ uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSi
|
|||||||
Directory &dir = *((Directory*) dirBuff);
|
Directory &dir = *((Directory*) dirBuff);
|
||||||
DirectoryEntry entry;
|
DirectoryEntry entry;
|
||||||
entry.inode = INODE_ROOT_DIR;
|
entry.inode = INODE_ROOT_DIR;
|
||||||
entry.name = '/';
|
entry.setName("/");
|
||||||
entry.nameLen = 1;
|
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
uint32_t err;
|
uint32_t err;
|
||||||
|
|||||||
@@ -24,6 +24,12 @@ int strcmp(const char *str1, const char *str2) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int strlen(const char *str1) {
|
||||||
|
int len;
|
||||||
|
for (len = 0; str1[len]; len++);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,7 @@ namespace std {
|
|||||||
|
|
||||||
int strcmp(const char *str1, const char *str2);
|
int strcmp(const char *str1, const char *str2);
|
||||||
|
|
||||||
|
int strlen(const char *str1);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user