本文整理汇总了C++中CFile::IsReg方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::IsReg方法的具体用法?C++ CFile::IsReg怎么用?C++ CFile::IsReg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::IsReg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenFile
CFile* CDCCSock::OpenFile(bool bWrite) {
if ((m_pFile) || (m_sLocalFile.empty())) {
m_pModule->PutModule(((bWrite) ? "DCC <- [" : "DCC -> [") + m_sRemoteNick + "][" + m_sLocalFile + "] - Unable to open file.");
return NULL;
}
m_pFile = new CFile(m_sLocalFile);
if (bWrite) {
if (m_pFile->Exists()) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC <- [" + m_sRemoteNick + "] - File already exists [" + m_sLocalFile + "]");
return NULL;
}
if (!m_pFile->Open(O_WRONLY | O_TRUNC | O_CREAT)) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC <- [" + m_sRemoteNick + "] - Could not open file [" + m_sLocalFile + "]");
return NULL;
}
} else {
if (!m_pFile->IsReg()) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - Not a file [" + m_sLocalFile + "]");
return NULL;
}
if (!m_pFile->Open()) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - Could not open file [" + m_sLocalFile + "]");
return NULL;
}
// The DCC specs only allow file transfers with files smaller
// than 4GiB (see ReadData()).
unsigned long long uFileSize = m_pFile->GetSize();
if (uFileSize > (unsigned long long) 0xffffffff) {
delete m_pFile;
m_pFile = NULL;
m_pModule->PutModule("DCC -> [" + m_sRemoteNick + "] - File too large (>4 GiB) [" + m_sLocalFile + "]");
return NULL;
}
m_uFileSize = (unsigned long) uFileSize;
}
m_sFileName = m_pFile->GetShortName();
return m_pFile;
}
示例2: OpenFile
CFile* CDCCSock::OpenFile(bool bWrite) {
if ((m_pFile) || (m_sLocalFile.empty())) {
if (m_bSend) {
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Unable to open file.")(
m_sFileName, m_sRemoteNick));
} else {
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Unable to open file.")(
m_sFileName, m_sRemoteNick));
}
return nullptr;
}
m_pFile = new CFile(m_sLocalFile);
if (bWrite) {
if (m_pFile->Exists()) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: File already exists.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
if (!m_pFile->Open(O_WRONLY | O_TRUNC | O_CREAT)) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Receiving [{1}] from [{2}]: Could not open file.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
} else {
if (!m_pFile->IsReg()) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Not a file.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
if (!m_pFile->Open()) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: Could not open file.")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
// The DCC specs only allow file transfers with files smaller
// than 4GiB (see ReadData()).
unsigned long long uFileSize = m_pFile->GetSize();
if (uFileSize > (unsigned long long)0xffffffffULL) {
delete m_pFile;
m_pFile = nullptr;
m_pModule->PutModule(
t_f("Sending [{1}] to [{2}]: File too large (>4 GiB).")(
m_sFileName, m_sRemoteNick));
return nullptr;
}
m_uFileSize = uFileSize;
}
m_sFileName = m_pFile->GetShortName();
return m_pFile;
}