#include <dpl/wrt-dao-ro/global_config.h>
#include <pkg-manager/pkgmgr_signal.h>
#include <app2ext_interface.h>
+#include <dpl/utils/path.h>
using namespace WrtDB;
namespace { //anonymous
const char* REG_TIZEN_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
const int PKGID_LENTH = 10;
-const std::string PRELOAD_INSTALLED_PATH = "/usr/apps";
+const DPL::Utils::Path PRELOAD_INSTALLED_PATH("/usr/apps");
bool checkDirectoryExist(const std::string& pkgId)
{
- std::string installPath =
- std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
- "/" + pkgId;
-
- struct stat dirStat;
- if ((stat(installPath.c_str(), &dirStat) == 0)) {
- return true;
- }
- return false;
+ DPL::Utils::Path installPath(GlobalConfig::GetUserInstalledWidgetPath());
+ installPath /= pkgId;
+ return installPath.Exists();
}
}
m_context.locations = WidgetLocation(m_context.tzPkgid);
m_context.locations->registerAppid(m_context.tzAppid);
m_context.installedPath =
- DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+ DPL::Utils::Path(*dao.getWidgetInstalledPath());
LogInfo("Widget model exists. App id : " << m_context.tzAppid);
LogDebug("Regcomp failed");
}
std::string pkgId;
- std::string installPath;
+ DPL::Utils::Path installPath;
Try {
if ((regexec(®x, id.c_str(),
LogDebug("Get appid from pkgid : " << appid);
m_context.tzAppid = DPL::ToUTF8String(appid);
WrtDB::WidgetDAOReadOnly dao(appid);
- installPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+ installPath = DPL::Utils::Path(*dao.getWidgetInstalledPath());
} else {
pkgId = id.substr(0, PKGID_LENTH);
WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(id));
m_context.tzAppid = id;
- installPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath());
+ installPath = DPL::Utils::Path(*dao.getWidgetInstalledPath());
}
-
- if (0 == installPath.compare(0, PRELOAD_INSTALLED_PATH.length(),
- PRELOAD_INSTALLED_PATH)) {
+ if(installPath.isSubPath(PRELOAD_INSTALLED_PATH)){
LogDebug("This widget is prealoded.");
}
} Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {