Fix the boiler plate codes
[platform/framework/native/appfw.git] / src / io / FIo_FileImpl.cpp
index 5837696..014c8bd 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);
@@ -567,22 +566,12 @@ _FileImpl::GetAttributes(const String& filePath, FileAttributes& attribute)
 String
 _FileImpl::GetFileName(const String& filePath)
 {
-       String fileName;
-       SysTryReturn(NID_IO, VerifyFilePathCompatibility(filePath, _AppInfo::IsOspCompat()) == true, fileName, E_INVALID_ARG,
-                       "[E_INVALID_ARG] The length of the specified filePath (%ls) is zero or exceeds system limitations.",
-                       filePath.GetPointer());
-
        return _FileUtil::GetFileName(filePath);
 }
 
 String
 _FileImpl::GetFileExtension(const String& filePath)
 {
-       String extName;
-       SysTryReturn(NID_IO, VerifyFilePathCompatibility(filePath, _AppInfo::IsOspCompat()) == true, extName, E_INVALID_ARG,
-                       "[E_INVALID_ARG] The length of the specified filePath (%ls) is zero or exceeds system limitations.",
-                       filePath.GetPointer());
-
        return _FileUtil::GetFileExtension(filePath);
 }
 
@@ -683,7 +672,7 @@ _FileImpl::PrepareDataCaging(const String& appRootPath, const String& pkgId)
        bool internalInstalled = true;
        result r = E_SUCCESS;
 
-       SysLog(NID_IO, "[data_caging] PrepareDataCaging() was called by installer backend, appRootPath: %ls, packageId: %ls",
+       SysSecureLog(NID_IO, "[data_caging] PrepareDataCaging() was called by installer backend, appRootPath: %ls, packageId: %ls",
                        appRootPath.GetPointer(), pkgId.GetPointer());
 
        if (CleanDirectories(appRootPath, pkgId) == false)
@@ -717,7 +706,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
@@ -796,6 +785,7 @@ _FileImpl::FinalizeDataCaging(const String& appRootPath) // for 2.0 app
                //{ "./packaging" },
                { "./proc" },
                { "./sbin" },
+               { "./smack" },
                { "./srv" },
                { "./sys/kernel/debug" },
                { "./sys" },
@@ -935,7 +925,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 +1063,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,
@@ -1172,6 +1166,7 @@ _FileImpl::CreateSlpDirectories(void)
                //{ "./packaging", 0000, false },
                { "./proc", 0000, false },
                { "./sbin", 0000, false },
+               { "./smack", 0000, false },
                { "./srv", 0000, false },
                { "./sys", 0000, false },
                { "./tmp", 0000, false },