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


C++ CopyFileW函数代码示例

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


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

示例1: Sleep

	/*!
	 * Copies file from source path to destination.
	 *
	 * @param sourceFilename Path to the file.
	 * @param destFilename Destination file path.
	 * @param doOverwrite Do overwrite destination file if it exists.
	 * @returns True if file was successfully moved.
	 */
	GDAPI bool FileUtilitiesWindows::FileCopy(WideString const& sourceFilename, WideString const& destFilename, bool const doOverwrite /*= false*/)
	{
		auto const sourceFilenameSystem = Paths::Platformize(sourceFilename);
		auto const destFilenameSystem = Paths::Platformize(destFilename);
		if (CopyFileW(sourceFilenameSystem.CStr(), destFilenameSystem.CStr(), !doOverwrite) == FALSE)
		{
			Sleep(0);
			return CopyFileW(sourceFilenameSystem.CStr(), destFilenameSystem.CStr(), !doOverwrite) == TRUE;
		}
		return true;
	}
开发者ID:GoddamnIndustries,项目名称:GoddamnEngine,代码行数:19,代码来源:FileUtilitiesWindows.cpp

示例2: FixAutoplay

void FixAutoplay( LPCWSTR wszApplicationName, LPCWSTR wszCommandLine, LPCWSTR wszCurrentDirectory )
{
	LPCWSTR uppApplicationName = _wcsupr( _wcsdup( wszApplicationName ) );

	// only UT2004
	if( wcsstr(uppApplicationName,L"UT2004.EXE") == NULL )
		return;

	// read mod name from commandline, must be specified
	LPCWSTR uppCommandLine = _wcsupr( _wcsdup( wszCommandLine ) );
	LPWSTR pb = wcsstr(uppCommandLine,L"-MOD=");
	if( pb == NULL )
		return;
	
	// mod name must be valid
	LPWSTR ps = pb + wcslen(L"-MOD=");
	LPWSTR token = wcstok( ps, L" " );
	if( token == NULL )
		return;

	// mod directory must be valid
	if( !SetCurrentDirectoryW(wszCurrentDirectory)
	||	!SetCurrentDirectoryW(L"..")
	||	!SetCurrentDirectoryW(token) )
		return;

	// copy Autoplay.ut2
	if( !CopyFileW( L"..\\Maps\\Autoplay.ut2", L"Maps\\Autoplay.ut2", FALSE ) )
		return;

	//MessageBox( NULL, TEXT("Copy OK"), TEXT("SwAutoplayFix"), MB_OK );
}
开发者ID:roman-dzieciol,项目名称:SwAutoplayFix,代码行数:32,代码来源:SwAutoplayFix.cpp

示例3: CopyFolder

bool CopyFolder(std::wstring src, std::wstring dst)
{
	if(!os_create_dir(dst))
		return false;

	std::vector<SFile> curr_files=getFiles(src);
	for(size_t i=0;i<curr_files.size();++i)
	{
		if(curr_files[i].isdir)
		{
			bool b=CopyFolder(src+os_file_sep()+curr_files[i].name, dst+os_file_sep()+curr_files[i].name);
			if(!b)
				return false;
		}
		else
		{
			if(!os_create_hardlink(dst+os_file_sep()+curr_files[i].name, src+os_file_sep()+curr_files[i].name, false, NULL) )
			{
				BOOL b=CopyFileW( (src+os_file_sep()+curr_files[i].name).c_str(), (dst+os_file_sep()+curr_files[i].name).c_str(), FALSE);
				if(!b)
				{
					return false;
				}
			}
		}
	}

	return true;
}
开发者ID:Averroes,项目名称:urbackup_backend,代码行数:29,代码来源:main.cpp

示例4: BLI_copy

int BLI_copy(const char *file, const char *to)
{
	int err;

	/* windows doesn't support copying to a directory
	 * it has to be 'cp filename filename' and not
	 * 'cp filename destdir' */

	BLI_strncpy(str, to, sizeof(str));
	/* points 'to' to a directory ? */
	if (BLI_last_slash(str) == (str + strlen(str) - 1)) {
		if (BLI_last_slash(file) != NULL) {
			strcat(str, BLI_last_slash(file) + 1);
		}
	}

	UTF16_ENCODE(file);
	UTF16_ENCODE(str);
	err = !CopyFileW(file_16, str_16, false);
	UTF16_UN_ENCODE(str);
	UTF16_UN_ENCODE(file);

	if (err) {
		callLocalErrorCallBack("Unable to copy file!");
		printf(" Copy from '%s' to '%s' failed\n", file, str);
	}

	return err;
}
开发者ID:linkedinyou,项目名称:blender-git,代码行数:29,代码来源:fileops.c

示例5: copyFiles

 size_t copyFiles(std::wstring sourcepath, std::wstring destpath, std::wstring mask, bool case_sensitive, bool rec, bool overwrite)
     {
     #if defined (_MSC_VER)
     int copied = 0;
     if ((sourcepath.length() != 0) && (sourcepath[sourcepath.length() - 1] != L'\\'))  { sourcepath += L"\\"; }
     if ((destpath.length() != 0) && (destpath[destpath.length() - 1] != L'\\'))        { destpath += L"\\"; }
     std::vector<std::wstring> tabsource;
     if (getFileList(sourcepath, mask, case_sensitive, tabsource, rec, true, rec) == false) { return(-1); }
     for (std::vector<std::wstring>::iterator it = tabsource.begin(); it != tabsource.end(); it++)
         {
         if ((it->length() != 0) && ((*it)[it->length() - 1] == L'\\'))
             {
             if (CreateDirectoryW((destpath + (*it)).c_str(), NULL) == 0) { if (GetLastError() != ERROR_ALREADY_EXISTS) { return -1; } }
             }
         else
             {
             bool fie = false; if (overwrite == false) { fie = true; }
             if (CopyFileW((sourcepath + (*it)).c_str(), (destpath + (*it)).c_str(), fie) == 0) { return -1; }
             }
         copied++;
         }
     return copied;
     #else
     // TODO
     #endif
     return -1;
     }
开发者ID:vindar,项目名称:mtools,代码行数:27,代码来源:fileio.cpp

示例6: SetFileAttributesW

DWORD FFileManagerWindows::InternalCopy( const TCHAR* DestFile, const TCHAR* SrcFile, UBOOL ReplaceExisting, UBOOL EvenIfReadOnly, UBOOL Attributes, FCopyProgress* Progress )
{
	if( EvenIfReadOnly )
	{
		SetFileAttributesW(DestFile, 0);
	}
	DWORD Result;
	if( Progress )
	{
		Result = FFileManagerGeneric::Copy( DestFile, SrcFile, ReplaceExisting, EvenIfReadOnly, Attributes, Progress );
	}
	else
	{
		MakeDirectory(*FFilename(DestFile).GetPath(), TRUE);
		if( CopyFileW(SrcFile, DestFile, !ReplaceExisting) != 0)
		{
			Result = COPY_OK;
		}
		else
		{
			Result = COPY_MiscFail;
		}
	}
	if( Result==COPY_OK && !Attributes )
	{
		SetFileAttributesW(DestFile, 0);
	}
	return Result;
}
开发者ID:LiuKeHua,项目名称:colorful-engine,代码行数:29,代码来源:FFileManagerWindows.cpp

示例7: copy_file

static HRESULT copy_file( const WCHAR *src_dir, DWORD src_len, const WCHAR *dst_dir, DWORD dst_len,
                          const WCHAR *filename )
{
    WCHAR *src_file, *dst_file;
    DWORD len = strlenW( filename );
    HRESULT hr = S_OK;

    if (!(src_file = HeapAlloc( GetProcessHeap(), 0, (src_len + len + 1) * sizeof(WCHAR) )))
        return E_OUTOFMEMORY;
    memcpy( src_file, src_dir, src_len * sizeof(WCHAR) );
    strcpyW( src_file + src_len, filename );

    if (!(dst_file = HeapAlloc( GetProcessHeap(), 0, (dst_len + len + 1) * sizeof(WCHAR) )))
    {
        HeapFree( GetProcessHeap(), 0, src_file );
        return E_OUTOFMEMORY;
    }
    memcpy( dst_file, dst_dir, dst_len * sizeof(WCHAR) );
    strcpyW( dst_file + dst_len, filename );

    if (!CopyFileW( src_file, dst_file, FALSE )) hr = HRESULT_FROM_WIN32( GetLastError() );
    HeapFree( GetProcessHeap(), 0, src_file );
    HeapFree( GetProcessHeap(), 0, dst_file );
    return hr;
}
开发者ID:GYGit,项目名称:reactos,代码行数:25,代码来源:asmcache.c

示例8: DownloadBSC_OnStopBinding

