correct nffs dir/file open with dirent

This commit is contained in:
hathach committed 2017-03-01 13:21:28 +07:00
1 parent 1b555e7b52
commit a39bf64279
4 files changed
+17 -7

No files matched your search

+7 -2
View File
@@ -62,14 +62,19 @@ bool NffsDir::open(const char* path)
return (errnum == FS_EOK);
}
bool NffsDir::open(NffsDirEntry& dirent)
bool NffsDir::open(const char* parent_dir, NffsDirEntry& dirent)
{
bool result = false;
char* name = (char*) rtos_malloc(NFFS_FILENAME_MAX_LEN+1);
VERIFY(name);
if ( dirent.getName(name, NFFS_FILENAME_MAX_LEN+1) > 0 )
strcpy(name, parent_dir);
strcat(name, "/");
int len = strlen(name);
if ( dirent.getName(name+len, NFFS_FILENAME_MAX_LEN+1-len) > 0 )
{
result = open(name);
}