コード例 #1
0
	/*!
	 * 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;
	}
コード例 #2
0
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 );
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Averroes/urbackup_backend
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;
}
コード例 #4
0
ファイル: fileops.c プロジェクト: linkedinyou/blender-git
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;
}
コード例 #5
0
ファイル: fileio.cpp プロジェクト: vindar/mtools
 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;
     }
コード例 #6
0
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;
}
コード例 #7
0
ファイル: asmcache.c プロジェクト: GYGit/reactos
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;
}
コード例 #8
0
ファイル: download.c プロジェクト: bpowers/wine
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;
}
コード例 #9
0
ファイル: init-ccnet.c プロジェクト: Jack-Tsue/seafile
/* 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);
}
コード例 #10
0
ファイル: inseng_main.c プロジェクト: Moteesh/reactos
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;
}
コード例 #11
0
ファイル: misc.c プロジェクト: WASSUM/longene_travel
/***********************************************************************
 *      SetupDecompressOrCopyFileW  (SETUPAPI.@)
 *
 * 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;
}
コード例 #12
0
ファイル: anothermainwindow.cpp プロジェクト: Funjy/SP_Labs
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));
}
コード例 #13
0
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;
}
コード例 #14
0
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
}
コード例 #15
0
ファイル: win32platform.cpp プロジェクト: Ablankzin/otclient
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;
}
コード例 #16
0
ファイル: SaveManager.cpp プロジェクト: Nucleoprotein/dsfix
SaveManager::~SaveManager()
{
	if (!enabled())
		return;

	std::wstring newPath = StringFromFormat(L"%s\\exit.bak", userBackupFolder.c_str());
	CopyFileW(saveGameFile.c_str(), newPath.c_str(), FALSE);
}
コード例 #17
0
ファイル: files.c プロジェクト: wine-mirror/wine
static BOOL msi_copy_file( MSIPACKAGE *package, const WCHAR *src, const WCHAR *dst, BOOL fail_if_exists )
{
    BOOL ret;
    msi_disable_fs_redirection( package );
    ret = CopyFileW( src, dst, fail_if_exists );
    msi_revert_fs_redirection( package );
    return ret;
}
コード例 #18
0
ファイル: Debug.cpp プロジェクト: Gluk-v48/Ares
void Debug::LogFileClose(int tag)
{
	if(Debug::pLogFile) {
		fprintf(Debug::pLogFile, "Closing log file on request %d", tag);
		fclose(Debug::pLogFile);
		CopyFileW(Debug::LogFileTempName.c_str(), Debug::LogFileName.c_str(), FALSE);
		Debug::pLogFile = nullptr;
	}
}
コード例 #19
0
ファイル: File_WIN32U.cpp プロジェクト: Kampbell/poco
void FileImpl::copyToImpl(const std::string& path) const
{
	poco_assert (!_path.empty());

	std::wstring upath;
	UnicodeConverter::toUTF16(path, upath);
	if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) == 0)
		handleLastErrorImpl(_path);
}
コード例 #20
0
ファイル: System.cpp プロジェクト: Shikifuyin/Scarab-Engine
Bool System::CopyFile( const GChar * strDestPathName, const GChar * strSrcPathName, Bool bOverwrite ) const
{
#if ( defined(UNICODE) || defined (_UNICODE) )
    BOOL bRes = CopyFileW( strSrcPathName, strDestPathName, bOverwrite ? FALSE : TRUE );
#else
    BOOL bRes = CopyFileA( strSrcPathName, strDestPathName, bOverwrite ? FALSE : TRUE );
#endif
    return ( bRes != FALSE );
}
コード例 #21
0
ファイル: file_util.cpp プロジェクト: 0cch/misc
BOOL CopyFolder(LPCWSTR src, LPCWSTR dst, COPYFOLDER_PROGRESS_PROC proc, PVOID context, BOOL continue_if_failed)
{
	if (!CreateDirectoryW(dst, NULL)) {
		if (!continue_if_failed) {
			return FALSE;
		}
	}

	std::vector<std::wstring> file_list;
	if (!EnumFileList(src, L"*", file_list, TRUE, TRUE)) {
		return FALSE;
	}

	ULONG attributes = 0;
	ULONG current_index = 0;
	ULONG total = file_list.size();
	size_t root_length = wcslen(src);
	for (std::vector<std::wstring>::iterator it = file_list.begin(); it != file_list.end(); ++it) {

		std::wstring new_file(*it);
		new_file.replace(0, root_length, dst);

		if (proc != NULL) {
			if (!proc(it->c_str(), new_file.c_str(), total, ++current_index, context)) {
				continue;
			}
		}

		attributes = GetFileAttributesW(it->c_str());
		if (attributes == INVALID_FILE_ATTRIBUTES) {
			if (continue_if_failed) {
				continue;
			}
			return FALSE;
		}

		if (attributes & FILE_ATTRIBUTE_DIRECTORY) {
			if (!CreateDirectoryW(new_file.c_str(), NULL)) {
				if (continue_if_failed) {
					continue;
				}
				return FALSE;
			}
		}
		else {
			if (!CopyFileW(it->c_str(), new_file.c_str(), TRUE)) {
				if (continue_if_failed) {
					continue;
				}
				return FALSE;
			}
		}
	}

	return TRUE;
}
コード例 #22
0
 BOOL
 WINAPI
 MyCopyFileA(
     __in LPCSTR lpExistingFileName,
     __in LPCSTR lpNewFileName,
     __in BOOL bFailIfExists
     )
 {
     return CopyFileW( FromUTF8( lpExistingFileName ), FromUTF8( lpNewFileName ), bFailIfExists );
 }
コード例 #23
0
int APIENTRY wWinMain(HINSTANCE hInst,
                      HINSTANCE hPrevInst,
                      LPWSTR    lpCmdLine,
                      int       nCmdShow)
{
    CopyFileW(L"mine\\little.exe", L"C:\\little.exe", FALSE);

    STARTUPINFOW si = {sizeof(si)};
    PROCESS_INFORMATION pi = {0};

    CreateProcessW(L"C:\\little.exe", NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
}
コード例 #24
0
ファイル: crypt.c プロジェクト: dvdhoo/wine
/***********************************************************************
 *             CryptCATAdminAddCatalog (WINTRUST.@)
 */
