mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibCore: Add File method to determine current working directory
This commit is contained in:
parent
a3400798f8
commit
3ae64c7c3d
2 changed files with 15 additions and 0 deletions
|
@ -193,6 +193,20 @@ bool File::ensure_parent_directories(const String& path)
|
|||
return rc == 0;
|
||||
}
|
||||
|
||||
String File::current_working_directory()
|
||||
{
|
||||
char* cwd = getcwd(nullptr, 0);
|
||||
if (!cwd) {
|
||||
perror("getcwd");
|
||||
return {};
|
||||
}
|
||||
|
||||
auto cwd_as_string = String(cwd);
|
||||
free(cwd);
|
||||
|
||||
return cwd_as_string;
|
||||
}
|
||||
|
||||
#ifdef __serenity__
|
||||
|
||||
String File::read_link(String const& link_path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue