void NewDocumentWizard::accept() // ---------------------------------------------------------------------------- // Copy template into user's document folder // ---------------------------------------------------------------------------- { QString docName = field("docName").toString(); QString docLocation = field("docLocation").toString(); QString dstPath = docLocation + "/" + docName; QDir dst(dstPath); if (dst.exists()) { QString dstPathNative = QDir::toNativeSeparators(dstPath); int r = QMessageBox::warning(this, tr("Folder exists"), tr("Document folder:\n%1\nalready exists. " "Do you want to use it anyway (current content " "will be deleted)?\n" "Click No to choose another location.") .arg(dstPathNative), QMessageBox::Yes | QMessageBox::No); if (r != QMessageBox::Yes) return; } Template t = templates.at(field("templateIdx").toInt()); bool ok = t.copyTo(dst); if (!ok) { QMessageBox::warning(this, tr("Error"), tr("Failed to copy document template.")); return; } docPath = dstPath; if (t.mainFile != "") { QString oldName = t.mainFile.replace(QRegExp("\\.ddd$"), ""); QString newName = docName; if (oldName != newName) { // Rename template main file to doc name. // We need to remove the destination file if it is there QDir dstDir = QDir(dstPath); Rename(dstDir, oldName, newName, ".ddd"); Rename(dstDir, oldName, newName, ".ddd.sig"); Rename(dstDir, oldName, newName, ".json"); docPath = dstDir.filePath(newName + ".ddd"); } } #if !defined(CFG_NOGIT) // Create project to avoid prompt when document is first opened RepositoryFactory::repository(dstPath, RepositoryFactory::Create); #endif QDialog::accept(); }
///////////////////////////////////////////////// // Building // ///////////////////////////////////////////////// Building::Building(int empire_id, const std::string& building_type, int produced_by_empire_id/* = ALL_EMPIRES*/) : m_building_type(building_type), m_produced_by_empire_id(produced_by_empire_id) { UniverseObject::SetOwner(empire_id); const BuildingType* type = GetBuildingType(m_building_type); if (type) Rename(UserString(type->Name())); else Rename(UserString("ENC_BUILDING")); UniverseObject::Init(); }
FileBrowser::FileBrowser(QWidget *parent) : QWidget(parent), ui(new Ui::FileBrowser), historyPosition(0), model(0) { ui->setupUi(this); actRename = new QAction(tr("Rename"),ui->treeFiles); actRename->setShortcut(Qt::Key_F2); actRename->setShortcutContext(Qt::WidgetWithChildrenShortcut); ui->treeFiles->addAction(actRename); connect(actRename,SIGNAL(triggered()), this,SLOT(Rename())); actDel = new QAction(QIcon(":/img16x16/delete.png"),tr("Delete"),ui->treeFiles); actDel->setShortcut(Qt::Key_Delete); actDel->setShortcutContext(Qt::WidgetWithChildrenShortcut); connect(actDel,SIGNAL(triggered()), this,SLOT(DeleteSelectedFile())); ui->treeFiles->addAction(actDel); actNewFolder = new QAction(QIcon(":img16x16/folder.png"),tr("New Folder"),ui->treeFiles); connect(actNewFolder,SIGNAL(triggered()), this,SLOT(NewFolder())); ui->treeFiles->addAction(actNewFolder); connect(ui->treeFiles, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(OnContextMenu(QPoint))); }
/****************************************************************** * my_rename ******************************************************************/ int my_rename (const TCHAR *oldname, const TCHAR *newname) { LONG res; char cmd[255]; DebOut("oldname: %s newname %s\n", oldname, newname); res=Rename(oldname, newname); if(res==DOSTRUE) { return 0; } /* ugly hack, as windows rename can move over filesystem borders, * but AROS rename can't. And there seems to be no simple * API to move a file across filesystem borders... * So we use the shell and hope for the best.. */ DebOut("rename failed, try shell copy..\n"); sprintf(cmd, "c:copy from %s to %s MOVE QUIET >NIL:", oldname, newname); DebOut("execute: %s\n", cmd); Execute(cmd, NULL, NULL); if(fsdb_exists(newname)) { /* there is a file, pray, it is the one we copied ;) */ return 0; } SetLastError(IoErr()); DebOut("return -1 (%d)\n", IoErr()); return -1; }
void DirRename(const iStringT& dname, const iStringT& to_dname) { if (!DirExists(dname)){ return; } Rename(dname,to_dname); }
/** * wrapper for ldap_rename(): kicks off an async rename request. * * @param aBaseDn Base DN to rename * @param aNewRDn New relative DN * @param aNewParent DN of the new parent under which to move the * * XXX doesn't currently handle LDAPControl params * * void rename(in AUTF8String aBaseDn, in AUTF8String aNewRDn, * in AUTF8String aNewParent, in boolean aDeleteOldRDn); */ NS_IMETHODIMP nsLDAPOperation::Rename(const nsACString& aBaseDn, const nsACString& aNewRDn, const nsACString& aNewParent, bool aDeleteOldRDn) { PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("nsLDAPOperation::Rename(): called with aBaseDn = '%s'", PromiseFlatCString(aBaseDn).get())); nsresult rv = Rename(PromiseFlatCString(aBaseDn).get(), PromiseFlatCString(aNewRDn).get(), PromiseFlatCString(aNewParent).get(), aDeleteOldRDn, 0, 0); if (NS_FAILED(rv)) return rv; // make sure the connection knows where to call back once the messages // for this operation start coming in rv = mConnection->AddPendingOperation(mMsgID, this); if (NS_FAILED(rv)) { (void)ldap_abandon_ext(mConnectionHandle, mMsgID, 0, 0); PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("nsLDAPOperation::AddExt(): abandoned due to rv %x", rv)); } return rv; }
static int retrieve_backup(userec_t *user) { int uid; char src[PATHLEN], dst[PATHLEN]; char ans; if ((uid = searchuser(user->userid, user->userid))) { userec_t orig; passwd_sync_query(uid, &orig); strlcpy(user->passwd, orig.passwd, sizeof(orig.passwd)); setumoney(uid, user->money); passwd_sync_update(uid, user); return 0; } ans = vans("目前的 PASSWD 檔沒有此 ID,新增嗎?[y/N]"); if (ans != 'y') { vmsg("目前的 PASSWDS 檔沒有此 ID,請先新增此帳號"); return -1; } if (setupnewuser((const userec_t *)user) >= 0) { sethomepath(dst, user->userid); if (!dashd(dst)) { snprintf(src, sizeof(src), "tmp/%s", user->userid); if (!dashd(src) || !Rename(src, dst)) mkuserdir(user->userid); } return 0; } return -1; }
PlaylistTabBar::PlaylistTabBar(QWidget* parent) : QTabBar(parent), manager_(nullptr), menu_(new QMenu(this)), menu_index_(-1), suppress_current_changed_(false), initialized_(false), rename_editor_(new RenameTabLineEdit(this)) { setAcceptDrops(true); setElideMode(Qt::ElideRight); setUsesScrollButtons(true); setTabsClosable(true); close_ = menu_->addAction(IconLoader::Load("list-remove", IconLoader::Base), tr("Close playlist"), this, SLOT(Close())); rename_ = menu_->addAction(IconLoader::Load("edit-rename", IconLoader::Base), tr("Rename playlist..."), this, SLOT(Rename())); save_ = menu_->addAction(IconLoader::Load("document-save", IconLoader::Base), tr("Save playlist..."), this, SLOT(Save())); menu_->addSeparator(); rename_editor_->setVisible(false); connect(rename_editor_, SIGNAL(editingFinished()), SLOT(RenameInline())); connect(rename_editor_, SIGNAL(EditingCanceled()), SLOT(HideEditor())); connect(this, SIGNAL(currentChanged(int)), SLOT(CurrentIndexChanged(int))); connect(this, SIGNAL(tabMoved(int, int)), SLOT(TabMoved())); // We can't just emit Close signal, we need to extract the playlist id first connect(this, SIGNAL(tabCloseRequested(int)), SLOT(CloseFromTabIndex(int))); }
void UK2Node_CustomEvent::RenameCustomEventCloseToName(int32 StartIndex) { bool bFoundName = false; const FString& BaseName = CustomFunctionName.ToString(); for (int32 NameIndex = StartIndex; !bFoundName; ++NameIndex) { const FString NewName = FString::Printf(TEXT("%s_%d"), *BaseName, NameIndex); if (Rename(*NewName, GetOuter(), REN_Test)) { CustomFunctionName = FName(NewName.GetCharArray().GetData()); Rename(*NewName); bFoundName = true; } } }
//----handles the storage of data----// void swapFiles() { OpenWrite(hFileHandle2,nIoResultRead,sFileName2,nFileSize2); OpenRead(hFileHandle,nIoResult,sFileName1,nFileSize); float tempVar; char tempX, tempY, tempTheta, z; while(nIoResult != ioRsltEndOfFile) { for(z = 0; z<numNeuralUnits; z++) { ReadFloat(hFileHandle,nIoResult,tempVar); if(nIoResult == ioRsltEndOfFile) {break;} WriteFloat(hFileHandle2,nIoResultRead,tempVar); } if(nIoResult == ioRsltEndOfFile) {break;} ReadByte(hFileHandle, nIoResult, tempX); ReadByte(hFileHandle, nIoResult, tempY); ReadByte(hFileHandle, nIoResult, tempTheta); WriteByte(hFileHandle2,nIoResultRead,tempX); WriteByte(hFileHandle2,nIoResultRead,tempY); WriteByte(hFileHandle2,nIoResultRead,tempTheta); } char x; for(x = 0; x<numNeuralUnits; x++) { WriteFloat(hFileHandle2, nIoResult, localTemp.localArray[x]); } WriteByte(hFileHandle2, nIoResult, poseWorld.maxActivatedCell.x); WriteByte(hFileHandle2, nIoResult, poseWorld.maxActivatedCell.y); WriteByte(hFileHandle2, nIoResult, poseWorld.maxActivatedCell.theta); Close(hFileHandle2,nIoResultRead); Close(hFileHandle,nIoResult); Delete(sFileName1,nIoResult); Rename(sFileName1,nIoResult,sFileName2); }
int CFileZillaEngine::Execute(const CCommand &command) { if (command.GetId() != Command::cancel && IsBusy()) return FZ_REPLY_BUSY; m_bIsInCommand = true; int res = FZ_REPLY_INTERNALERROR; switch (command.GetId()) { case Command::connect: res = Connect(reinterpret_cast<const CConnectCommand &>(command)); break; case Command::disconnect: res = Disconnect(reinterpret_cast<const CDisconnectCommand &>(command)); break; case Command::cancel: res = Cancel(reinterpret_cast<const CCancelCommand &>(command)); break; case Command::list: res = List(reinterpret_cast<const CListCommand &>(command)); break; case Command::transfer: res = FileTransfer(reinterpret_cast<const CFileTransferCommand &>(command)); break; case Command::raw: res = RawCommand(reinterpret_cast<const CRawCommand&>(command)); break; case Command::del: res = Delete(reinterpret_cast<const CDeleteCommand&>(command)); break; case Command::removedir: res = RemoveDir(reinterpret_cast<const CRemoveDirCommand&>(command)); break; case Command::mkdir: res = Mkdir(reinterpret_cast<const CMkdirCommand&>(command)); break; case Command::rename: res = Rename(reinterpret_cast<const CRenameCommand&>(command)); break; case Command::chmod: res = Chmod(reinterpret_cast<const CChmodCommand&>(command)); break; default: return FZ_REPLY_SYNTAXERROR; } if (res != FZ_REPLY_WOULDBLOCK) ResetOperation(res); m_bIsInCommand = false; if (command.GetId() != Command::disconnect) res |= m_nControlSocketError; else if (res & FZ_REPLY_DISCONNECTED) res = FZ_REPLY_OK; m_nControlSocketError = 0; return res; }
// Create directory and copy contents (does not overwrite existing files) void CopyDir(const std::string& source_path, const std::string& dest_path, bool destructive) { if (source_path == dest_path) return; if (!Exists(source_path)) return; if (!Exists(dest_path)) File::CreateFullPath(dest_path); #ifdef _WIN32 WIN32_FIND_DATA ffd; HANDLE hFind = FindFirstFile(UTF8ToTStr(source_path + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { FindClose(hFind); return; } do { const std::string virtualName(TStrToUTF8(ffd.cFileName)); #else DIR* dirp = opendir(source_path.c_str()); if (!dirp) return; while (dirent* result = readdir(dirp)) { const std::string virtualName(result->d_name); #endif // check for "." and ".." if (virtualName == "." || virtualName == "..") continue; std::string source = source_path + DIR_SEP + virtualName; std::string dest = dest_path + DIR_SEP + virtualName; if (IsDirectory(source)) { if (!Exists(dest)) File::CreateFullPath(dest + DIR_SEP); CopyDir(source, dest, destructive); } else if (!destructive && !Exists(dest)) { Copy(source, dest); } else if (destructive) { Rename(source, dest); } #ifdef _WIN32 } while (FindNextFile(hFind, &ffd) != 0); FindClose(hFind); #else } closedir(dirp); #endif }
void UK2Node_CustomEvent::RenameCustomEventCloseToName(int32 StartIndex) { bool bFoundName = false; const FString& BaseName = CustomFunctionName.ToString(); for (int32 NameIndex = StartIndex; !bFoundName; ++NameIndex) { const FString NewName = FString::Printf(TEXT("%s_%d"), *BaseName, NameIndex); if (Rename(*NewName, GetOuter(), REN_Test)) { UBlueprint* Blueprint = GetBlueprint(); CustomFunctionName = FName(NewName.GetCharArray().GetData()); Rename(*NewName, GetOuter(), (Blueprint->bIsRegeneratingOnLoad ? REN_ForceNoResetLoaders : 0) | REN_DontCreateRedirectors); bFoundName = true; } } }
Field::Field(const std::string& field_type, double x, double y, double radius) : UniverseObject("", x, y), m_type_name(field_type) { const FieldType* type = GetFieldType(m_type_name); if (type) Rename(UserString(type->Name())); else Rename(UserString("ENC_FIELD")); UniverseObject::Init(); AddMeter(METER_SPEED); AddMeter(METER_SIZE); UniverseObject::GetMeter(METER_SIZE)->Set(radius, radius); }
bool sprawl::filesystem::Renames(sprawl::String const& path, String const& newName) { if(!MakeDirs(path::Dirname(newName), 0777)) { return false; } return Rename(path, newName); }
LONG rxsupp_rename(struct Library *RexxSupportBase, struct RexxMsg *msg, UBYTE **argstring) { BOOL ok; ok = Rename(ARG1(msg), ARG2(msg)); *argstring = CreateArgstring(ok ? "1" : "0", 1); return RC_OK; }
VError XLinuxFile::Rename(const VString& inName, VFile** outFile) const { //jmo - todo : we should check that inName < NAME_MAX or use PathBuffer VFilePath newPath(fOwner->GetPath()); newPath.SetFileName(inName); return Rename(newPath, outFile); }
/*---------------------------------------------------------------------- | NPT_File::Rename +---------------------------------------------------------------------*/ NPT_Result NPT_File::Rename(const char* path) { NPT_Result result = Rename(m_Path.GetChars(), path); if (NPT_SUCCEEDED(result)) { m_Path = path; } return result; }
void SafeWriteFile::close(void) { File::close(); if(!mTarget.empty()) { if(!std::fstream::bad()) Rename(mName, mTarget); Remove(mName); mName = mTarget; mTarget.clear(); } }
void PlaylistTabBar::Rename() { if (menu_index_ == -1) return; QString name = tabText(menu_index_); name = QInputDialog::getText(this, tr("Rename playlist"), tr("Enter a new name for this playlist"), QLineEdit::Normal, name); if (name.isNull()) return; emit Rename(tabData(menu_index_).toInt(), name); }
void RenameDialog::accept () { std::shared_ptr<void> guard (nullptr, [this] (void*) { QDialog::accept (); }); const auto& toRename = GetRenames (); if (toRename.isEmpty ()) return; if (QMessageBox::question (this, "LMP Graffiti", tr ("Are you sure you want to rename %n file(s)?", 0, toRename.size ()), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) Rename (toRename); }
void CFileManager::OnReceive(LPBYTE lpBuffer, UINT nSize) { switch (lpBuffer[0]) { case COMMAND_LIST_FILES:// 获取文件列表 SendFilesList((char *)lpBuffer + 1); break; case COMMAND_DELETE_FILE:// 删除文件 DeleteFile((char *)lpBuffer + 1); SendToken(TOKEN_DELETE_FINISH); break; case COMMAND_DELETE_DIRECTORY:// 删除文件 ////printf("删除目录 %s\n", (char *)(bPacket + 1)); DeleteDirectory((char *)lpBuffer + 1); SendToken(TOKEN_DELETE_FINISH); break; case COMMAND_DOWN_FILES: // 上传文件 UploadToRemote(lpBuffer + 1); break; case COMMAND_CONTINUE: // 上传文件 SendFileData(lpBuffer + 1); break; case COMMAND_CREATE_FOLDER: CreateFolder(lpBuffer + 1); break; case COMMAND_RENAME_FILE: Rename(lpBuffer + 1); break; case COMMAND_STOP: StopTransfer(); break; case COMMAND_SET_TRANSFER_MODE: SetTransferMode(lpBuffer + 1); break; case COMMAND_FILE_SIZE: CreateLocalRecvFile(lpBuffer + 1); break; case COMMAND_FILE_DATA: WriteLocalRecvFile(lpBuffer + 1, nSize -1); break; case COMMAND_OPEN_FILE_SHOW: OpenFile((char *)lpBuffer + 1, SW_SHOW); break; case COMMAND_OPEN_FILE_HIDE: OpenFile((char *)lpBuffer + 1, SW_HIDE); break; default: break; } }
int CFileZillaApi::Command(t_command *pCommand) { //Check if call allowed if (!m_bInitialized) return FZ_REPLY_NOTINITIALIZED; //Dispatch command to command specific functions switch(pCommand->id) { case FZ_COMMAND_LIST: if (pCommand->param1!=_MPT("")) return List(pCommand->path,pCommand->param1,pCommand->param4); else if (!pCommand->path.IsEmpty()) return List(pCommand->path,pCommand->param4); else return List(pCommand->param4); break; case FZ_COMMAND_CONNECT: return Connect(pCommand->server); break; case FZ_COMMAND_DISCONNECT: return Disconnect(); break; case FZ_COMMAND_FILETRANSFER: return FileTransfer(pCommand->transferfile); break; case FZ_COMMAND_DELETE: return Delete(pCommand->param1, pCommand->path); break; case FZ_COMMAND_REMOVEDIR: return RemoveDir(pCommand->param1, pCommand->path); break; case FZ_COMMAND_MAKEDIR: return MakeDir(pCommand->path); break; case FZ_COMMAND_RENAME: return Rename(pCommand->param1, pCommand->param2, pCommand->path, pCommand->newPath); break; case FZ_COMMAND_CUSTOMCOMMAND: return CustomCommand(pCommand->param1); break; case FZ_COMMAND_CHMOD: return Chmod(pCommand->param4, pCommand->param1, pCommand->path); break; } return FZ_REPLY_INVALIDPARAM; }
/*---------------------------------------------------------------------------------------------- Change all the occurrences of the old styles names to the new names, and delete any obsolete names. ----------------------------------------------------------------------------------------------*/ bool FwDbMergeStyles::ProcessFormatting(ComVector<ITsTextProps> & vqttp, StrUni stuDelete) { bool fAnyChanged = false; for (int ittp = 0; ittp < vqttp.Size(); ittp++) { SmartBstr sbstr; HRESULT hr; CheckHr(hr = vqttp[ittp]->GetStrPropValue(ktptNamedStyle, &sbstr)); if (hr == S_OK && sbstr.Length() > 0) { ITsPropsBldrPtr qtpb = NULL; StrUni stuOld(sbstr.Chars()); StrUni stuNew; if (Delete(stuOld)) { CheckHr(vqttp[ittp]->GetBldr(&qtpb)); if (stuDelete.Length() == 0) { // If the style name to delete is empty, we want to pass null // so that the named style string property is removed. CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, NULL)); } else CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, stuDelete.Bstr())); } else if (Rename(stuOld, stuNew)) { CheckHr(vqttp[ittp]->GetBldr(&qtpb)); CheckHr(qtpb->SetStrPropValue(ktptNamedStyle, stuNew.Bstr())); } if (qtpb) { ITsTextPropsPtr qttpNew; CheckHr(qtpb->GetTextProps(&qttpNew)); vqttp[ittp] = qttpNew; fAnyChanged = true; } } } return fAnyChanged; }
void EditTOC::ConnectSignalsToSlots() { connect(this, SIGNAL(accepted()), this, SLOT(Save())); connect(ui.AddEntryAbove, SIGNAL(clicked()), this, SLOT(AddEntryAbove())); connect(ui.AddEntryBelow, SIGNAL(clicked()), this, SLOT(AddEntryBelow())); connect(ui.DeleteEntry, SIGNAL(clicked()), this, SLOT(DeleteEntry())); connect(ui.MoveLeft, SIGNAL(clicked()), this, SLOT(MoveLeft())); connect(ui.MoveRight, SIGNAL(clicked()), this, SLOT(MoveRight())); connect(ui.MoveUp, SIGNAL(clicked()), this, SLOT(MoveUp())); connect(ui.MoveDown, SIGNAL(clicked()), this, SLOT(MoveDown())); connect(m_MoveUp, SIGNAL(triggered()), this, SLOT(MoveUp())); connect(m_MoveDown, SIGNAL(triggered()), this, SLOT(MoveDown())); connect(ui.SelectTarget, SIGNAL(clicked()), this, SLOT(SelectTarget())); connect(ui.TOCTree, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(OpenContextMenu(const QPoint &))); connect(m_Rename, SIGNAL(triggered()), this, SLOT(Rename())); connect(m_Delete, SIGNAL(triggered()), this, SLOT(DeleteEntry())); connect(m_CollapseAll, SIGNAL(triggered()), this, SLOT(CollapseAll())); connect(m_ExpandAll, SIGNAL(triggered()), this, SLOT(ExpandAll())); }
VError XLinuxFile::Move(const VFilePath& inDestinationPath, VFile** outFile, FileCopyOptions inOptions) const { VFilePath dstPath(inDestinationPath); if (dstPath.IsFolder()) { VStr255 name; //jmo - todo : NAME_MAX ? fOwner->GetName(name); dstPath.SetFileName(name); } //First we try to rename the file... VError verr=Rename(dstPath.GetPath(), outFile); //If Rename() fails beacause src and dst are not on the same fs, we try a Copy() if(verr!=VE_OK && IS_NATIVE_VERROR(verr) && NATIVE_ERRCODE_FROM_VERROR(verr)==EXDEV) verr=Copy(inDestinationPath, outFile, inOptions); return verr; }
bool RenameSync(const std::string &srcFilename, const std::string &destFilename) { if (!Rename(srcFilename, destFilename)) return false; #ifdef _WIN32 int fd = _topen(UTF8ToTStr(srcFilename).c_str(), _O_RDONLY); if (fd != -1) { _commit(fd); close(fd); } #else char *path = strdup(srcFilename.c_str()); FSyncPath(path); FSyncPath(dirname(path)); free(path); path = strdup(destFilename.c_str()); FSyncPath(dirname(path)); free(path); #endif return true; }
static int RenRRD(char *oldName, char *newName) { char first[PATHNAMESIZE], second[PATHNAMESIZE]; Object *root; strcpy(first, oldName); strcpy(second, newName); if ( !RemoveRootPath(first) || !RemoveRootPath(second) ) { fprintf(stderr, "RenRRD: trying to rename '%s' as '%s' - this shouldn't happen!\n", oldName, second); exit(2); } if ( (root=Locate(NULL, ROOTDIR)) == NULL) { fprintf(stderr, "RenRRD: failed to locate root directory '%s'\n", ROOTDIR); exit(2); } if ( Rename(root, first, second) != 0 ) return 0; else return 1; }
int Ardb::RenameNX(Context& ctx, RedisCommandFrame& cmd) { Rename(ctx, cmd); return 0; }
void PlaylistTabBar::RenameInline() { emit Rename(tabData(menu_index_).toInt(), rename_editor_->text()); HideEditor(); }