vfs: add follow_path function

This commit is contained in:
2025-09-23 19:38:14 +03:00
parent 1fb777adb0
commit f697fab390
4 changed files with 85 additions and 3 deletions
+66
View File
@@ -221,4 +221,70 @@ int vsf_read_file_by_path(const char* path, uint8_t** buffer, l9660_dir* dir)
debug_log("bytes read: 0x%X\n", read);
return 0;
}
void follow_path(const char* path, l9660_file* file, l9660_dir* dir)
{
int pos = 0;
int start_from_root = 0;
char buf[32];
int bufpos = 0;
int isdir = 0;
memset(buf, 0, sizeof(buf));
if (path[pos] == '/')
{
start_from_root = 1;
pos++;
l9660_fs_open_root(dir, global_fs);
debug_log("start_from_root\n");
debug_log("/");
}
//printf("start_from_root: %X\n\n", start_from_root);
l9660_status status;
while(path[pos] != '\0')
{
while (path[pos] != '/' && path[pos] != '\0')
{
buf[bufpos] = path[pos];
pos++;
bufpos++;
}
buf[bufpos] = '\0'; // Null-terminate the string
bufpos = 0;
if(path[pos] != '\0')
{
isdir = 1;
debug_log("%s->", buf);//this is a directory
l9660_dir dir2;
status = l9660_opendirat(&dir2, dir, buf);
if(status != L9660_OK)
{
debug_log("FUCKFUCKFUCKFUCK BLYAAAT!!!!!\n");
return;
}
*dir = dir2;
}
else
{
isdir = 0;
debug_log("%s", buf);//this is a file
status = l9660_openat(file, dir, buf);
if(status != L9660_OK)
{
debug_log("PIZDAPIZDA BLYAAAT!!!!!\n");
return;
}
return;
}
pos++;
}
debug_log("\n");
//printf("buf: %s\n", buf);
debug_log("isdir: %X\n", isdir);
}