Skip to content

Commit

Permalink
Merge branch 'main' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Apr 24, 2024
2 parents 4b8f3ef + 9769a5b commit cf2eb4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion base/fs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// LAF Base Library
// Copyright (c) 2020-2021 Igara Studio S.A.
// Copyright (c) 2020-2024 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
Expand Down Expand Up @@ -39,6 +39,8 @@ namespace base {
void remove_directory(const std::string& path);

std::string get_current_path();
void set_current_path(const std::string& path);

std::string get_app_path();
std::string get_temp_path();
std::string get_user_docs_folder();
Expand Down
11 changes: 8 additions & 3 deletions base/fs_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,16 @@ void remove_directory(const std::string& path)
std::string get_current_path()
{
std::vector<char> path(MAXPATHLEN);
if (getcwd(&path[0], path.size()))
return std::string(&path[0]);
if (getcwd(path.data(), path.size()))
return std::string(path.data());
return std::string();
}

void set_current_path(const std::string& path)
{
chdir(path.data());
}

std::string get_app_path()
{
std::vector<char> path(MAXPATHLEN);
Expand Down Expand Up @@ -171,7 +176,7 @@ std::string get_canonical_path(const std::string& path)
// Ignore return value as realpath() returns nullptr anyway when the
// resolved_path parameter is specified.
realpath(path.c_str(), buffer);
return path;
return buffer;
}

paths list_files(const std::string& path)
Expand Down
7 changes: 6 additions & 1 deletion base/fs_win32.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// LAF Base Library
// Copyright (c) 2020 Igara Studio S.A.
// Copyright (c) 2020-2024 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
Expand Down Expand Up @@ -123,6 +123,11 @@ std::string get_current_path()
return "";
}

void set_current_path(const std::string& path)
{
::SetCurrentDirectory(from_utf8(path).c_str());
}

std::string get_app_path()
{
TCHAR buffer[MAX_PATH+1];
Expand Down

0 comments on commit cf2eb4b

Please sign in to comment.