mirror of
https://github.com/google/cdc-file-transfer.git
synced 2026-09-13 01:10:44 +03:00
[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:
+13
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user