Permalink
Browse files

Some minor cleanup

This makes the code use GetISpoofFile() instead of accessing m_sISpoofFile
directly. Additonally, CFile::GetLongName() is used for printing the filepath.

(This also removes an useless if branch, because nothing here cares if
m_sISpoofFile is empty, we just need the lock file.)

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information...
1 parent cd78225 commit f69aeff3d9ef15c7bef34daca9dd93327f23a087 @psychon psychon committed Feb 20, 2011
Showing with 10 additions and 12 deletions.
  1. +10 −12 znc.cpp
View
22 znc.cpp
@@ -255,9 +255,9 @@ bool CZNC::WriteISpoof(CUser* pUser) {
if (m_pISpoofLockFile != NULL)
return false;
- if (!m_sISpoofFile.empty()) {
+ if (!GetISpoofFile().empty()) {
m_pISpoofLockFile = new CFile;
- if (!m_pISpoofLockFile->TryExLock(m_sISpoofFile, O_RDWR | O_CREAT)) {
+ if (!m_pISpoofLockFile->TryExLock(GetISpoofFile(), O_RDWR | O_CREAT)) {
DEBUG("Couldn't open and lock ISpoofFile: " << strerror(errno));
delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL;
@@ -283,7 +283,7 @@ bool CZNC::WriteISpoof(CUser* pUser) {
if (sData == m_sISpoofFormat) {
sData.Replace("%", pUser->GetIdent());
}
- DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_sISpoofFile + "]");
+ DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]");
m_pISpoofLockFile->Write(sData + "\n");
}
return true;
@@ -293,17 +293,15 @@ void CZNC::ReleaseISpoof() {
if (m_pISpoofLockFile == NULL)
return;
- if (!m_sISpoofFile.empty()) {
- if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) {
- DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_sISpoofFile + "]");
- m_pISpoofLockFile->Write(m_sOrigISpoof);
- } else {
- DEBUG("Error while restoring ISpoof: " << strerror(errno));
- }
-
- m_sOrigISpoof = "";
+ if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) {
+ DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]");
+ m_pISpoofLockFile->Write(m_sOrigISpoof);
+ } else {
+ DEBUG("Error while restoring ISpoof: " << strerror(errno));
}
+ m_sOrigISpoof = "";
+
delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL;
}

0 comments on commit f69aeff

Please sign in to comment.