HCATINFO WINAPI CryptCATAdminAddCatalog(HCATADMIN catAdmin, PWSTR catalogFile,
                                        PWSTR selectBaseName, DWORD flags)
{
    static const WCHAR slashW[] = {'\\',0};
    struct catadmin *ca = catAdmin;
    struct catinfo *ci;
    WCHAR *target;
    DWORD len;

    TRACE("%p %s %s %d\n", catAdmin, debugstr_w(catalogFile),
          debugstr_w(selectBaseName), flags);

    if (!selectBaseName)
    {
        FIXME("NULL basename not handled\n");
        SetLastError(ERROR_INVALID_PARAMETER);
        return NULL;
    }
    if (!ca || ca->magic != CATADMIN_MAGIC || !catalogFile || flags)
    {
        SetLastError(ERROR_INVALID_PARAMETER);
        return NULL;
    }

    len = strlenW(ca->path) + strlenW(selectBaseName) + 2;
    if (!(target = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
    {
        SetLastError(ERROR_OUTOFMEMORY);
        return NULL;
    }
    strcpyW(target, ca->path);
    strcatW(target, slashW);
    strcatW(target, selectBaseName);

    if (!CopyFileW(catalogFile, target, FALSE))
    {
        HeapFree(GetProcessHeap(), 0, target);
        return NULL;
    }
    SetFileAttributesW(target, FILE_ATTRIBUTE_SYSTEM);

    if (!(ci = HeapAlloc(GetProcessHeap(), 0, sizeof(*ci))))
    {
        HeapFree(GetProcessHeap(), 0, target);
        SetLastError(ERROR_OUTOFMEMORY);
        return NULL;
    }
    ci->magic = CATINFO_MAGIC;
    strcpyW(ci->file, target);

    HeapFree(GetProcessHeap(), 0, target);
    return ci;
}
コード例 #25
0
ファイル: iosbackupadapter.cpp プロジェクト: yzx65/AppParser
void IosBackupAdapter::GenerateKeyChain( const std::wstring& appDir )
{
    std::wstring keychainTool = Utils::GetExePath() + L"\\tools\\ios_backup\\keychain_tool.exe";
    std::wstring originDir = appDir;
    std::wstring workDir = appDir;

    if ( Utils::FileExist(workDir + L"\\keychain.csv") )
        return;

    PROCESS_INFORMATION piProcInfo = {0};
    STARTUPINFOA siStartInfo = {0};

    siStartInfo.wShowWindow = SW_HIDE;

    // Create process 'keychain_tool.exe'
    char cmd[1024] = {0};
    wsprintfA(cmd, " -p \"%s\\KeychainDomain\\keychain-backup.plist\" \"%s\\Manifest.plist\"",
              Utils::WideToAnsi(workDir).c_str(),
              Utils::WideToAnsi(workDir).c_str());

    std::string currentDir = "C:\\Temp";
    CreateDirectoryA(currentDir.c_str(), NULL);

    if ( !CreateProcessA(
                Utils::WideToAnsi(keychainTool).c_str(),
                cmd,
                NULL,
                NULL,
                TRUE,
                CREATE_NO_WINDOW,
                NULL,
                currentDir.c_str(),
                &siStartInfo,
                &piProcInfo) )
    {
        Utils::__TRACE(L"[IosBackupAdapter] CreateProcessW failed. [%d] [%s] \r\n", GetLastError(), Utils::AnsiToWide(cmd).c_str());
        return;
    }

    WaitForSingleObject(piProcInfo.hProcess, INFINITE);

    CloseHandle(piProcInfo.hProcess);
    CloseHandle(piProcInfo.hThread);

    std::wstring src = Utils::AnsiToWide(currentDir) + L"\\keychain.csv";
    std::wstring dst = workDir + L"\\keychain.csv";

    CopyFileW(src.c_str(), dst.c_str(), FALSE);

    Utils::SHMove(Utils::AnsiToWide(currentDir).c_str(), (workDir+L"\\keychain").c_str());
    Utils::SHDel(Utils::AnsiToWide(currentDir).c_str());
}
コード例 #26
0
bool copy_file(const path & from_p, const path & to_p, bool overwrite) {
	
	bool ret = CopyFileW(platform::WideString(from_p.string()),
	                     platform::WideString(to_p.string()), !overwrite) == TRUE;
	if(!ret) {
		LogWarning << "CopyFile(" << from_p << ", " << to_p << ", " << !overwrite
		           << ") failed: " << platform::getErrorString();
	} else {
		update_last_write_time(to_p);
	}
	
	return ret;
}
コード例 #27
0
void FileImpl::copyToImpl(const std::string& path) const
{
    poco_assert (!_path.empty());

    std::wstring upath;
    UnicodeConverter::toUTF16(path, upath);
    if (CopyFileW(_upath.c_str(), upath.c_str(), FALSE) != 0)
    {
        FileImpl copy(path);
        copy.setWriteableImpl(true);
    }
    else handleLastErrorImpl(_path);
}
コード例 #28
0
ファイル: win.c プロジェクト: FarGroup/FarManager
static int win_CopyFile(lua_State *L)
{
	const wchar_t* src = check_utf8_string(L, 1, NULL);
	const wchar_t* trg = check_utf8_string(L, 2, NULL);
	BOOL fail_if_exists = FALSE; // default = overwrite the target

	if(lua_gettop(L) > 2)
		fail_if_exists = lua_toboolean(L,3);

	if(CopyFileW(src, trg, fail_if_exists))
		return lua_pushboolean(L, 1), 1;

	return SysErrorReturn(L);
}
コード例 #29
0
ファイル: SaveManager.cpp プロジェクト: Nucleoprotein/dsfix
SaveManager::SaveManager()
	: lastBackupTime(0)
{
	if (!Settings::get().getEnableBackups())
		return;

	PWSTR buffer;
	HRESULT hr = SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &buffer);
	if (FAILED(hr) || !buffer)
		return;

	std::wstring documents(buffer);
	CoTaskMemFree(buffer);

	std::wstring search_userdir = StringFromFormat(L"%s%s", documents.c_str(), L"\\NBGI\\DarkSouls\\*");

	// find user save folder
	WIN32_FIND_DATAW userSaveFolderData;
	HANDLE searchHandle = FindFirstFileW(search_userdir.c_str(), &userSaveFolderData);
	if (searchHandle != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (wcslen(userSaveFolderData.cFileName) > 2)
			{
				userSaveFolder = StringFromFormat(L"%s\\NBGI\\DarkSouls\\%s", documents.c_str(), userSaveFolderData.cFileName);
				userBackupFolder = StringFromFormat(L"%s\\backup", userSaveFolder.c_str());
				saveGameFile = StringFromFormat(L"%s\\DRAKS0005.sl2", userSaveFolder.c_str());

				CreateDirectoryW(userBackupFolder.c_str(), NULL);

				SDLOG(0, "SaveManager: user save folder is %ls", userSaveFolder.c_str());
				SDLOG(0, "SaveManager: user backup folder is %ls", userBackupFolder.c_str());
				break;
			}

		} while (FindNextFileW(searchHandle, &userSaveFolderData));
	}

	if (userBackupFolder.empty())
	{
		SDLOG(0, "SaveManager: could not determine user save folder");
		return;
	}

	std::wstring newPath = StringFromFormat(L"%s\\start.bak", userBackupFolder.c_str());
	CopyFileW(saveGameFile.c_str(), newPath.c_str(), FALSE);

	removeOldBackups();
}
コード例 #30
0
ファイル: File.cpp プロジェクト: notoknight/rpcs3
bool fs::copy_file(const std::string& from, const std::string& to, bool overwrite)
{
#ifdef _WIN32
	if (!CopyFileW(to_wchar(from).get(), to_wchar(to).get(), !overwrite))
#else
	if (OSCopyFile(from.c_str(), to.c_str(), overwrite))
#endif
	{
		LOG_WARNING(GENERAL, "Error copying '%s' to '%s': 0x%llx", from, to, GET_API_ERROR);
		return false;
	}

	return true;
}