[cdc_fuse_fs] Fix various issues (#6)

Fixes a couple of issues with the FUSE:
- Creates the mount directory if it does not exist.
  This assumes the mount dir to be the last arg. Ideally, we'd parse the
  command line and then create the directory, but unfortunately
  fuse_parse_cmdline already verifies that the dir exists.
- Expands the cache_dir (e.g. ~).
- Fixes a compile issue in manifest_iterator.
This commit is contained in:
ljusten
2022-11-17 14:01:59 +01:00
committed by GitHub
parent 76bbdb01bb
commit ca84d3dd2e
6 changed files with 80 additions and 17 deletions
+13 -2
View File
@@ -37,6 +37,7 @@
#include <stdlib.h> // putenv
#include <unistd.h> // readlink
#include <utime.h> // struct utimbuf
#include <wordexp.h>
#define __stat64 stat64
#define _chmod chmod
#endif
@@ -198,8 +199,8 @@ absl::Status GetKnownFolderPath(FolderId folder_id, std::string* path) {
}
#endif
absl::Status ExpandPathVariables(std::string* path) {
#if PLATFORM_WINDOWS
absl::Status ExpandEnvironmentPathVariables(std::string* path) {
std::wstring wchar_path = Util::Utf8ToWideStr(*path);
DWORD size = ::ExpandEnvironmentStrings(wchar_path.c_str(), nullptr, 0);
@@ -217,8 +218,18 @@ absl::Status ExpandEnvironmentPathVariables(std::string* path) {
wchar_expanded.pop_back();
*path = Util::WideToUtf8Str(wchar_expanded);
return absl::OkStatus();
}
#else
wordexp_t res;
wordexp(path->c_str(), &res, 0);
if (res.we_wordc > 1) {
return absl::InvalidArgumentError(
"Path expands to multiple results (did you use * etc. ?");
}
*path = res.we_wordv[0];
wordfree(&res);
return absl::OkStatus();
#endif
}
absl::Status GetEnv(const std::string& name, std::string* value) {
value->clear();