From 1b1d9e234abb9cbba7f722d32e7a0eb9dfe267d1 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Wed, 18 Feb 2009 17:23:26 +0100 Subject: new logic of getting package name --- lib/Utils/DebugDump.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'lib/Utils/DebugDump.cpp') diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index f09de9ea..53861622 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -93,11 +93,12 @@ void CDebugDump::Lock() m_bUnlock = false; return; } - while (ExistFileDir(lockPath)) - { - std::cerr << "CDebugDump::Lock(): waiting..." << std::endl; - usleep(10); - } + } + + while (ExistFileDir(lockPath)) + { + std::cerr << "CDebugDump::Lock(): waiting..." << std::endl; + usleep(10); } if ((m_nFD = open(lockPath.c_str(), O_RDWR | O_CREAT, 0640)) < 0) @@ -106,6 +107,7 @@ void CDebugDump::Lock() } if (lockf(m_nFD,F_LOCK, 0) < 0) { + remove(lockPath.c_str()); throw std::string("CDebugDump::Lock(): cannot lock DebugDump"); } } @@ -334,16 +336,3 @@ void CDebugDump::SaveProc(const std::string& pPID) LoadTextFile(path, data); SaveText(FILENAME_CMDLINE, data); } - -void CDebugDump::SavePackage() -{ - std::string executable; - std::string package = ""; - if (Exist(FILENAME_EXECUTABLE)) - { - CPackages packages; - LoadText(FILENAME_EXECUTABLE, executable); - package = packages.SearchFile(executable); - } - SaveText(FILENAME_PACKAGE, package); -} -- cgit From 72ef5336c82cd667332d726a6d6432e7ec8e677c Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Thu, 19 Feb 2009 14:31:19 +0100 Subject: new delete function --- lib/Utils/DebugDump.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib/Utils/DebugDump.cpp') diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 53861622..302d3be3 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -20,7 +20,6 @@ */ #include "DebugDump.h" -#include "Packages.h" #include #include #include @@ -30,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -144,13 +142,12 @@ void CDebugDump::Create(const std::string& pDir) SaveTime(); } -void CDebugDump::Delete(const std::string& pDir) +void CDebugDump::DeleteFileDir(const std::string& pDir) { if (!ExistFileDir(pDir)) { return; } - Lock(); DIR *dir = opendir(pDir.c_str()); std::string fullPath; struct dirent *dent = NULL; @@ -163,20 +160,30 @@ void CDebugDump::Delete(const std::string& pDir) fullPath = pDir + "/" + dent->d_name; if (dent->d_type == DT_DIR) { - Delete(fullPath); + DeleteFileDir(fullPath); } if (remove(fullPath.c_str()) == -1) { - throw "CDebugDump::DeleteDir(): Cannot remove file: " + fullPath; + throw "CDebugDump::DeleteFileDir(): Cannot remove file: " + fullPath; } } } closedir(dir); if (remove(pDir.c_str()) == -1) { - throw "CDebugDump::DeleteDir(): Cannot remove dir: " + fullPath; + throw "CDebugDump::DeleteFileDir(): Cannot remove dir: " + fullPath; } } +} + +void CDebugDump::Delete() +{ + if (!ExistFileDir(m_sDebugDumpDir)) + { + return; + } + Lock(); + DeleteFileDir(m_sDebugDumpDir); UnLock(); } -- cgit