summaryrefslogtreecommitdiffstats
path: root/lib/Utils
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-02-19 14:31:19 +0100
committerZdenek Prikryl <zprikryl@redhat.com>2009-02-19 14:31:19 +0100
commit72ef5336c82cd667332d726a6d6432e7ec8e677c (patch)
treed3241bdacc70d18b8917fd2e23919ad720af8adf /lib/Utils
parentb6b9b225850604848308803ba5de5d898f68d891 (diff)
downloadabrt-72ef5336c82cd667332d726a6d6432e7ec8e677c.tar.gz
abrt-72ef5336c82cd667332d726a6d6432e7ec8e677c.tar.xz
abrt-72ef5336c82cd667332d726a6d6432e7ec8e677c.zip
new delete function
Diffstat (limited to 'lib/Utils')
-rw-r--r--lib/Utils/DebugDump.cpp21
-rw-r--r--lib/Utils/DebugDump.h4
2 files changed, 17 insertions, 8 deletions
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 <fstream>
#include <iostream>
#include <sstream>
@@ -30,7 +29,6 @@
#include <sys/utsname.h>
#include <limits.h>
#include <fcntl.h>
-#include <sys/procfs.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
@@ -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();
}
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index 08e26434..eecc89d4 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -59,12 +59,14 @@ class CDebugDump
void Lock();
void UnLock();
+ void DeleteFileDir(const std::string& pDir);
+
public:
CDebugDump();
void Open(const std::string& pDir);
void Create(const std::string& pDir);
- void Delete(const std::string& pDir);
+ void Delete();
void Close();
void SaveProc(const std::string& pPID);