Cleaned up file name handling.

This commit is contained in:
2016-06-26 19:55:12 -05:00
parent eeff1dda8b
commit c3b9a9e9e0
4 changed files with 20 additions and 9 deletions
-5
View File
@@ -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 {
}
}
+12 -4
View File
@@ -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;
+6
View File
@@ -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;
}
} }
} }
+2
View File
@@ -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);
} }
} }