Remove all sub-files deliveried in shared/data and shared/trusted directory for OSP...
authorHyunbin Lee <hyunbin.lee@samsung.com>
Fri, 12 Apr 2013 02:26:54 +0000 (11:26 +0900)
committerHyunbin Lee <hyunbin.lee@samsung.com>
Fri, 12 Apr 2013 02:28:06 +0000 (11:28 +0900)
Change-Id: I015ed586fffe2da1fb74082513d947d4e29f9843
Signed-off-by: Hyunbin Lee <hyunbin.lee@samsung.com>
src/io/FIo_FileImpl.cpp
src/io/inc/FIo_FileImpl.h

index 5837696..ce3749f 100644 (file)
@@ -717,7 +717,7 @@ _FileImpl::PrepareDataCaging(const String& appRootPath, const String& pkgId)
                SysTryCatch(NID_IO, chdir(pAppRootPath.get()) == 0, r = E_SYSTEM, E_SYSTEM,
                                "[E_SYSTEM] chdir() was failed (%s), path: %s", strerror(errno), pAppRootPath.get());
 
-               SysTryCatch(NID_IO, CreateOspInternalDirectories(pkgId) == true, r = E_SYSTEM, E_SYSTEM,
+               SysTryCatch(NID_IO, CreateOspInternalDirectories(appRootPath, pkgId) == true, r = E_SYSTEM, E_SYSTEM,
                                "[E_SYSTEM] fail to create OSP Internal directories");
        }
        else
@@ -935,7 +935,7 @@ CATCH:
 }
 
 bool
-_FileImpl::CreateOspInternalDirectories(const String& pkgId) // for 2.0 app
+_FileImpl::CreateOspInternalDirectories(const String& appRootPath, const String& pkgId) // for 2.0 app
 {
        unsigned int i = 0;
        int ret = 0;
@@ -1073,12 +1073,16 @@ _FileImpl::CreateOspInternalDirectories(const String& pkgId) // for 2.0 app
                SysTryReturn(NID_IO, system(chownCmd) != -1, false, E_SYSTEM, "[E_SYSTEM] chown() failed");
        }
 #endif
-       ret = remove("./shared/data");
-       SysTryReturn(NID_IO, ret == 0 || errno == ENOENT, false, E_SYSTEM,
-                       "[E_SYSTEM] remove() failed, errno: %d (%s), path: ./shared/data", errno, strerror(errno));
-       ret = remove("./shared/trusted");
-       SysTryReturn(NID_IO, ret == 0 || errno == ENOENT, false, E_SYSTEM,
-                       "[E_SYSTEM] remove() failed, errno: %d (%s), path: ./shared/trusted", errno, strerror(errno));
+       String appSharedDataPath(appRootPath);
+       appSharedDataPath.Append(L"/shared/data");
+
+       String appSharedTrustedPath(appRootPath);
+       appSharedTrustedPath.Append(L"/shared/trusted");
+
+       SysTryReturn(NID_IO, Directory::Remove(appSharedDataPath, true) == E_SUCCESS, false, E_SYSTEM,
+                       "[E_SYSTEM] Failed to remove path (%ls)", appSharedDataPath.GetPointer());
+       SysTryReturn(NID_IO, Directory::Remove(appSharedTrustedPath, true) == E_SUCCESS, false, E_SYSTEM,
+                       "[E_SYSTEM] Failed to remove path (%ls)", appSharedTrustedPath.GetPointer());
 
        ret = symlink(pOspShareAppIdPath.get(), "./shared/data");
        SysTryReturn(NID_IO, ret == 0, false, E_SYSTEM,
index 6ed64c7..b1cacd4 100644 (file)
@@ -205,7 +205,7 @@ private:
 
        static bool VerifyFilePath(const Tizen::Base::String& filePath, _FilePathType pathType);
 
-       static bool CreateOspInternalDirectories(const Tizen::Base::String& pkgId);
+       static bool CreateOspInternalDirectories(const Tizen::Base::String& appRootPath, const Tizen::Base::String& pkgId);
 
        static bool CreateOspExternalDirectories(const Tizen::Base::String& pkgId);