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


C++ Rename函数代码示例

本文整理汇总了C++中Rename函数的典型用法代码示例。如果您正苦于以下问题:C++ Rename函数的具体用法?C++ Rename怎么用?C++ Rename使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: field

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();
}
开发者ID:c3d,项目名称:tao-3D,代码行数:57,代码来源:new_document_wizard.cpp

示例2: m_building_type

/////////////////////////////////////////////////
// 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();
}
开发者ID:MatGB,项目名称:freeorion,代码行数:17,代码来源:Building.cpp

示例3: QWidget

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)));
}
开发者ID:TomStanczyk,项目名称:vstboard,代码行数:30,代码来源:filebrowser.cpp

示例4: my_rename

/******************************************************************
 * 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;
}
开发者ID:Kalamatee,项目名称:WinUAE,代码行数:36,代码来源:fsdb_aros.cpp

示例5: DirRename

void DirRename(const iStringT& dname, const iStringT& to_dname)
{
	if (!DirExists(dname)){
		return;
	}
	Rename(dname,to_dname);
}
开发者ID:Reynmar,项目名称:pocketheroes,代码行数:7,代码来源:gxl.file.cpp

示例6: retrieve_backup

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;
}
开发者ID:KaedeTai,项目名称:pttbbs,代码行数:33,代码来源:admin.c

示例7: QTabBar

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)));
}
开发者ID:jamie-gifford,项目名称:Clementine,代码行数:30,代码来源:playlisttabbar.cpp

示例8: FName

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;
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:16,代码来源:K2Node_CustomEvent.cpp

示例9: swapFiles

//----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);
}
开发者ID:mjs513,项目名称:rsnxt08,代码行数:36,代码来源:b4+rat.c

示例10: switch

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;
}
开发者ID:bugiii,项目名称:filezilla3ex,代码行数:60,代码来源:FileZillaEngine.cpp

示例11: CopyDir

// 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
}
开发者ID:Tilka,项目名称:dolphin,代码行数:60,代码来源:FileUtil.cpp

示例12: GetBlueprint

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;
		}
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:17,代码来源:K2Node_CustomEvent.cpp

示例13: UniverseObject

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);
}
开发者ID:mel-odious,项目名称:freeorion,代码行数:17,代码来源:Field.cpp

示例14: Rename

bool sprawl::filesystem::Renames(sprawl::String const& path, String const& newName)
{
	if(!MakeDirs(path::Dirname(newName), 0777))
	{
		return false;
	}
	return Rename(path, newName);
}
开发者ID:ShadauxCat,项目名称:Sprawl,代码行数:8,代码来源:filesystem.cpp

示例15: newPath

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);
}
开发者ID:sanyaade-webdev,项目名称:core-XToolbox,代码行数:9,代码来源:XLinuxFile.cpp


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