diff options
author | 2023-08-22 17:40:55 +0000 | |
---|---|---|
committer | 2023-09-01 19:04:20 +0000 | |
commit | 09f0cc608e964732a05e15471d5c4daacf31249d (patch) | |
tree | 71217f10aea8dcefb3c64d5a35ae201db34201e8 | |
parent | efce371535f2c3cc3edf16370ec8b2a643771e47 (diff) |
Migrate from android::String path functions to std::filesystem
Bug: 295394788
Test: m checkbuild
Change-Id: I7efdc32872d00c066b9a874d774e5ecdc5e53722
-rw-r--r-- | cmds/cmd/Android.bp | 3 | ||||
-rw-r--r-- | cmds/cmd/cmd.cpp | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/cmds/cmd/Android.bp b/cmds/cmd/Android.bp index c3d2601444..27ef78854c 100644 --- a/cmds/cmd/Android.bp +++ b/cmds/cmd/Android.bp @@ -27,6 +27,9 @@ cc_library_static { "libselinux", "libbinder", ], + whole_static_libs: [ + "libc++fs", + ], cflags: [ "-Wall", diff --git a/cmds/cmd/cmd.cpp b/cmds/cmd/cmd.cpp index b7273987b6..0ce7711574 100644 --- a/cmds/cmd/cmd.cpp +++ b/cmds/cmd/cmd.cpp @@ -27,6 +27,7 @@ #include <utils/Mutex.h> #include <utils/Vector.h> +#include <filesystem> #include <getopt.h> #include <stdlib.h> #include <stdio.h> @@ -69,10 +70,8 @@ public: virtual int openFile(const String16& path, const String16& seLinuxContext, const String16& mode) { String8 path8(path); - char cwd[256]; - getcwd(cwd, 256); - String8 fullPath(cwd); - fullPath.appendPath(path8); + auto fullPath = std::filesystem::current_path(); + fullPath /= path8.c_str(); if (!mActive) { mErrorLog << "Open attempt after active for: " << fullPath << endl; return -EPERM; |