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/.
|
||||
*/
|
||||
#include "filesystem.hpp"
|
||||
|
||||
namespace ox {
|
||||
namespace fs {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,17 @@ class FileSystem {
|
||||
private:
|
||||
struct DirectoryEntry {
|
||||
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 {
|
||||
@@ -88,8 +97,7 @@ uint8_t *FileSystem<FileStore>::format(uint8_t *buffer, typename FileStore::FsSi
|
||||
Directory &dir = *((Directory*) dirBuff);
|
||||
DirectoryEntry entry;
|
||||
entry.inode = INODE_ROOT_DIR;
|
||||
entry.name = '/';
|
||||
entry.nameLen = 1;
|
||||
entry.setName("/");
|
||||
|
||||
if (buffer) {
|
||||
uint32_t err;
|
||||
|
||||
@@ -24,6 +24,12 @@ int strcmp(const char *str1, const char *str2) {
|
||||
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 strlen(const char *str1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user