diff options
author | Dongeup Ham <dongeup.ham@samsung.com> | 2012-11-06 12:55:34 +0900 |
---|---|---|
committer | Dongeup Ham <dongeup.ham@samsung.com> | 2012-11-06 12:55:34 +0900 |
commit | baad189f97c525a0ee50be07cd5ac82253b4a2da (patch) | |
tree | 717e7c6b4f09fd2bec5c6aeb8af015474bda147f /src | |
parent | b3a15131cb80364229ede77333775da1e6a26bd4 (diff) | |
download | installer-baad189f97c525a0ee50be07cd5ac82253b4a2da.tar.gz installer-baad189f97c525a0ee50be07cd5ac82253b4a2da.tar.bz2 installer-baad189f97c525a0ee50be07cd5ac82253b4a2da.zip |
Implementation to remove real directory path.
Change-Id: I4aecf97e8be68ef253d730dce38cc324ff592671
Diffstat (limited to 'src')
-rwxr-xr-x | src/Manager/InstallerManager.cpp | 24 | ||||
-rwxr-xr-x | src/Manager/InstallerManager.h | 2 | ||||
-rwxr-xr-x | src/Step/UninstallStep.cpp | 9 | ||||
-rwxr-xr-x | src/Util/InstallerUtil.cpp | 16 | ||||
-rwxr-xr-x | src/Util/InstallerUtil.h | 1 | ||||
-rwxr-xr-x | src/backend/backend.cpp | 8 |
6 files changed, 40 insertions, 20 deletions
diff --git a/src/Manager/InstallerManager.cpp b/src/Manager/InstallerManager.cpp index 7c682c8..9f53bcf 100755 --- a/src/Manager/InstallerManager.cpp +++ b/src/Manager/InstallerManager.cpp @@ -656,26 +656,20 @@ InstallerManager::ParseCommandArg(int argc, char **argv, int *mode, char *buf, b } bool -InstallerManager::RemoveGarbage(const char* pDirectory) +InstallerManager::RemoveGarbage(const String& filePath) { - char pkgname[1024] = {0}; + AppLogTag(OSP_INSTALLER, "RemoveGarbage Directory = [%ls]", filePath.GetPointer()); - if (pDirectory == null) + String realPath; + if (InstallerUtil::IsSymlink(filePath) == true) { - return false; - } - - char* pStart = strrchr(const_cast<char*>(pDirectory), '/'); - if (pStart == null) - { - return false; + if (InstallerUtil::GetRealPath(filePath, realPath) == true) + { + InstallerUtil::Remove(realPath); + } } - strcpy(pkgname, pStart + 1); - AppLogTag(OSP_INSTALLER, "pkgname = %s", pkgname); - - AppLogTag(OSP_INSTALLER, "Remove Directory=(%s)", pDirectory); - InstallerUtil::Remove(pDirectory); + InstallerUtil::Remove(filePath); return true; } diff --git a/src/Manager/InstallerManager.h b/src/Manager/InstallerManager.h index f61dcef..9e4a05f 100755 --- a/src/Manager/InstallerManager.h +++ b/src/Manager/InstallerManager.h @@ -47,7 +47,7 @@ public: int Request(const Osp::Base::String& path, InstallerOperation op, RequesterType requesterType, bool hybridService = false); int RequestRecursiveDirectory(const Osp::Base::String& path, int& errorType); - bool RemoveGarbage(const char* pDirectory); + bool RemoveGarbage(const Osp::Base::String& filePath); int RequestByCommand(int argc, char **argv); int ReqeustByTest(void); diff --git a/src/Step/UninstallStep.cpp b/src/Step/UninstallStep.cpp index 1e5f4d2..2b024a4 100755 --- a/src/Step/UninstallStep.cpp +++ b/src/Step/UninstallStep.cpp @@ -205,6 +205,15 @@ UninstallStep::OnStateRemoveDir(void) } else { + String realPath; + if (InstallerUtil::IsSymlink(rootPath) == true) + { + if (InstallerUtil::GetRealPath(rootPath, realPath) == true) + { + InstallerUtil::Remove(realPath); + } + } + InstallerUtil::Remove(rootPath); } diff --git a/src/Util/InstallerUtil.cpp b/src/Util/InstallerUtil.cpp index ef67d72..36fa0cf 100755 --- a/src/Util/InstallerUtil.cpp +++ b/src/Util/InstallerUtil.cpp @@ -188,6 +188,22 @@ InstallerUtil::IsSymlink(const Osp::Base::String& filePath) } bool +InstallerUtil::GetRealPath(const String& filePath, String& realPath) +{ + char* pRealPath = null; + std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(filePath)); + TryReturn(pFilePath, false, "[osp-installer] pFilePath is null"); + + char tmpPath[PATH_MAX] = {0}; + pRealPath = realpath(pFilePath.get(), tmpPath); + TryReturn(pRealPath, false, "[osp-installer] pRealPath is null"); + + realPath = tmpPath; + + return true; +} + +bool InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath) { int err = -1; diff --git a/src/Util/InstallerUtil.h b/src/Util/InstallerUtil.h index 0386ae5..2fae278 100755 --- a/src/Util/InstallerUtil.h +++ b/src/Util/InstallerUtil.h @@ -48,6 +48,7 @@ public: static bool Copy(const Osp::Base::String& srcFilePath, const Osp::Base::String& destFilePath); static bool CopyDirectory(const Osp::Base::String& srcFilePath, const Osp::Base::String& destFilePath); static bool IsSymlink(const Osp::Base::String& filePath); + static bool GetRealPath(const Osp::Base::String& filePath, Osp::Base::String& realPath); static bool CreateSymlink(const Osp::Base::String& oldPath, const Osp::Base::String& newPath); static bool ChangeMode(const Osp::Base::String& filePath, int mode); diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 320d505..b72cdff 100755 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -109,10 +109,10 @@ main(int argc, char **argv) AppLogTag(OSP_INSTALLER, "_pi is null"); } - if (errorType != 0) - { - manager.RemoveGarbage(pkg_path); - } +// if (errorType != 0) +// { +// manager.RemoveGarbage(path); +// } __osp_installer_report_result(appId, errorType); manager.PrintResult(); |