From: Tomasz Marciniak Date: Fri, 23 Sep 2016 10:25:02 +0000 (+0200) Subject: [Archive] Replace old virtual root path. X-Git-Tag: submit/tizen/20160926.015513~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e8424ddb04aec53503e829181ad88b82218bfdc7;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Archive] Replace old virtual root path. [Verification] Code compiles. TCT pass rate is 100% with change in inst.py script which replaces "/home/owner/content/Downloads" to "/opt/usr/home/owner/media/Downloads" Change-Id: If567a4d30ee8e8382faf809e4f49687500c4e643 Signed-off-by: Tomasz Marciniak --- diff --git a/src/archive/filesystem_path.cc b/src/archive/filesystem_path.cc index 1357a711..0b9a9027 100755 --- a/src/archive/filesystem_path.cc +++ b/src/archive/filesystem_path.cc @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "filesystem_path.h" #include "common/logger.h" @@ -26,13 +28,31 @@ namespace extension { namespace filesystem { +#define MAX_PATH_SIZE 4096 + const Path::SeparatorType Path::m_pathSeparator = '/'; +std::string Path::replaceVirtualRootPath(const char* path) { + LoggerD("Enter"); + + const char* old_path = "/opt/usr/media"; + char replace_path[MAX_PATH_SIZE] = {0, }; + + if (strncmp(path, old_path, strlen(old_path)) == 0) { + snprintf(replace_path, MAX_PATH_SIZE, "%s%s", tzplatform_getenv(TZ_USER_CONTENT), + path + strlen(old_path)); + } else { + snprintf(replace_path, MAX_PATH_SIZE, "%s", path); + } + + return std::string(replace_path); +} + PathPtr Path::create(const std::string& path) { LoggerD("Enter"); auto result = std::shared_ptr(new Path()); - result->reset(path); + result->reset(replaceVirtualRootPath(path.c_str())); return result; } diff --git a/src/archive/filesystem_path.h b/src/archive/filesystem_path.h index c06b9cb0..25ec7319 100644 --- a/src/archive/filesystem_path.h +++ b/src/archive/filesystem_path.h @@ -47,6 +47,7 @@ private: * @param path String to verify. * @return True when string is a valid path, false otherwise. */ + static std::string replaceVirtualRootPath(const char* path); static bool isValid(const std::string& str); Path(); void reset(const std::string& str);