mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +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;
|
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__
|
#ifdef __serenity__
|
||||||
|
|
||||||
String File::read_link(String const& link_path)
|
String File::read_link(String const& link_path)
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
|
|
||||||
static bool exists(const String& filename);
|
static bool exists(const String& filename);
|
||||||
static bool ensure_parent_directories(const String& path);
|
static bool ensure_parent_directories(const String& path);
|
||||||
|
static String current_working_directory();
|
||||||
|
|
||||||
enum class RecursionMode {
|
enum class RecursionMode {
|
||||||
Allowed,
|
Allowed,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue