#include <Commons/Exception.h>
#include <API/Filesystem/Enums.h>
#include <API/Filesystem/IManager.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
#include <WidgetDB/WidgetDBMgr.h>
#include "FilesystemUtils.h"
IPathPtr fromVirtualPath(JSContextRef context,
const std::string& arg)
{
-/* IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
- Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");*/
+ LogDebug("arg:[" << arg << "]");
if (!isPathValid(arg)) {
- ThrowMsg(Commons::NotFoundException, "Not found path component.");
+ LogDebug("virtual path is invalid:[" << arg << "]");
+ ThrowMsg(Commons::ConversionException, "Not found path component.");
}
std::string root;
root = arg;
}
-/* WidgetDB::Api::IWidgetDBPtr widgetDB =
- WidgetDB::Api::getWidgetDB(wrt->getWidgetId());*/
+/* int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+ WidgetDB::Api::IWidgetDBPtr widgetDB =
+ WidgetDB::Api::getWidgetDB(widgetId);*/
RootToPathMap rootToPath = getRootToPathMap();
/* rootToPath["wgt-package"] = widgetDB->getWidgetInstallationPath();
}
std::string toVirtualPath(JSContextRef context, const std::string& arg) {
- IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
- Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
+ int widgetId = WrtAccessSingleton::Instance().getWidgetId();
WidgetDB::Api::IWidgetDBPtr widgetDB =
- WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+ WidgetDB::Api::getWidgetDB(widgetId);
PathToRootMap pathToRoot = getPathToRootMap();
pathToRoot[widgetDB->getWidgetInstallationPath()] = "wgt-package";
}
bool isPathValid(const std::string& path) {
- static const std::string currentDirBegin(
- PATH_INVALID_COMPONENT_CURRENT_DIR +
- Api::Filesystem::IPath::getSeparator());
- static const std::string parentDirBegin(
- PATH_INVALID_COMPONENT_PARENT_DIR +
- Api::Filesystem::IPath::getSeparator());
- static const std::string currentDirMiddle(
- Api::Filesystem::IPath::getSeparator() +
- PATH_INVALID_COMPONENT_CURRENT_DIR +
- Api::Filesystem::IPath::getSeparator());
- static const std::string parentDirMiddle(
- Api::Filesystem::IPath::getSeparator() +
- PATH_INVALID_COMPONENT_PARENT_DIR +
+ static const std::string currentDirBegin(PATH_INVALID_COMPONENT_CURRENT_DIR + Api::Filesystem::IPath::getSeparator());
+ static const std::string parentDirBegin(PATH_INVALID_COMPONENT_PARENT_DIR +
Api::Filesystem::IPath::getSeparator());
+ static const std::string currentDirMiddle(Api::Filesystem::IPath::getSeparator() +
+ PATH_INVALID_COMPONENT_CURRENT_DIR +Api::Filesystem::IPath::getSeparator());
+ static const std::string parentDirMiddle(Api::Filesystem::IPath::getSeparator() +
+ PATH_INVALID_COMPONENT_PARENT_DIR +Api::Filesystem::IPath::getSeparator());
if (path.find(parentDirBegin) == 0 ||
- path.find(currentDirBegin) == 0 ||
+ path.find(currentDirBegin) == 0 ||
path.find(parentDirMiddle) != std::string::npos ||
path.find(currentDirMiddle) != std::string::npos) {
return false;
}
+
return true;
}