System/Libraries/FileSystem: Add FileSystem.CreatePath()

This commit is contained in:
Alec Murphy
2025-09-12 16:57:56 -04:00
parent ed6362d731
commit c06de7edc6

View File

@@ -27,6 +27,7 @@ extern I64 @plan9fs_write_file(U8* path, U64 buffer, I64 size);
class @filesystem
{
I64 root_fs_type;
Bool (*CreatePath)(U8* path);
@dir_entry (*GetFiles)(U8* path);
U8* (*GetFileExtension)(U8* path);
U0 (*Init)();
@@ -225,6 +226,31 @@ I64 @filesystem_write_file(U8* path, U8* buffer, I64 size)
return NULL;
}
Bool @filesystem_create_path(U8* path)
{
if (!path)
return FALSE;
U8 buf[512];
I64 type = @filesystem_get_type(path);
switch (type) {
case FS_TYPE_SYSTEM:
return FALSE;
SysHlt;
break;
case FS_TYPE_REDSEA:
StrPrint(&buf, "%c:%s", ToUpper(path[12]), path + 13);
return Cd(&buf, TRUE);
break;
case FS_TYPE_9P:
return FALSE;
break;
default:
break;
}
return NULL;
}
FileSystem.CreatePath = &@filesystem_create_path;
FileSystem.GetFiles = &@filesystem_get_files;
FileSystem.GetFileExtension = &@filesystem_get_file_extension;
FileSystem.PathExists = &@filesystem_path_exists;