mirror of
https://github.com/znc/znc.git
synced 2026-05-02 03:22:33 +02:00
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>
This commit is contained in:
22
znc.cpp
22
znc.cpp
@@ -255,9 +255,9 @@ bool CZNC::WriteISpoof(CUser* pUser) {
|
|||||||
if (m_pISpoofLockFile != NULL)
|
if (m_pISpoofLockFile != NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!m_sISpoofFile.empty()) {
|
if (!GetISpoofFile().empty()) {
|
||||||
m_pISpoofLockFile = new CFile;
|
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));
|
DEBUG("Couldn't open and lock ISpoofFile: " << strerror(errno));
|
||||||
delete m_pISpoofLockFile;
|
delete m_pISpoofLockFile;
|
||||||
m_pISpoofLockFile = NULL;
|
m_pISpoofLockFile = NULL;
|
||||||
@@ -283,7 +283,7 @@ bool CZNC::WriteISpoof(CUser* pUser) {
|
|||||||
if (sData == m_sISpoofFormat) {
|
if (sData == m_sISpoofFormat) {
|
||||||
sData.Replace("%", pUser->GetIdent());
|
sData.Replace("%", pUser->GetIdent());
|
||||||
}
|
}
|
||||||
DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_sISpoofFile + "]");
|
DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]");
|
||||||
m_pISpoofLockFile->Write(sData + "\n");
|
m_pISpoofLockFile->Write(sData + "\n");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -293,17 +293,15 @@ void CZNC::ReleaseISpoof() {
|
|||||||
if (m_pISpoofLockFile == NULL)
|
if (m_pISpoofLockFile == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_sISpoofFile.empty()) {
|
if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) {
|
||||||
if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) {
|
DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_pISpoofLockFile->GetLongName() + "]");
|
||||||
DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_sISpoofFile + "]");
|
m_pISpoofLockFile->Write(m_sOrigISpoof);
|
||||||
m_pISpoofLockFile->Write(m_sOrigISpoof);
|
} else {
|
||||||
} else {
|
DEBUG("Error while restoring ISpoof: " << strerror(errno));
|
||||||
DEBUG("Error while restoring ISpoof: " << strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sOrigISpoof = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_sOrigISpoof = "";
|
||||||
|
|
||||||
delete m_pISpoofLockFile;
|
delete m_pISpoofLockFile;
|
||||||
m_pISpoofLockFile = NULL;
|
m_pISpoofLockFile = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user