diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2023-11-02 10:40:26 -0700 |
---|---|---|
committer | Kelvin Zhang <zhangkelvin@google.com> | 2023-11-02 10:40:26 -0700 |
commit | 8b435660e0a967b7229d390d9c094f364fffec1a (patch) | |
tree | 5513df7fcf4bdb15f10a07032c4ec264abb8eb95 /partition_tools | |
parent | 571326c9c91446bbdd9ba076630550034e84713c (diff) | |
download | extras-8b435660e0a967b7229d390d9c094f364fffec1a.tar.gz |
Create output dir in lpunpack if does not exist
This saves caller 1 extra step to create the output dir before invoking
lpunpack
Test: lpunpack super.img /tmp/not_exist_dir
Change-Id: Idcadf3ff2d5c3656174f712f00b170d77deaf8ea
Diffstat (limited to 'partition_tools')
-rw-r--r-- | partition_tools/Android.bp | 3 | ||||
-rw-r--r-- | partition_tools/lpunpack.cc | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/partition_tools/Android.bp b/partition_tools/Android.bp index f330d254..e483cea0 100644 --- a/partition_tools/Android.bp +++ b/partition_tools/Android.bp @@ -182,6 +182,9 @@ cc_binary_host { "liblp", "libsparse", ], + static_libs: [ + "libc++fs", + ], srcs: [ "lpunpack.cc", ], diff --git a/partition_tools/lpunpack.cc b/partition_tools/lpunpack.cc index b215c58e..696d3f25 100644 --- a/partition_tools/lpunpack.cc +++ b/partition_tools/lpunpack.cc @@ -21,6 +21,7 @@ #include <sys/types.h> #include <unistd.h> +#include <filesystem> #include <iostream> #include <limits> #include <string> @@ -203,6 +204,7 @@ ImageExtractor::ImageExtractor(std::vector<unique_fd>&& image_fds, std::unique_p output_dir_(output_dir) {} bool ImageExtractor::Extract() { + std::filesystem::create_directories(output_dir_); if (!BuildPartitionList()) { return false; } |