diff mbox series

archive: support property "create-destination"

Message ID 20200412131114.12749-1-sbabic@denx.de
State Accepted
Headers show
Series archive: support property "create-destination" | expand

Commit Message

Stefano Babic April 12, 2020, 1:11 p.m. UTC
This property is already supported by eaw-handler, add it to the archive
handler. If the directory where to extract te archive does not exist,
create it if create-destination is set to "true" (properties are always
strings).

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 handlers/archive_handler.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c
index b797277..f409ec5 100644
--- a/handlers/archive_handler.c
+++ b/handlers/archive_handler.c
@@ -246,6 +246,19 @@  static int install_archive_image(struct img_type *img,
 		goto out;
 	}
 
+	/*
+	 * Check if path must be created
+	 */
+	char* make_path;
+	make_path = dict_get_value(&img->properties, "create-destination");
+	if (make_path != NULL && strcmp(make_path, "true") == 0) {
+		ret = mkpath(path, 0755);
+		if (ret < 0) {
+			ERROR("I cannot create path %s: %s", path, strerror(errno));
+			return -1;
+		}
+	}
+
 	/*
 	 * Change to directory where tarball must be extracted
 	 */