summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2017-04-20 16:07:20 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-04-27 02:18:03 +0000
commit3a482f67eb50cc9bd779dc8f3412e793b9b3cae9 (patch)
tree83cf3e0e81d401eb0cdd3dbbbe1220ddb565e79b
parenta733df5f73c266aaab8487e1773583c4356367ac (diff)
downloadphosphor-bmc-code-mgmt-3a482f67eb50cc9bd779dc8f3412e793b9b3cae9.tar.gz
phosphor-bmc-code-mgmt-3a482f67eb50cc9bd779dc8f3412e793b9b3cae9.zip
Create image dir if needed
Change-Id: If1c1a62292027ae98d1ba1c6d62bd72d0ae8a307 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rwxr-xr-xMakefile.am3
-rw-r--r--download_manager.cpp9
2 files changed, 11 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index e4be065..9de41b4 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,8 @@ generic_ldflags = \
$(SYSTEMD_LIBS) \
$(PHOSPHOR_DBUS_INTERFACES_LIBS) \
$(SDBUSPLUS_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS)
+ $(PHOSPHOR_LOGGING_LIBS) \
+ -lstdc++fs
phosphor_version_software_manager_CXXFLAGS = $(generic_cxxflags)
phosphor_version_software_manager_LDFLAGS = $(generic_ldflags)
diff --git a/download_manager.cpp b/download_manager.cpp
index f5ff54b..fc217f0 100644
--- a/download_manager.cpp
+++ b/download_manager.cpp
@@ -3,6 +3,7 @@
#include <unistd.h>
#include <sys/wait.h>
#include <phosphor-logging/log.hpp>
+#include <experimental/filesystem>
#include "config.h"
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
@@ -18,6 +19,7 @@ namespace manager
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using namespace phosphor::logging;
+namespace fs = std::experimental::filesystem;
void Download::downloadViaTFTP(const std::string fileName,
const std::string serverAddress)
@@ -46,6 +48,13 @@ void Download::downloadViaTFTP(const std::string fileName,
entry("FILENAME=%s", fileName),
entry("SERVERADDRESS=%s", serverAddress));
+ // Check if IMAGE DIR exists and create if necessary.
+ fs::path imgDirPath(IMG_UPLOAD_DIR);
+ if (!fs::is_directory(imgDirPath))
+ {
+ fs::create_directory(imgDirPath);
+ }
+
pid_t pid = fork();
if (pid == 0)
OpenPOWER on IntegriCloud