本文整理汇总了C++中wxRenameFile函数的典型用法代码示例。如果您正苦于以下问题:C++ wxRenameFile函数的具体用法?C++ wxRenameFile怎么用?C++ wxRenameFile使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxRenameFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxT
void TopedApp::FinishSessionLog()
{
LogFile.close();
wxString fullName;
fullName << tpdLogDir << wxT("/tpd_previous.log");
wxFileName* lFN = new wxFileName(fullName.c_str());
lFN->Normalize();
assert(lFN->IsOk());
wxRenameFile(logFileName.c_str(), lFN->GetFullPath());
delete lFN;
}
示例2: RenameFile
bool RenameFile(const wxString& src, const wxString& dst)
{
wxFileName fname1(Manager::Get()->GetMacrosManager()->ReplaceMacros(src));
wxFileName fname2(Manager::Get()->GetMacrosManager()->ReplaceMacros(dst));
NormalizePath(fname1, wxEmptyString);
NormalizePath(fname2, wxEmptyString);
if (!SecurityAllows(_T("RenameFile"), wxString::Format(_T("%s -> %s"),
fname1.GetFullPath().c_str(), fname2.GetFullPath().c_str())))
return false;
if (!wxFileExists(fname1.GetFullPath())) return false;
return wxRenameFile(fname1.GetFullPath(),
fname2.GetFullPath());
}
示例3: MoveFile
// move file from source to dst, dst will be deleted if exists, dirs aren't created!
bool MoveFile(const wxString& src, const wxString& dst)
{
//delete destination file
if (wxFileExists(dst)) {
wxRemoveFile(dst);
}
//rename file
if (wxRenameFile(src, dst)) {
return true;
}
// rename failed, try to copy + delete
return wxCopyFile(src, dst) && wxRemoveFile(src);
}
示例4: wxLogStderr
CLogManager::CLogManager() :
wxLogStderr()
{
m_pLock = new wxCriticalSection();
wxASSERT(m_pLock);
if (wxFileExists(wxT("BOINC-Sentinels-Valkyrie.log")))
{
wxRenameFile(wxT("BOINC-Sentinels-Valkyrie.log"), wxT("BOINC-Sentinels-Valkyrie.bak"), true);
}
m_pFile = new wxFFile(wxT("BOINC-Sentinels-Valkyrie.log"), wxT("a"));
m_fp = m_pFile->fp();
}
示例5: time
void TopedApp::SaveIgnoredCrashLog()
{
time_t timeNow = time(NULL);
tm* broken_time = localtime(&timeNow);
char* btm = DEBUG_NEW char[256];
strftime(btm, 256, "_%y%m%d_%H%M%S", broken_time);
wxString fullName;
fullName << tpdLogDir + wxT("/crash") + wxString(btm, wxConvUTF8) + wxT(".log");
wxFileName* lFN = DEBUG_NEW wxFileName(fullName.c_str());
delete [] btm;
lFN->Normalize();
assert(lFN->IsOk());
wxRenameFile(logFileName.c_str(), lFN->GetFullPath());
delete lFN;
}
示例6: cellFsRename
int cellFsRename(u32 from_addr, u32 to_addr)
{
const wxString& ps3_from = Memory.ReadString(from_addr);
const wxString& ps3_to = Memory.ReadString(to_addr);
wxString from;
wxString to;
Emu.GetVFS().GetDevice(ps3_from, from);
Emu.GetVFS().GetDevice(ps3_to, to);
sys_fs.Log("cellFsRename(from: %s, to: %s)", from.mb_str(), to.mb_str());
if(!wxFileExists(from)) return CELL_ENOENT;
if(wxFileExists(to)) return CELL_EEXIST;
if(!wxRenameFile(from, to)) return CELL_EBUSY; // (TODO: RenameFile(a,b) = CopyFile(a,b) + RemoveFile(a), therefore file "a" will not be removed if it is opened)
return CELL_OK;
}
示例7: wxLogSysError
bool wxTempFile::Commit()
{
m_file.Close();
if ( wxFile::Exists(m_strName) && wxRemove(m_strName) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return false;
}
if ( !wxRenameFile(m_strTemp, m_strName) ) {
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return false;
}
return true;
}
示例8: RenameFile
bool RenameFile()
{
CPPUNIT_ASSERT(m_file.FileExists());
wxLogDebug("Renaming %s=>%s", m_file.GetFullPath(), m_new.GetFullPath());
bool ret = wxRenameFile(m_file.GetFullPath(), m_new.GetFullPath());
if (ret)
{
m_old = m_file;
m_file = m_new;
m_new = RandomName();
}
return ret;
}
示例9: wxRenameFile
bool mmAttachmentManage::RelocateAllAttachments(const wxString& RefType, int OldRefId, int NewRefId)
{
auto attachments = Model_Attachment::instance().find(Model_Attachment::DB_Table_ATTACHMENT_V1::REFTYPE(RefType), Model_Attachment::REFID(OldRefId));
wxString AttachmentsFolder = mmex::getPathAttachment(mmAttachmentManage::InfotablePathSetting()) + m_PathSep + RefType + m_PathSep;
for (auto &entry : attachments)
{
wxString NewFileName = entry.FILENAME;
NewFileName.Replace(entry.REFTYPE + "_" + wxString::Format("%i", entry.REFID), entry.REFTYPE + "_" + wxString::Format("%i", NewRefId));
wxRenameFile(AttachmentsFolder + entry.FILENAME, AttachmentsFolder + NewFileName);
entry.REFID = NewRefId;
entry.FILENAME = NewFileName;
Model_Attachment::instance().save(attachments);
}
return true;
}
示例10: Disable
void CIP2Country::DownloadFinished(uint32 result)
{
if (result == HTTP_Success) {
Disable();
// download succeeded. Switch over to new database.
wxString newDat = m_DataBasePath + wxT(".download");
// Try to unpack the file, might be an archive
wxWCharBuffer dataBaseName = m_DataBaseName.wc_str();
const wxChar* geoip_files[] = {
dataBaseName,
NULL
};
if (UnpackArchive(CPath(newDat), geoip_files).second == EFT_Error) {
AddLogLineC(_("Download of GeoIP.dat file failed, aborting update."));
return;
}
if (wxFileExists(m_DataBasePath)) {
if (!wxRemoveFile(m_DataBasePath)) {
AddLogLineC(CFormat(_("Failed to remove %s file, aborting update.")) % m_DataBaseName);
return;
}
}
if (!wxRenameFile(newDat, m_DataBasePath)) {
AddLogLineC(CFormat(_("Failed to rename %s file, aborting update.")) % m_DataBaseName);
return;
}
Enable();
if (m_geoip) {
AddLogLineN(CFormat(_("Successfully updated %s")) % m_DataBaseName);
} else {
AddLogLineC(_("Error updating GeoIP.dat"));
}
} else if (result == HTTP_Skipped) {
AddLogLineN(CFormat(_("Skipped download of %s, because requested file is not newer.")) % m_DataBaseName);
} else {
AddLogLineC(CFormat(_("Failed to download %s from %s")) % m_DataBaseName % thePrefs::GetGeoIPUpdateUrl());
// if it failed and there is no database, turn it off
if (!wxFileExists(m_DataBasePath)) {
thePrefs::SetGeoIPEnabled(false);
}
}
}
示例11: wxASSERT
void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event )
{
wxFileData *fd = (wxFileData*)event.m_item.m_data;
wxASSERT( fd );
if ((event.GetLabel().empty()) ||
(event.GetLabel() == _(".")) ||
(event.GetLabel() == _("..")) ||
(event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND))
{
wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
event.Veto();
return;
}
wxString new_name( wxPathOnly( fd->GetFilePath() ) );
new_name += wxFILE_SEP_PATH;
new_name += event.GetLabel();
wxLogNull log;
if (wxFileExists(new_name))
{
wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
event.Veto();
}
if (wxRenameFile(fd->GetFilePath(),new_name))
{
fd->SetNewName( new_name, event.GetLabel() );
ignoreChanges = true;
SetItemState( event.GetItem(), wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
ignoreChanges = false;
UpdateItem( event.GetItem() );
EnsureVisible( event.GetItem() );
}
else
{
wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
event.Veto();
}
}
示例12: wxFileName
bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
{
// this is broken & unsafe to use on linux.
if( m_Type == TREE_DIRECTORY )
return false;
if( name.IsEmpty() )
return false;
const wxString sep = wxFileName().GetPathSeparator();
wxString newFile;
wxString dirs = GetDir();
if( !dirs.IsEmpty() && GetType() != TREE_DIRECTORY )
newFile = dirs + sep + name;
else
newFile = name;
if( newFile == GetFileName() )
return false;
wxString ext = TREE_PROJECT_FRAME::GetFileExt( GetType() );
wxRegEx reg( wxT( "^.*\\" ) + ext + wxT( "$" ), wxRE_ICASE );
if( check && !ext.IsEmpty() && !reg.Matches( newFile ) )
{
wxMessageDialog dialog( m_parent, _(
"Changing file extension will change file type.\n Do you want to continue ?" ),
_( "Rename File" ),
wxYES_NO | wxICON_QUESTION );
if( wxID_YES != dialog.ShowModal() )
return false;
}
if( !wxRenameFile( GetFileName(), newFile, false ) )
{
wxMessageDialog( m_parent, _( "Unable to rename file ... " ),
_( "Permission error ?" ), wxICON_ERROR | wxOK );
return false;
}
SetFileName( newFile );
return true;
}
示例13: wxRemoveFile
void t4p::ExplorerModifyActionClass::BackgroundWork() {
wxFileName parentDir;
wxString name;
bool totalSuccess = true;
std::vector<wxFileName> dirsDeleted;
std::vector<wxFileName> dirsNotDeleted;
std::vector<wxFileName> filesDeleted;
std::vector<wxFileName> filesNotDeleted;
if (t4p::ExplorerModifyActionClass::DELETE_FILES_DIRS == Action) {
std::vector<wxFileName>::iterator d;
for (d = Dirs.begin(); d != Dirs.end(); ++d) {
bool success = t4p::RecursiveRmDir(d->GetPath());
if (success) {
wxFileName wxFileName;
wxFileName.AssignDir(d->GetPath());
dirsDeleted.push_back(wxFileName);
} else {
wxFileName wxFileName;
wxFileName.AssignDir(d->GetPath());
dirsNotDeleted.push_back(wxFileName);
}
totalSuccess &= success;
}
std::vector<wxFileName>::iterator f;
for (f = Files.begin(); f != Files.end(); ++f) {
bool success = wxRemoveFile(f->GetFullPath());
if (success) {
wxFileName deletedFile(f->GetFullPath());
filesDeleted.push_back(deletedFile);
} else {
wxFileName deletedFile(f->GetFullPath());
filesNotDeleted.push_back(deletedFile);
}
totalSuccess &= success;
}
t4p::ExplorerModifyEventClass modEvent(GetEventId(),
dirsDeleted, filesDeleted, dirsNotDeleted, filesNotDeleted, totalSuccess);
PostEvent(modEvent);
} else if (t4p::ExplorerModifyActionClass::RENAME_FILE == Action) {
wxFileName destFile(OldFile.GetPath(), NewName);
bool success = wxRenameFile(OldFile.GetFullPath(), destFile.GetFullPath(), false);
t4p::ExplorerModifyEventClass modEvent(GetEventId(),
OldFile, NewName, success);
PostEvent(modEvent);
}
}
示例14: GetRedirectedName
bool CXmlFile::SaveXmlFile()
{
bool exists = false;
bool isLink = false;
int flags = 0;
wxString redirectedName = GetRedirectedName();
if (CLocalFileSystem::GetFileInfo(redirectedName, isLink, 0, 0, &flags) == CLocalFileSystem::file) {
#ifdef __WXMSW__
if (flags & FILE_ATTRIBUTE_HIDDEN)
SetFileAttributes(redirectedName, flags & ~FILE_ATTRIBUTE_HIDDEN);
#endif
exists = true;
bool res;
{
wxLogNull null;
res = wxCopyFile(redirectedName, redirectedName + _T("~"));
}
if (!res) {
m_error = _("Failed to create backup copy of xml file");
return false;
}
}
bool success = false;
{
wxFFile f(redirectedName, _T("w"));
success = f.IsOpened() && m_pDocument->SaveFile(f.fp());
}
if (!success) {
wxRemoveFile(redirectedName);
if (exists) {
wxLogNull null;
wxRenameFile(redirectedName + _T("~"), redirectedName);
}
m_error = _("Failed to write xml file");
return false;
}
if (exists)
wxRemoveFile(redirectedName + _T("~"));
return true;
}
示例15: wxT
void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event)
{
if (event.IsEditCancelled())
return;
if ((event.GetLabel().empty()) ||
(event.GetLabel() == wxT(".")) ||
(event.GetLabel() == wxT("..")) ||
(event.GetLabel().Find(wxT('/')) != wxNOT_FOUND) ||
(event.GetLabel().Find(wxT('\\')) != wxNOT_FOUND) ||
(event.GetLabel().Find(wxT('|')) != wxNOT_FOUND))
{
wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
event.Veto();
return;
}
wxTreeItemId treeid = event.GetItem();
wxDirItemData *data = (wxDirItemData*)m_treeCtrl->GetItemData( treeid );
wxASSERT( data );
wxString new_name( wxPathOnly( data->m_path ) );
new_name += wxString(wxFILE_SEP_PATH);
new_name += event.GetLabel();
wxLogNull log;
if (wxFileExists(new_name))
{
wxMessageDialog dialog(this, _("File name exists already."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
event.Veto();
}
if (wxRenameFile(data->m_path,new_name))
{
data->SetNewDirName( new_name );
}
else
{
wxMessageDialog dialog(this, _("Operation not permitted."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
event.Veto();
}
}