Merge "Add a _LocalizedNumParser class and 4 static functions" into tizen_2.1
[platform/framework/native/appfw.git] / src / app / FApp_AppInfo.cpp
index 892a4f8..45a0438 100644 (file)
@@ -1,5 +1,4 @@
 //
-// Open Service Platform
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the License);
@@ -112,6 +111,9 @@ _AppInfo::~_AppInfo(void)
 {
        delete __pAppName;
        delete __pAppVersion;
+
+       // closing may or may not succeed
+       close(__appRootDirFd);
 }
 
 _AppInfo*
@@ -164,8 +166,9 @@ _AppInfo::Construct(const char* appId, const char* exeName, int argc, char* argv
                int len = strlen(PACKAGE_PATH_FORMAT2);
                strncpy(appInfoPath, PACKAGE_PATH_FORMAT2, len);
                appInfoPath[len] = '\0';
+               strncpy(appInfoPath + strlen(PATH_ROOT2), appId, MAX_APPID);
 
-               if (access(appInfoPath, R_OK) != 0)
+               if (euidaccess(appInfoPath, R_OK) != 0)
                {
                        len = strlen(PACKAGE_PATH_FORMAT);
                        strncpy(appInfoPath, PACKAGE_PATH_FORMAT, len);
@@ -173,12 +176,7 @@ _AppInfo::Construct(const char* appId, const char* exeName, int argc, char* argv
                        
                        strncpy(appInfoPath + strlen(PATH_ROOT), appId, MAX_APPID);
                }
-               else
-               {
-                       strncpy(appInfoPath + strlen(PATH_ROOT2), appId, MAX_APPID);
-               }
 #endif
-
                // app root directory file descriptor
                __appRootDirFd = open(appInfoPath, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
 
@@ -187,7 +185,7 @@ _AppInfo::Construct(const char* appId, const char* exeName, int argc, char* argv
                SysLog(NID_APP, "App root directory (%s:%d) open.", appInfoPath, __appRootDirFd);
 
                int fd = openat(__appRootDirFd, APPINFO_FILE_PATH, O_RDONLY);
-               SysAssert(fd != -1);
+               SysAssertf(fd != -1, "Failed to open info file, errno: %d (%s)", errno, strerror(errno));
 
                pFile = fdopen(fd, "r");
                SysTryCatch(NID_APP, pFile != NULL, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Opening appinfo file (%s) failed : %s.", appInfoPath, strerror(errno));