当前位置: 首页>>代码示例>>C++>>正文


C++ CFile::Exists方法代码示例

本文整理汇总了C++中CFile::Exists方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::Exists方法的具体用法?C++ CFile::Exists怎么用?C++ CFile::Exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::Exists方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CFile

bool CUser::LoadModule(const CString& sModName, const CString& sArgs,
                       const CString& sNotice, CString& sError) {
    bool bModRet = true;
    CString sModRet;

    CModInfo ModInfo;
    if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sModName, sModRet)) {
        sError = "Unable to find modinfo [" + sModName + "] [" + sModRet + "]";
        return false;
    }

    CUtils::PrintAction(sNotice);

    if (!ModInfo.SupportsType(CModInfo::UserModule) &&
        ModInfo.SupportsType(CModInfo::NetworkModule)) {
        CUtils::PrintMessage(
            "NOTICE: Module [" + sModName +
            "] is a network module, loading module for all networks in user.");

        // Do they have old NV?
        CFile fNVFile =
            CFile(GetUserPath() + "/moddata/" + sModName + "/.registry");

        for (CIRCNetwork* pNetwork : m_vIRCNetworks) {
            // Check whether the network already has this module loaded (#954)
            if (pNetwork->GetModules().FindModule(sModName)) {
                continue;
            }

            if (fNVFile.Exists()) {
                CString sNetworkModPath =
                    pNetwork->GetNetworkPath() + "/moddata/" + sModName;
                if (!CFile::Exists(sNetworkModPath)) {
                    CDir::MakeDir(sNetworkModPath);
                }

                fNVFile.Copy(sNetworkModPath + "/.registry");
            }

            bModRet = pNetwork->GetModules().LoadModule(
                sModName, sArgs, CModInfo::NetworkModule, this, pNetwork,
                sModRet);
            if (!bModRet) {
                break;
            }
        }
    } else {
        bModRet = GetModules().LoadModule(sModName, sArgs, CModInfo::UserModule,
                                          this, nullptr, sModRet);
    }

    if (!bModRet) {
        sError = sModRet;
    }
    return bModRet;
}
开发者ID:Un1matr1x,项目名称:znc,代码行数:56,代码来源:User.cpp

示例2: 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;
}
开发者ID:BGCX261,项目名称:znc-msvc-svn-to-git,代码行数:54,代码来源:dcc.cpp

示例3: CFile

bool CModule::MoveRegistry(const CString& sPath) {
	if (m_sSavePath != sPath) {
		CFile fOldNVFile = CFile(m_sSavePath + "/.registry");
		if (!fOldNVFile.Exists()) {
			return false;
		}
		if (!CFile::Exists(sPath) && !CDir::MakeDir(sPath)) {
			return false;
		}
		fOldNVFile.Copy(sPath + "/.registry");
		m_sSavePath = sPath;
		return true;
	}
	return false;
}
开发者ID:ylfchild,项目名称:znc,代码行数:15,代码来源:Modules.cpp

示例4: FindMedia

/////////////////////////////////////////////////////////////
/// Cherche un fichier dans les r�pertoires de recherche
///
/// \param Filename : Chemin du media
///
/// \return Chemin complet du media, exception si non trouv�
///
////////////////////////////////////////////////////////////
CFile CMediaManager::FindMedia(const CFile& Filename) const
{
	// Parcours de la liste des chemins de recherche
	for (std::set<std::string>::const_iterator i = m_Paths.begin();
			i != m_Paths.end(); ++i)
			{
		CFile RetFile = *i + Filename.Fullname();
		if (RetFile.Exists())
			return RetFile;
	}

	//// DEBUG
	Logger::Log() << "===== PATH : \n";
	for (std::set<std::string>::const_iterator i = m_Paths.begin();
			i != m_Paths.end(); ++i)
			{
		Logger::Log() << "  * " << *i + Filename.Fullname() << "\n";
	}

	// Si le fichier est introuvable, on lance une exception
	throw CLoadingFailed(Filename.Fullname(),
			"Fichier introuvable dans les repertoires de recherche");
}
开发者ID:beltegeuse,项目名称:Amaterasu3D,代码行数:31,代码来源:MediaManager.cpp

