mirror of
https://git.checksum.fail/alec/erythros
synced 2025-12-10 13:09:55 +02:00
System/Core/Shell: Return full expanded path (including mount point) in @shell_expand_relative_path
This commit is contained in:
@@ -79,12 +79,9 @@ I64 @shell_parse_opts(@shell* sh, U8* op_lst, I64 argc, U8** argv, I64* flags,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
U8* @shell_expand_relative_path(@shell* sh, U8* path)
|
||||
|
||||
U8* @shell_expand_relative_path_to_root_path(@shell* sh, U8* path)
|
||||
{
|
||||
if (!path || !sh)
|
||||
return NULL;
|
||||
if (StrLen(path) < 1)
|
||||
return NULL;
|
||||
switch (path[0]) {
|
||||
case '/':
|
||||
return StrNew(path);
|
||||
@@ -97,6 +94,24 @@ U8* @shell_expand_relative_path(@shell* sh, U8* path)
|
||||
}
|
||||
}
|
||||
|
||||
U8* @shell_expand_relative_path(@shell* sh, U8* path)
|
||||
{
|
||||
if (!path || !sh)
|
||||
return NULL;
|
||||
if (StrLen(path) < 1)
|
||||
return NULL;
|
||||
U8* relative_path_to_root_path = @shell_expand_relative_path_to_root_path(sh, path);
|
||||
if (!MemCmp(relative_path_to_root_path, "/mnt/", 5))
|
||||
return relative_path_to_root_path;
|
||||
if (!MemCmp(relative_path_to_root_path, "/sys/", 5))
|
||||
return relative_path_to_root_path;
|
||||
U8* prepend_root_path = config->o("default")->o("filesystem")->@("root");
|
||||
U8* full_expanded_path = CAlloc(StrLen(relative_path_to_root_path) + StrLen(prepend_root_path) + 8);
|
||||
StrPrint(full_expanded_path, "%s%s", prepend_root_path, relative_path_to_root_path);
|
||||
Free(relative_path_to_root_path);
|
||||
return full_expanded_path;
|
||||
}
|
||||
|
||||
U8* @shell_get_env_var(@shell* sh, U8* key)
|
||||
{
|
||||
@shell_env_var* var = sh->env->next;
|
||||
|
||||
Reference in New Issue
Block a user