本文整理汇总了C++中MoveFileEx函数的典型用法代码示例。如果您正苦于以下问题:C++ MoveFileEx函数的具体用法?C++ MoveFileEx怎么用?C++ MoveFileEx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MoveFileEx函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MoveDirectory
// 将pc中的文件夹从一个目录拷贝到另外的一个目录
BOOL MoveDirectory(CString strSrcPath, CString strDesPath)
{
if( strSrcPath.IsEmpty() )
{
return FALSE;
}
if ( !PathIsDirectory(strDesPath) )
{
if ( !CreateDirectory(strDesPath,NULL))
return FALSE;
}
if ( strSrcPath.GetAt(strSrcPath.GetLength()-1) != '\\' )
strSrcPath += '\\';
if ( strDesPath.GetAt(strDesPath.GetLength()-1) != '\\' )
strDesPath += '\\';
BOOL bRet = FALSE; // 因为源目录不可能为空,所以该值一定会被修改
CFileFind ff;
BOOL bFound = ff.FindFile(strSrcPath+_T("*"), 0);
CString strFile;
BOOL bSpecialFile=FALSE;
while(bFound) // 递归拷贝
{
bFound = ff.FindNextFile();
bSpecialFile=FALSE;
if( ff.IsDots() )
continue;
CString strSubSrcPath = ff.GetFilePath();
CString strSubDespath = strSubSrcPath;
strSubDespath.Replace(strSrcPath, strDesPath);
if( ff.IsDirectory() )
bRet = MoveDirectory(strSubSrcPath, strSubDespath); // 递归拷贝文件夹
else
{
strFile=PathFindFileName(strSubSrcPath);
strFile.MakeUpper();
for (int i=0;i<nSpecialFileCount;i++)
{
//找到特殊文件
if(_tcscmp(strFile.GetString(),sSpecialFile[i])==0)
{
bSpecialFile=TRUE;
break;
}
}
if(bSpecialFile)
bRet=MoveFileEx( strSubSrcPath,strSubDespath,MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
else
bRet = MoveFileEx(strSubSrcPath, strSubDespath,MOVEFILE_REPLACE_EXISTING); // 移动文件
}
if ( !bRet )
break;
}
ff.Close();
return bRet;
}
开发者ID:isnb,项目名称:AutoUpdate,代码行数:61,代码来源:PatchDlg.cpp
示例2: move_program
static BOOL move_program() {
if (MoveFileEx(L"Calibre Portable\\calibre-portable.exe",
L"..\\calibre-portable.exe", MOVEFILE_REPLACE_EXISTING) == 0) {
show_last_error(L"Failed to move calibre-portable.exe, make sure calibre is not running");
return false;
}
if (directory_exists(L"..\\Calibre")) {
if (!rmtree(L"..\\Calibre")) {
show_error(L"Failed to delete the Calibre program folder. Make sure calibre is not running.");
return false;
}
}
if (MoveFileEx(L"Calibre Portable\\Calibre", L"..\\Calibre", 0) == 0) {
Sleep(4000); // Sleep and try again
if (MoveFileEx(L"Calibre Portable\\Calibre", L"..\\Calibre", 0) == 0) {
show_last_error(L"Failed to move calibre program folder. This is usually caused by an antivirus program or a file sync program like DropBox. Turn them off temporarily and try again. Underlying error: ");
return false;
}
}
if (!directory_exists(L"..\\Calibre Library")) {
MoveFileEx(L"Calibre Portable\\Calibre Library", L"..\\Calibre Library", 0);
}
if (!directory_exists(L"..\\Calibre Settings")) {
MoveFileEx(L"Calibre Portable\\Calibre Settings", L"..\\Calibre Settings", 0);
}
return true;
}
开发者ID:Aliminator666,项目名称:calibre,代码行数:32,代码来源:portable-installer.cpp
示例3: RemoveDirectory
BOOL install_util::DeleteFolder(LPCTSTR pszFolder)
{
if(IsFolderEmpty(pszFolder))
return RemoveDirectory(pszFolder);
//下面的实现据说有隐患。应改为递归删除所有子文件及文件夹
_TCHAR szPath[MAX_PATH + 1] = {0};
_sntprintf_s(szPath, _countof(szPath), sizeof(szPath), _TEXT("%s%c"), pszFolder, 0);
SHFILEOPSTRUCT fos ;
ZeroMemory(&fos, sizeof( fos)) ;
fos.hwnd = HWND_DESKTOP;
fos.wFunc = FO_DELETE ;
fos.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
fos.pFrom = szPath;
// 删除文件夹及其内容
if (0 == SHFileOperation(&fos))
return TRUE;
wstring tmpFile = szPath;
tmpFile += L"_yytmp";
if (MoveFileEx(szPath, tmpFile.c_str(), MOVEFILE_REPLACE_EXISTING))
return MoveFileEx(tmpFile.c_str(),NULL,MOVEFILE_DELAY_UNTIL_REBOOT);
return FALSE;
}
开发者ID:510908220,项目名称:setup,代码行数:27,代码来源:install_util.cpp
示例4: DeleteFile
BOOL DeleteFile(LPCTSTR lpszFileName, DWORD dwPlatformID)
{
// Delete file
if (!::DeleteFile(lpszFileName))
{
if( VER_PLATFORM_WIN32_NT == dwPlatformID) //WINNT系列
{
CString strTemp = lpszFileName;
strTemp += _T(".tmp");
//源文件文件改名成重新启动后自动删除
//rename current file to file.tmp
if(!MoveFileEx(lpszFileName, strTemp, MOVEFILE_REPLACE_EXISTING)
|| !MoveFileEx(strTemp, NULL, MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING))
return FALSE;
}
else if (VER_PLATFORM_WIN32_WINDOWS == dwPlatformID) //win98
{
CString strOldFileName,strIniPathName;
::GetWindowsDirectory(strIniPathName.GetBuffer(MAX_PATH),MAX_PATH);
strIniPathName.ReleaseBuffer();
strIniPathName += _T("\\wininit.ini");
::GetShortPathName(lpszFileName,strOldFileName.GetBuffer(MAX_PATH),MAX_PATH);
strOldFileName.ReleaseBuffer();
if (!::WritePrivateProfileString(TEXT("rename"), _T("NUL"), strOldFileName,strIniPathName))
return FALSE;
}
}
return TRUE;
}
开发者ID:kaka-jeje,项目名称:zhu,代码行数:29,代码来源:opstr.cpp
示例5: SelfDelete
VOID SelfDelete(LPCSTR ModuleFileName)
{
CHAR TempPath[MAX_PATH];
CHAR TempName[MAX_PATH];
GetTempPath(RTL_NUMBER_OF(TempPath)-1,TempPath);
GetTempFileName(TempPath,NULL,0,TempName);
MoveFileEx(ModuleFileName, TempName, MOVEFILE_REPLACE_EXISTING);
MoveFileEx(TempName, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
}
开发者ID:AlexWMF,项目名称:Carberp,代码行数:11,代码来源:dropper.cpp
示例6: MoveFileEx
BOOL install_util::DeleteFile(LPCTSTR pszFile)
{
if (::DeleteFile(pszFile))
return TRUE;
wstring tmpFile = pszFile;
tmpFile += L"_yytmp";
if (MoveFileEx(pszFile, tmpFile.c_str(), MOVEFILE_REPLACE_EXISTING))
return MoveFileEx(tmpFile.c_str(),NULL,MOVEFILE_DELAY_UNTIL_REBOOT);
return FALSE;
}
开发者ID:510908220,项目名称:setup,代码行数:12,代码来源:install_util.cpp
示例7: ConvertPath
//=============================================================================
// 函数名称: 移动覆盖一个指定的目录
// 作者说明: mushuai
// 修改时间: 2013-03-14
//=============================================================================
int ConvertPath(LPCTSTR srcpath,LPCTSTR targpath)
{
int iresult = 1;
CFindFile finder;
if(finder.FindFile(srcpath))
{
CString fileName,filePath;
do
{
fileName=finder.GetFileName();
filePath = finder.GetFilePath();
//. ..
if (finder.IsDots())
{
continue;
}
//dir
else if (finder.IsDirectory())
{
CString tTargPath = targpath;
tTargPath +=_T("\\")+fileName;
ConvertPath(filePath+_T("\\*"),tTargPath);
RemoveDirectory(filePath);
}
else//file
{
CString newFilePath = targpath;
newFilePath +=_T("\\")+fileName;
if (!PathFileExists(targpath))
{
if(ERROR_SUCCESS != SHCreateDirectoryEx(0,targpath,0))
{
return 0;
}
}
BOOL res=MoveFileEx(filePath,newFilePath,MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
if (!res)
{
SetFileAttributes(newFilePath,FILE_ATTRIBUTE_NORMAL);
if (!DeleteFile(newFilePath))
{
MoveFileEx(filePath,newFilePath,MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
}
}
}
}while (finder.FindNextFile());
}
finder.Close();
return iresult;
}
开发者ID:ChenzhenqingCC,项目名称:WinProjects,代码行数:55,代码来源:publicfun.cpp
示例8: strcpy
//剪切一个文件夹到另外一个文件夹
bool TraverseFolder::CutfolderTofolder(LPCSTR path1,LPCSTR path2)
{
WIN32_FIND_DATA findData;
HANDLE hSearch;
char FilePathName[MAX_PATH];
char FullPathName1[MAX_PATH];
char FullPathName2[MAX_PATH];
strcpy(FilePathName,path1);
strcat(FilePathName,"\\*.*");
hSearch = FindFirstFile(FilePathName,&findData);
if( hSearch ==INVALID_HANDLE_VALUE)
{
std::cout<<"Search files failed\n";
return false;
}
while(::FindNextFile(hSearch,&findData))
{
if(strcmp(findData.cFileName,".") ==0||strcmp(findData.cFileName,"..") ==0)
{
continue;
}
sprintf(FullPathName1,"%s\\%s",path1,findData.cFileName);
sprintf(FullPathName2,"%s\\%s",path2,findData.cFileName);
if( !MoveFileEx(FullPathName1,FullPathName2,MOVEFILE_REPLACE_EXISTING))
{
std::cout<<"Move file"<<findData.cFileName<<"failed\n";
}
}
::FindClose(hSearch);
return true;
}
开发者ID:zhuangsifei,项目名称:planet_work,代码行数:34,代码来源:TraverseFolder.cpp
示例9: my_rename
int my_rename(const char *from, const char *to, myf MyFlags)
{
int error = 0;
DBUG_ENTER("my_rename");
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
#if defined(HAVE_FILE_VERSIONS)
{ /* Check that there isn't a old file */
int save_errno;
MY_STAT my_stat_result;
save_errno=my_errno;
if (my_stat(to,&my_stat_result,MYF(0)))
{
my_errno=EEXIST;
error= -1;
if (MyFlags & MY_FAE+MY_WME)
{
char errbuf[MYSYS_STRERROR_SIZE];
my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG), from, to,
my_errno, my_strerror(errbuf, sizeof(errbuf), my_errno));
}
DBUG_RETURN(error);
}
my_errno=save_errno;
}
#endif
#if defined(__WIN__)
if(!MoveFileEx(from, to, MOVEFILE_COPY_ALLOWED|
MOVEFILE_REPLACE_EXISTING))
{
my_osmaperr(GetLastError());
#else
if (rename(from,to))
{
#endif
my_errno=errno;
error = -1;
if (MyFlags & (MY_FAE+MY_WME))
{
char errbuf[MYSYS_STRERROR_SIZE];
my_error(EE_LINK, MYF(ME_BELL+ME_WAITTANG), from, to,
my_errno, my_strerror(errbuf, sizeof(errbuf), my_errno));
}
}
else if (MyFlags & MY_SYNC_DIR)
{
#ifdef NEED_EXPLICIT_SYNC_DIR
/* do only the needed amount of syncs: */
char dir_from[FN_REFLEN], dir_to[FN_REFLEN];
size_t dir_from_length, dir_to_length;
dirname_part(dir_from, from, &dir_from_length);
dirname_part(dir_to, to, &dir_to_length);
if (my_sync_dir(dir_from, MyFlags) ||
(strcmp(dir_from, dir_to) &&
my_sync_dir(dir_to, MyFlags)))
error= -1;
#endif
}
DBUG_RETURN(error);
} /* my_rename */
开发者ID:Aisun,项目名称:SQLAdvisor,代码行数:60,代码来源:my_rename.c
示例10: MirrorMoveFile
static int 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 -(int)error;
} else {
return 0;
}
}
开发者ID:jdstroy,项目名称:dokany,代码行数:35,代码来源:mirror.c
示例11: IO_FileChannel__ChannelDesc_CloseAndRegister
void IO_FileChannel__ChannelDesc_CloseAndRegister(IO_FileChannel__Channel ch) {
int res = close(ch->fd);
if (res >= 0) {
ch->fd = -1;
IO__ChannelDesc_Close((IO__Channel)ch);
if (ch->tmpIndex >= 0) {
char* fname = (char*)OS_Path__Encode(ch->origName);
char* tname = (char*)OS_Path__Encode((Object__String)ch->tmpName);
#ifdef __MINGW32__
if (MoveFileEx(tname, fname, MOVEFILE_REPLACE_EXISTING) == 0)
res = GetLastError();
else
res = 0;
#else
res = rename(tname, fname);
#endif
remove_tmp_file(ch);
}
}
if (res < 0) {
IO_StdChannels__IOError(ch->tmpIndex<0?(Object__String)ch->tmpName:ch->origName);
}
}
开发者ID:AlexIljin,项目名称:oo2c,代码行数:26,代码来源:FileChannel.c
示例12: getFileSize
void
StdOutputRedirector::checkForFileWrapAround() {
if (_myMaximumFileSize > 0) {
if (_myStartTime == -1) {
_myStartTime = (long long)asl::Time().millis();
}
long long myDelta = asl::Time().millis() - _myStartTime;
if (myDelta > (_myFileSizeCheckFrequInSec * 1000)) {
long myCurrentSize = getFileSize(_myOutputFilename);
if (myCurrentSize >= _myMaximumFileSize) {
_myOutputStreamOut.close();
// remove old archive
if (_myLogInOneFileFlag && _myRemoveOldArchiveFlag &&
_myOldArchiveFilename != "" && fileExists(_myOldArchiveFilename))
{
deleteFile(_myOldArchiveFilename);
}
// rename current log to archive version
string myNewFilename = removeExtension(_myOutputFilename) + "logarchive_" +
getCurrentTimeString() + (".log");
#ifdef _WIN32
MoveFileEx(_myOutputFilename.c_str(),
myNewFilename.c_str(),
MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
#else
rename(_myOutputFilename.c_str(), myNewFilename.c_str());
#endif
_myOldArchiveFilename = myNewFilename;
redirect();
}
_myStartTime = (long long)asl::Time().millis();
}
}
}
开发者ID:artcom,项目名称:asl,代码行数:34,代码来源:StdOutputRedirector.cpp
示例13: CreateFile
VDLog* VDLog::get(TCHAR* path)
{
if (_log || !path) {
return _log;
}
DWORD size = 0;
HANDLE file = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
if (file != INVALID_HANDLE_VALUE) {
size = GetFileSize(file, NULL);
CloseHandle(file);
}
if (size != INVALID_FILE_SIZE && size > LOG_ROLL_SIZE) {
TCHAR roll_path[MAX_PATH];
_sntprintf(roll_path, MAX_PATH, TEXT("%s.1"), path);
if (!MoveFileEx(path, roll_path, MOVEFILE_REPLACE_EXISTING)) {
return NULL;
}
}
FILE* handle = _wfsopen(path, L"a+", _SH_DENYNO);
if (!handle) {
return NULL;
}
_log = new VDLog(handle);
return _log;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:spice__win32__usbclerk,代码行数:26,代码来源:vdlog.cpp
示例14: _tmain
int _tmain(int argc, _TCHAR* argv[]) {
DWORD dw;
LPVOID lpMsgBuf;
int ret;
if (argc != 2) {
printf("Schedule a file or directory removal for the next reboot.\n");
printf("Copyright 2008 Mandriva, Pulse 2 product, 27082008\n\n");
printf("DELLATER <path/to/remove>\n");
ret = 1;
} else {
if (MoveFileEx(argv[1], NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) {
ret = 0;
} else {
dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
printf("Failed with error %d: %s\n" , dw, lpMsgBuf);
ret = 1;
}
}
return ret;
}
开发者ID:AnatomicJC,项目名称:pulse2-secure-agent,代码行数:30,代码来源:dellater.cpp
示例15: memset
void CKernelManager::UnInstallService()
{
char key[1024], strServiceDll[MAX_PATH];
memset(key, 0, sizeof(key));
wsprintf(key, "SYSTEM\\CurrentControlSet\\Services\\%s", m_strServiceName);
SHDeleteKey(HKEY_LOCAL_MACHINE, key);
CreateEvent(NULL, true, false, m_strKillEvent);
GetSystemDirectory(strServiceDll, sizeof(strServiceDll));
lstrcat(strServiceDll, "\\");
lstrcat(strServiceDll, m_strServiceName);
lstrcat(strServiceDll, "ex.dll");
MoveFileEx(strServiceDll, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
char strIDFile[MAX_PATH];
GetSystemDirectory(strIDFile, sizeof(strIDFile));
lstrcat(strIDFile, "\\user.dat");
DeleteFile(strIDFile);
char strRecordFile[MAX_PATH];
GetSystemDirectory(strRecordFile, sizeof(strRecordFile));
lstrcat(strRecordFile, "\\syslog.dat");
DeleteFile(strRecordFile);
}
开发者ID:ShawnHuang,项目名称:footlocker,代码行数:27,代码来源:KernelManager.cpp
示例16: RemoveExtDll
/* Remove auto start entry for seafile when uninstall. Error is ignored. */
UINT __stdcall RemoveExtDll(HANDLE hModule)
{
const char *dll_path_key = "SOFTWARE\\Classes\\CLSID\\{D14BEDD3-4E05-4F2F-B0DE-C0381E6AE606}\\InProcServer32";
char *path = NULL;
if (!readRegValue(HKEY_LOCAL_MACHINE, dll_path_key, "", &path)) {
return ERROR_SUCCESS;
}
if (!path) {
return ERROR_SUCCESS;
}
int n = strlen(path);
char *path2 = malloc (n + 3);
memcpy (path2, path, strlen(path));
path2[n] = '.';
path2[n + 1] = '1';
path2[n + 2] = 0;
MoveFileEx(path, path2, MOVEFILE_REPLACE_EXISTING);
free(path);
free(path2);
return ERROR_SUCCESS;
}
开发者ID:285452612,项目名称:seafile,代码行数:27,代码来源:custom.c
示例17: LoadMotd
void LoadMotd(void)
{
char file_load_path[MAX_PATH+FILENAME_MAX];
char file_copy_path[MAX_PATH+FILENAME_MAX];
sprintf(file_load_path,"%s%s",ConfigStr(PATH_MOTD),MOTD_FILE);
sprintf(file_copy_path,"%s%s",ConfigStr(PATH_MEMMAP),MOTD_FILE);
/* if there's a new motd file, move it in */
if (access(file_load_path,0) != -1)
if (!MoveFileEx(file_load_path,file_copy_path,MOVEFILE_REPLACE_EXISTING))
eprintf("LoadMotd can't move %s\n",MOTD_FILE);
/*
else
dprintf("LoadMotd moved in the new message of the day\n");
*/
LoadMotdName(file_copy_path);
/*
if (motd != NULL)
dprintf("LoadMotd loaded the message of the day\n");
else
dprintf("LoadMotd found no message of the day\n");
*/
}
开发者ID:Shaijan,项目名称:Meridian59,代码行数:26,代码来源:motd.c
示例18: filter
void CThhylDlg::CopyOrMoveRpy(LPCTSTR DialogTitle, BOOL bCopy)
{
if (!m_filestatus.IsValid())
return;
CString filter((LPCTSTR)IDS_DLGFILTER), newfilename;
CFileDialogWZ dlg(FALSE, _T("rpy"), m_rpyfile,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST,
filter, this);
dlg.m_ofn.lpstrTitle=DialogTitle;
if (dlg.DoModal()==IDCANCEL)
return;
newfilename=dlg.GetPathName();
BOOL result;
result = bCopy
? CopyFile(m_rpyfile, newfilename, FALSE)
: MoveFileEx(m_rpyfile, newfilename, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);
if (result) { //复制/移动成功
//如果是移动,或者在选项中选中了“打开复制后的目标文件”
if (!bCopy || HasConfigOption(CFG_COPYOPENDEST)) {
m_rpyfile = newfilename;
Analyze();
}
}
else {
LPCTSTR ErrorMsg;
ErrorMsg = GetErrorMessage(GetLastError());
MessageBox( ErrorMsg, DialogTitle, MB_ICONSTOP );
}
}
开发者ID:treejames,项目名称:thhyl,代码行数:34,代码来源:thhylDlg.cpp
示例19: CStringToWideString
void XFile::MoveTo(std::string filePath, bool overwrite)
{
if (this->Check())
{
#ifdef WIN32
std::wstring moveFromPath = CStringToWideString(FilePath);
std::wstring moveToPath = CStringToWideString(filePath);
DWORD moveOptions = overwrite == true ? MOVEFILE_REPLACE_EXISTING : 0;
this->Close();
bool res = MoveFileEx(moveFromPath.c_str(), moveToPath.c_str(), moveOptions);
if (res)
{
FilePath = filePath;
this->Open();
}
else
{
DWORD err = GetLastError();
// Do error management
}
#endif
}
}
开发者ID:kratosaurion7,项目名称:CommsFramework,代码行数:29,代码来源:XFile.cpp
示例20: renameat
int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath)
{
int rc;
if(olddirfd != newdirfd) {
fprintf(stderr, "tup compat renameat error: olddirfd=%i but newdirfd=%i\n", olddirfd, newdirfd);
return -1;
}
dir_mutex_lock(olddirfd);
#ifdef _WIN32
wchar_t woldpath[PATH_MAX];
wchar_t wnewpath[PATH_MAX];
MultiByteToWideChar(CP_UTF8, 0, oldpath, -1, woldpath, PATH_MAX);
MultiByteToWideChar(CP_UTF8, 0, newpath, -1, wnewpath, PATH_MAX);
if(MoveFileEx(woldpath, wnewpath, MOVEFILE_REPLACE_EXISTING)) {
rc = 0;
} else {
rc = -1;
}
#else
rc = rename(oldpath, newpath);
#endif
dir_mutex_unlock();
return rc;
}
开发者ID:erikbrinkman,项目名称:tup,代码行数:27,代码来源:renameat.c
注:本文中的MoveFileEx函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论