#include <iterator>
#include <stdlib.h>
#include <limits.h>
+#include <tzplatform_variables.h>
+#include <tzplatform_config.h>
#include "filesystem_path.h"
#include "common/logger.h"
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<Path>(new Path());
- result->reset(path);
+ result->reset(replaceVirtualRootPath(path.c_str()));
return result;
}
* @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);