本文整理汇总了C++中CFile::Copy方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::Copy方法的具体用法?C++ CFile::Copy怎么用?C++ CFile::Copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::Copy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadModule
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;
}
示例2: MoveRegistry
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;
}
示例3: ParseConfig
//.........这里部分代码省略.........
}
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;
}
示例4: Copy
bool CDirectory::Copy(_INOUT CDirectory& rSource, _INOUT CDirectory& rDestination, _IN bool bOverwriteExisting)
{
#ifdef WIN32
if (!rDestination.Create(bOverwriteExisting))
{
SCFError(ErrorDirectoryFailedCopy);
return false;
}
CVector<CString> Directories;
CVector<CString> Files;
if (!rSource.Read(&Files, &Directories))
{
Directories.AllDelete();
Files.AllDelete();
SCFError(ErrorDirectoryFailedCopy);
return false;
}
CString csTerminator(STRING("\\"));
for (UINT i = 0; i < Directories.Size(); i++)
{
CDirectory DirectorySource (rSource.PathFull() + (CString&)(Directories[i]) + csTerminator);
CDirectory DirectoryDestination(rDestination.PathFull() + (CString&)(Directories[i]) + csTerminator);
if (!Copy(DirectorySource, DirectoryDestination, bOverwriteExisting))
{
Directories.AllDelete();
Files.AllDelete();
SCFError(ErrorDirectoryFailedCopy);
return false;
}
}
for (UINT i = 0; i < Files.Size(); i++)
{
CFile FileSource (rSource.PathFull() + (CString&)(Files[i]));
CFile FileDestination(rDestination.PathFull() + (CString&)(Files[i]));
if (!FileSource.Copy(FileDestination, bOverwriteExisting))
{
Directories.AllDelete();
Files.AllDelete();
SCFError(ErrorDirectoryFailedCopy);
return false;
}
}
Directories.AllDelete();
Files.AllDelete();
return true;
#else
//TODO:
return false;
#endif // WIN32
}