示例5: 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;
}
开发者ID:aszrul,项目名称:znc,代码行数:72,代码来源:dcc.cpp

示例6: sizeof


//.........这里部分代码省略.........
	}
	if (subIt != subConf.end()) {
		sError = "Password defined more than once";
		CUtils::PrintError(sError);
		return false;
	}

	pConfig->FindSubConfig("network", subConf);
	for (subIt = subConf.begin(); subIt != subConf.end(); ++subIt) {
		const CString& sNetworkName = subIt->first;

		CIRCNetwork *pNetwork = FindNetwork(sNetworkName);

		if (!pNetwork) {
			pNetwork = new CIRCNetwork(this, sNetworkName);
		}

		if (!pNetwork->ParseConfig(subIt->second.m_pSubConfig, sError)) {
			return false;
		}
	}

	if (pConfig->FindStringVector("server", vsList, false) || pConfig->FindStringVector("chan", vsList, false) || pConfig->FindSubConfig("chan", subConf, false)) {
		CIRCNetwork *pNetwork = FindNetwork("user");
		if (!pNetwork) {
			pNetwork = AddNetwork("user");
		}

		if (pNetwork) {
			CUtils::PrintMessage("NOTICE: Found deprecated config, upgrading to a network");

			if (!pNetwork->ParseConfig(pConfig, sError, true)) {
				return false;
			}
		}
	}

	pConfig->FindStringVector("loadmodule", vsList);
	for (vit = vsList.begin(); vit != vsList.end(); ++vit) {
		sValue = *vit;
		CString sModName = sValue.Token(0);

		// XXX Legacy crap, added in ZNC 0.089
		if (sModName == "discon_kick") {
			CUtils::PrintMessage("NOTICE: [discon_kick] was renamed, loading [disconkick] instead");
			sModName = "disconkick";
		}

		// XXX Legacy crap, added in ZNC 0.099
		if (sModName == "fixfreenode") {
			CUtils::PrintMessage("NOTICE: [fixfreenode] doesn't do anything useful anymore, ignoring it");
			continue;
		}

		CUtils::PrintAction("Loading Module [" + sModName + "]");
		CString sModRet;
		CString sArgs = sValue.Token(1, true);
		bool bModRet;

		CModInfo ModInfo;
		if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sModName, sModRet)) {
			sError = "Unable to find modinfo [" + sModName + "] [" + sModRet + "]";
			return false;
		}

		if (!ModInfo.SupportsType(CModInfo::UserModule) && ModInfo.SupportsType(CModInfo::NetworkModule)) {
			CUtils::PrintMessage("NOTICE: Module [" + sModName + "] is a network module, loading module for all networks in user.");

			// Do they have old NV?
			CFile fNVFile = CFile(GetUserPath() + "/moddata/" + sModName + "/.registry");

			for (vector<CIRCNetwork*>::iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
				if (fNVFile.Exists()) {
					CString sNetworkModPath = (*it)->GetNetworkPath() + "/moddata/" + sModName;
					if (!CFile::Exists(sNetworkModPath)) {
						CDir::MakeDir(sNetworkModPath);
					}

					fNVFile.Copy(sNetworkModPath + "/.registry");
				}

				bModRet = (*it)->GetModules().LoadModule(sModName, sArgs, CModInfo::NetworkModule, this, *it, sModRet);
				if (!bModRet) {
					break;
				}
			}
		} else {
			bModRet = GetModules().LoadModule(sModName, sArgs, CModInfo::UserModule, this, NULL, sModRet);
		}

		CUtils::PrintStatus(bModRet, sModRet);
		if (!bModRet) {
			sError = sModRet;
			return false;
		}
		continue;
	}

	return true;
}
开发者ID:b3rend,项目名称:znc,代码行数:101,代码来源:User.cpp


注:本文中的CFile::Exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。