static HRESULT WINAPI DownloadBSC_OnStopBinding(IBindStatusCallback *iface,
        HRESULT hresult, LPCWSTR szError)
{
    DownloadBSC *This = impl_from_IBindStatusCallback(iface);

    TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));

    if(This->file_name) {
        if(This->cache_file) {
            BOOL b;

            b = CopyFileW(This->cache_file, This->file_name, FALSE);
            if(!b)
                FIXME("CopyFile failed: %u\n", GetLastError());
        }else {
            FIXME("No cache file\n");
        }
    }

    if(This->callback)
        IBindStatusCallback_OnStopBinding(This->callback, hresult, szError);

    if(This->binding) {
        IBinding_Release(This->binding);
        This->binding = NULL;
    }

    return S_OK;
}
开发者ID:bpowers,项目名称:wine,代码行数:29,代码来源:download.c

示例9: copy_user_manual

/* Copy manual from install dir to Seafile directory */
void
copy_user_manual ()
{
    char *installdir;            /* C:\Program Files\Seafile */
    char *seafdir;              /* C:\Seafile */
    char *src_path;             /* C:\Program Files\Seafile\help.txt */
    char *dst_path;             /* C:\Seafile\help.txt */

    wchar_t *src_path_w, *dst_path_w;

    installdir = g_path_get_dirname (seafile_bin_dir);
    seafdir = g_path_get_dirname (applet->seafile_dir);

    src_path = g_build_filename (installdir, _("Seafile help.txt"), NULL);
    dst_path = g_build_filename (seafdir, _("Seafile help.txt"), NULL);

    src_path_w = wchar_from_utf8 (src_path);
    dst_path_w = wchar_from_utf8 (dst_path);

    BOOL failIfExist = FALSE;
    CopyFileW (src_path_w, dst_path_w, failIfExist);

    g_free (installdir);
    g_free (seafdir);
    g_free (src_path);
    g_free (dst_path);
    g_free (src_path_w);
    g_free (dst_path_w);
}
开发者ID:Jack-Tsue,项目名称:seafile,代码行数:30,代码来源:init-ccnet.c

示例10: downloadcb_OnStopBinding

static HRESULT WINAPI downloadcb_OnStopBinding(IBindStatusCallback *iface, HRESULT hresult, LPCWSTR szError)
{
    struct downloadcb *This = impl_from_IBindStatusCallback(iface);

    TRACE("(%p)->(%08x %s)\n", This, hresult, debugstr_w(szError));

    if (FAILED(hresult))
    {
        This->hr = hresult;
        goto done;
    }

    if (!This->cache_file)
    {
        This->hr = E_FAIL;
        goto done;
    }

    if (CopyFileW(This->cache_file, This->file_name, FALSE))
        This->hr = S_OK;
    else
    {
        ERR("CopyFile failed: %u\n", GetLastError());
        This->hr = E_FAIL;
    }

done:
    SetEvent(This->event_done);
    return S_OK;
}
开发者ID:Moteesh,项目名称:reactos,代码行数:30,代码来源:inseng_main.c

示例11: SetupDecompressOrCopyFileW

/***********************************************************************
 *      SetupDecompressOrCopyFileW  ([email protected])
 *
 * Copy a file and decompress it if needed.
 *
 * PARAMS
 *  source [I] File to copy.
 *  target [I] Filename of the copy.
 *  type   [I] Compression type.
 *
 * RETURNS
 *  Success: ERROR_SUCCESS
 *  Failure: Win32 error code.
 */
