$exec may now provide a stdin parameter. Deprecated path.append, path.tappend, getcwd, tgetcwd, path.absolute, ls. Deprecated env::get_config_dir, replaced by env::new_get_config_dir. Added path.has_extension, path.new_append, path.temp_append, new_cwd, temp_cwd, path.new_absolute, new_ls, temp_ls. Added dstring.replace Updated win escapes for exec.

This commit is contained in:
Christoffer Lerno
2024-08-14 00:57:25 +02:00
parent 6bc486400c
commit 3ccb4b9ec3
18 changed files with 309 additions and 145 deletions

View File

@@ -83,10 +83,15 @@ fn String! get_home_dir(Allocator using = allocator::heap())
return get_var(home, using);
}
fn Path! get_config_dir(Allocator allocator = allocator::heap()) @deprecated("use new_get_config_dir()")
{
return new_get_config_dir(allocator) @inline;
}
/**
* Returns the current user's config directory.
**/
fn Path! get_config_dir(Allocator allocator = allocator::heap())
fn Path! new_get_config_dir(Allocator allocator = allocator::heap())
{
@pool(allocator)
{
@@ -100,7 +105,7 @@ fn Path! get_config_dir(Allocator allocator = allocator::heap())
String s = get_var_temp("XDG_CONFIG_HOME") ?? get_var_temp("HOME")!;
const DIR = ".config";
$endif
return path::temp_new(s).append(DIR, .allocator = allocator);
return path::temp_new(s).new_append(DIR, .allocator = allocator);
$endif
};
}
@@ -126,11 +131,16 @@ fn bool clear_var(String name)
};
}
fn String! executable_path(Allocator allocator = allocator::heap())
fn String! executable_path(Allocator allocator = allocator::heap()) @deprecated("use new_executable_path()")
{
return new_executable_path(allocator) @inline;
}
fn String! new_executable_path(Allocator allocator = allocator::heap())
{
$if env::DARWIN:
return darwin::executable_path(allocator);
$else
return "<Unsupported>";
return SearchResult.MISSING?;
$endif
}

View File

@@ -80,7 +80,7 @@ fn uptr! load_address() @local
{
Darwin_segment_command_64* cmd = darwin::getsegbyname("__TEXT");
if (!cmd) return BacktraceFault.SEGMENT_NOT_FOUND?;
String path = env::executable_path(allocator::temp()) ?? BacktraceFault.EXECUTABLE_PATH_NOT_FOUND?!;
String path = env::new_executable_path(allocator::temp()) ?? BacktraceFault.EXECUTABLE_PATH_NOT_FOUND?!;
uint dyld_count = darwin::_dyld_image_count();
for (uint i = 0; i < dyld_count; i++)
{