diff options
author | Zdenek Prikryl <zprikryl@redhat.com> | 2009-05-28 14:05:48 +0200 |
---|---|---|
committer | Zdenek Prikryl <zprikryl@redhat.com> | 2009-05-28 14:05:48 +0200 |
commit | c861d5917a14128364ee8c46b71e490a57cc7640 (patch) | |
tree | 762917abb2afd219c6b50dae2e3f118e4f6de768 /lib/Utils/DebugDump.cpp | |
parent | e81fcd94aaca34958b837ca9ea752ab74f387239 (diff) | |
download | abrt-c861d5917a14128364ee8c46b71e490a57cc7640.tar.gz abrt-c861d5917a14128364ee8c46b71e490a57cc7640.tar.xz abrt-c861d5917a14128364ee8c46b71e490a57cc7640.zip |
addded removing useless back slashed from debug dump dir name
Diffstat (limited to 'lib/Utils/DebugDump.cpp')
-rw-r--r-- | lib/Utils/DebugDump.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index 1b7fbd1c..0ac9d796 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -61,11 +61,11 @@ void CDebugDump::Open(const std::string& pDir) { throw CABRTException(EXCEP_ERROR, "CDebugDump::CDebugDump(): DebugDump is already opened."); } - m_sDebugDumpDir = pDir; + m_sDebugDumpDir = RemoveBackSlashes(pDir); std::string lockPath = m_sDebugDumpDir + "/.lock"; - if (!ExistFileDir(pDir)) + if (!ExistFileDir(m_sDebugDumpDir)) { - throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::CDebugDump(): "+pDir+" does not exist."); + throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::CDebugDump(): "+m_sDebugDumpDir+" does not exist."); } Lock(); m_bOpened = true; @@ -181,20 +181,20 @@ void CDebugDump::Create(const std::string& pDir) throw CABRTException(EXCEP_ERROR, "CDebugDump::CDebugDump(): DebugDump is already opened."); } - m_sDebugDumpDir = pDir; - std::string lockPath = pDir + ".lock"; - if (ExistFileDir(pDir)) + m_sDebugDumpDir = RemoveBackSlashes(pDir); + std::string lockPath = m_sDebugDumpDir + ".lock"; + if (ExistFileDir(m_sDebugDumpDir)) { - throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::CDebugDump(): "+pDir+" already exists."); + throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::CDebugDump(): "+m_sDebugDumpDir+" already exists."); } Lock(); m_bOpened = true; - if (mkdir(pDir.c_str(), 0755) == -1) + if (mkdir(m_sDebugDumpDir.c_str(), 0755) == -1) { UnLock(); - throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Create(): Cannot create dir: " + pDir); + throw CABRTException(EXCEP_DD_OPEN, "CDebugDump::Create():m_sDebugDumpDir Cannot create dir: " + pDir); } SaveKernelArchitectureRelease(); @@ -268,6 +268,16 @@ bool CDebugDump::IsTextFile(const std::string& pName) return isText; } +std::string CDebugDump::RemoveBackSlashes(const std::string& pDir) +{ + std::string ret = pDir; + while (ret[ret.length() - 1] == '/') + { + ret = ret.substr(0, ret.length() - 2); + } + return ret; +} + void CDebugDump::Delete() { if (!ExistFileDir(m_sDebugDumpDir)) |