summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-02-11 10:22:09 +0100
committerZdenek Prikryl <zprikryl@redhat.com>2009-02-11 10:22:09 +0100
commitc37394c5d4517b36ec1826668f7b7d75e94dc14a (patch)
treea30c58e3f11a66d0d31ef1a9bb4754ddeddd3887 /lib
parent021c815746d47f7fe161a27f709debfd2491eaf7 (diff)
downloadabrt-c37394c5d4517b36ec1826668f7b7d75e94dc14a.tar.gz
abrt-c37394c5d4517b36ec1826668f7b7d75e94dc14a.tar.xz
abrt-c37394c5d4517b36ec1826668f7b7d75e94dc14a.zip
added new constructionr and new method for getting time
Diffstat (limited to 'lib')
-rw-r--r--lib/Utils/DebugDump.cpp24
-rw-r--r--lib/Utils/DebugDump.h8
2 files changed, 27 insertions, 5 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp
index 9fd887fd..e0f88c4c 100644
--- a/lib/Utils/DebugDump.cpp
+++ b/lib/Utils/DebugDump.cpp
@@ -32,6 +32,7 @@
#include <fcntl.h>
#include <sys/procfs.h>
#include <ctype.h>
+#include <time.h>
CDebugDump::CDebugDump() :
m_sDebugDumpDir("")
@@ -75,8 +76,16 @@ void CDebugDump::Create(const std::string& pDir)
throw "CDebugDump::Create(): Cannot create dir: " + pDir;
}
SaveEnvironment();
+ SaveTime();
}
+void CDebugDump::Create(const std::string& pDir, const std::string& pPID)
+{
+ Create(pDir);
+ SaveProc(pPID);
+}
+
+
void CDebugDump::Delete(const std::string& pDir)
{
if (!ExistFileDir(pDir))
@@ -122,6 +131,18 @@ void CDebugDump::SaveEnvironment()
}
}
+void CDebugDump::SaveTime()
+{
+ std::stringstream ss;
+ time_t t = time(NULL);
+ if (((time_t) -1) == t)
+ {
+ throw std::string("CDebugDump::SaveTime(): Cannot get local time.");
+ }
+ ss << t;
+ SaveText(FILENAME_TIME, ss.str());
+}
+
void CDebugDump::LoadTextFile(const std::string& pPath, std::string& pData)
{
std::ifstream fIn;
@@ -236,10 +257,11 @@ void CDebugDump::SaveProc(const std::string& pPID)
while (!packages.SearchFile(executable)) {}
while (!packages.GetStatus()) {}
std::string package = packages.GetSearchFileReply();
+
SaveText(FILENAME_PACKAGE, package);
path = "/proc/"+pPID+"/status";
- std::string uid = "0";
+ std::string uid = "";
int ii = 0;
LoadTextFile(path, data);
diff --git a/lib/Utils/DebugDump.h b/lib/Utils/DebugDump.h
index c8eef157..11574e95 100644
--- a/lib/Utils/DebugDump.h
+++ b/lib/Utils/DebugDump.h
@@ -43,7 +43,8 @@ class CDebugDump
std::string m_sDebugDumpDir;
void SaveEnvironment();
-
+ void SaveTime();
+ void SaveProc(const std::string& pPID);
void LoadTextFile(const std::string& pName, std::string& pData);
void LoadBinaryFile(const std::string& pName, char** pData, unsigned int* pSize);
@@ -57,16 +58,15 @@ class CDebugDump
CDebugDump();
void Open(const std::string& pDir);
void Create(const std::string& pDir);
+ void Create(const std::string& pDir, const std::string& pPID);
void Delete(const std::string& pDir);
- bool Exist(const std::string& pPath);
+ bool Exist(const std::string& pFileName);
void LoadText(const std::string& pName, std::string& pData);
void LoadBinary(const std::string& pName, char** pData, unsigned int* pSize);
void SaveText(const std::string& pName, const std::string& pData);
void SaveBinary(const std::string& pName, const char* pData, const unsigned int pSize);
-
- void SaveProc(const std::string& pPID);
};
#endif /*DEBUGDUMP_H_*/