DWORD WINAPI SetupDecompressOrCopyFileW( PCWSTR source, PCWSTR target, PUINT type )
{
    UINT comp;
    DWORD ret = ERROR_INVALID_PARAMETER;

    if (!source || !target) return ERROR_INVALID_PARAMETER;

    if (!type) comp = detect_compression_type( source );
    else comp = *type;

    switch (comp)
    {
    case FILE_COMPRESSION_NONE:
        if (CopyFileW( source, target, FALSE )) ret = ERROR_SUCCESS;
        else ret = GetLastError();
        break;
    case FILE_COMPRESSION_WINLZA:
        ret = decompress_file_lz( source, target );
        break;
    case FILE_COMPRESSION_NTCAB:
    case FILE_COMPRESSION_MSZIP:
        ret = decompress_file_cab( source, target );
        break;
    default:
        WARN("unknown compression type %d\n", comp);
        break;
    }

    TRACE("%s -> %s %d\n", debugstr_w(source), debugstr_w(target), comp);
    return ret;
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:45,代码来源:misc.c

示例12: newFileQ

void AnotherMainWindow::DoTask()
{
    int t1s = QTime::currentTime().msec();
    QList<QString>* fList = new QList<QString>();
    DirWorker::FindFiles(_taskOptions->FromDir, "*.txt", fList);

    int len = fList->length();

    for(int i = 0; i < len; i++)
    {
        QString fName = fList->at(i);
        std::wstring sst = fName.toStdWString();
        LPCWSTR sourseFile =  sst.c_str();
        QString newFileQ(_taskOptions->ToDir + "\\" + QString::number(1) + '_' + QString::number(i) + ".html");
        std::wstring nst = newFileQ.toStdWString();
        LPCWSTR newFile = nst.c_str();
        if(!CopyFileW(sourseFile, newFile, false))
        {
            QMessageBox::critical(0, "Ошибка", "Не удалось скопировать файл: " + fName);
            return;
        }
        FileCreateParams* params = new FileCreateParams();
        params->CreateOptions = OPEN_EXISTING;
        params->DesiredAccess = GENERIC_READ;
        params->DesiredAccess += GENERIC_WRITE;
        params->FileName = newFileQ;
        FileWorker::OpenCreateFile(params);
        FileWorker::UpdateFile(params);
        FileWorker::CloseOpenedFile(params);
        delete params;
    }
    int t2s = QTime::currentTime().msec();
    ui->DurationBox->setText(QString::number(t2s - t1s));
}
开发者ID:Funjy,项目名称:SP_Labs,代码行数:34,代码来源:anothermainwindow.cpp

示例13: ServiceUpdate

bool ServiceUpdate(bool validService)
{
	if (validService)
	{
		ServiceInstaller si;

		if (si.run() != 0)
			return false;
	}
	else
	{
		std::wstring appPath = UTIL::OS::getCommonProgramFilesPath();

		if (!FolderExists(appPath.c_str()))
			CreateDirectoryW(appPath.c_str(), NULL);

		std::wstring newService = UTIL::OS::getCommonProgramFilesPath(L"desura_service.exe");
		std::wstring curService = UTIL::OS::getCurrentDir(L"desura_service.exe");

		char regname[255];
		Safe::snprintf(regname, 255, "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\%s\\ImagePath", SERVICE_NAME);

		CopyFileW(curService.c_str(), newService.c_str(), FALSE);
		UTIL::WIN::setRegValue(regname, gcString(newService).c_str());
	}

	return true;
}
开发者ID:karolherbst,项目名称:Desurium,代码行数:28,代码来源:UpdateFunctions.cpp

示例14: FSCopyFile

bool FSCopyFile(const unicode_t *srcFileName, const unicode_t *desFileName, bool bFailIfExists/* = true*/)
{
#if defined(_WIN32_WCE)
	return 	CopyFile(srcFileName, desFileName, bFailIfExists) == TRUE;
#elif defined(WIN32)
	return 	CopyFileW(srcFileName, desFileName, bFailIfExists) == TRUE;
#elif defined(__APPLE_CPP__) || defined(__APPLE_CC__)
	FSString	srcString(srcFileName);
	FSString	desString(desFileName);
	
	if ( srcString == desString ) return false;
	
	if ( bFailIfExists )
	{
		if ( _ExistFile(desString.GetString()) ) return false;
	}
	
	return _CopyFile(srcFileName, desFileName);
	
//	return copyfile(srcString.GetString(), desString.GetString(), NULL, bFailIfExists ? COPYFILE_ALL | COPYFILE_EXCL : COPYFILE_ALL) == 0;
#else
	FSString	srcString(srcFileName);
	FSString	desString(desFileName);
	
	if ( srcString == desString ) return false;
	
	if ( bFailIfExists )
	{
		if ( _ExistFile(desString.GetString()) ) return false;
	}
	return copyfile(srcString.GetString(), desString.GetString(), NULL, bFailIfExists? COPYFILE_ALL | COPYFILE_EXCL : COPYFILE_ALL) == 0;
#endif
}
开发者ID:kjoon010,项目名称:IncubeTech-Contribs,代码行数:33,代码来源:FileSystem.cpp

示例15: copyFile

bool Platform::copyFile(std::string from, std::string to)
{
    boost::replace_all(from, "/", "\\");
    boost::replace_all(to, "/", "\\");
    if(CopyFileW(stdext::utf8_to_utf16(from).c_str(), stdext::utf8_to_utf16(to).c_str(), FALSE) == 0)
        return false;
    return true;
}
开发者ID:Ablankzin,项目名称:otclient,代码行数:8,代码来源:win32platform.cpp


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