gui_message_return CheckInstallNLM( const char *name, vhandle var_handle ) { char unpacked_as[_MAX_PATH]; char temp[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; _splitpath( name, drive, dir, fname, ext ); _makepath( unpacked_as, drive, dir, fname, "._N_" ); if( CheckNewer( unpacked_as, name ) ) { _makepath( temp, NULL, sysPath, fname, ext ); if( CheckNewer( unpacked_as, temp ) ) { chmod( name, PMODE_RWX ); DoCopyFile( unpacked_as, name, false ); strcpy( temp, fname ); strcat( temp, "_NLM_installed" ); SetVariableByName( temp, "1" ); SetVariableByHandle( var_handle, temp ); } } remove( unpacked_as ); return( GUI_RET_OK ); }
static bool CheckWin95Uninstall( int argc, char **argv ) { // The Windows 95 version of setup gets installed as the // uninstall utility. So that it can erase itself, the setup // program gets copied to the Windows directory, and run from // there. The version in the Windows directory gets erased by // the WININIT program. int len; char buff[2 * _MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char name[_MAX_FNAME]; if( argc > 1 && stricmp( argv[ 1 ], "-u" ) == 0 ) { // copy setup program to unsetup.exe in system directory GetWindowsDirectory( buff, _MAX_PATH ); strcat( buff, "\\UnSetup.exe" ); if( DoCopyFile( argv[0], buff, FALSE ) == CFE_NOERROR ) { // add entry to wininit.ini to erase unsetup.exe WritePrivateProfileString( "rename", "NUL", buff, "wininit.ini" ); // setup.inf should be in same directory as setup.exe len = strlen( buff ); buff[len] = ' '; buff[len + 1] = '\"'; _splitpath( argv[0], drive, dir, name, NULL ); _makepath( &buff[len + 2], drive, dir, name, "inf" ); strcat( buff, "\"" ); // execute unsetup WinExec( buff, SW_SHOW ); return( TRUE ); } } return( FALSE ); }
CMissionManager::InstallResult CMissionManager::InstallMod(const idStr& name) { CModInfoPtr info = GetModInfo(name); // result is always non-NULL const idStr& modName = info->modName; // Ensure that the target folder exists fs::path targetFolder = g_Global.GetModPath(modName.c_str()); if (!fs::create_directory(targetFolder)) { // Directory exists, not a problem, but log this DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("FM targetFolder already exists: %s\r", targetFolder.string().c_str()); } #if 0 // Path to the darkmod directory fs::path darkmodPath = GetDarkmodPath(); // greebo: We don't copy PK4s around anymore, they remain in the fms/ subfolders // Copy all PK4s from the FM folder (and all subdirectories) idFileList* pk4Files = fileSystem->ListFilesTree(info->pathToFMPackage, ".pk4", false); for (int i = 0; i < pk4Files->GetNumFiles(); ++i) { // Source file (full OS path) fs::path pk4fileOsPath = GetDarkmodPath() / pk4Files->GetFile(i); // Target location fs::path targetFile = targetFolder / pk4fileOsPath.leaf(); DM_LOG(LC_MAINMENU, LT_DEBUG)LOGSTRING("Copying file %s to %s\r", pk4fileOsPath.string().c_str(), targetFile.string().c_str()); // Use boost::filesystem instead of id's (comments state that copying large files can be problematic) //fileeSystem->CopyFile(pk4fileOsPath, targetFile.string().c_str()); // Copy the PK4 file and make sure any target file with the same name is removed beforehand if (!DoCopyFile(pk4fileOsPath, targetFile, true)) { // Failed copying return COPY_FAILURE; } } fileSystem->FreeFileList(pk4Files); #endif // Save the name to currentfm.txt WriteCurrentFmFile(modName); // taaaki: now that fms are loaded directly from <basepath>/darkmod/fms/ // we don't need to copy config files around (i.e. just use the // one in <basepath>/darkmod/ (same with config.spec) return INSTALLED_OK; }
int TclpCopyFile( CONST char *src, /* Pathname of file to be copied (UTF-8). */ CONST char *dst) /* Pathname of file to copy to (UTF-8). */ { int result; Tcl_DString srcString, dstString; Tcl_WinUtfToTChar(src, -1, &srcString); Tcl_WinUtfToTChar(dst, -1, &dstString); result = DoCopyFile(&srcString, &dstString); Tcl_DStringFree(&srcString); Tcl_DStringFree(&dstString); return result; }
static int TraversalCopy( Tcl_DString *srcPtr, /* Source pathname to copy. */ Tcl_DString *dstPtr, /* Destination pathname of copy. */ int type, /* Reason for call - see TraverseWinTree() */ Tcl_DString *errorPtr) /* If non-NULL, initialized DString filled * with UTF-8 name of file causing error. */ { TCHAR *nativeDst, *nativeSrc; DWORD attr; switch (type) { case DOTREE_F: { if (DoCopyFile(srcPtr, dstPtr) == TCL_OK) { return TCL_OK; } break; } case DOTREE_PRED: { if (DoCreateDirectory(dstPtr) == TCL_OK) { nativeSrc = (TCHAR *) Tcl_DStringValue(srcPtr); nativeDst = (TCHAR *) Tcl_DStringValue(dstPtr); attr = (*tclWinProcs->getFileAttributesProc)(nativeSrc); if ((*tclWinProcs->setFileAttributesProc)(nativeDst, attr) != FALSE) { return TCL_OK; } TclWinConvertError(GetLastError()); } break; } case DOTREE_POSTD: { return TCL_OK; } } /* * There shouldn't be a problem with src, because we already * checked it to get here. */ if (errorPtr != NULL) { nativeDst = (TCHAR *) Tcl_DStringValue(dstPtr); Tcl_WinTCharToUtf(nativeDst, -1, errorPtr); } return TCL_ERROR; }
unsigned long CCopyThread::Process(void* parameter) { SetThreadPriority(hThread,THREAD_PRIORITY_HIGHEST); Stage = CS_CALCSIZE; //DebugMsg("Calc size of %s",Source.c_str()); //DebugMsg("Last Char : %s",Source.substr(Source.size()-1,1).c_str()); if (Source.substr(Source.size()-1,1) == "\\") { //DebugMsg("Scanning Dir"); Total_Size.QuadPart = File_Size.QuadPart = 0; Total_Prog.QuadPart = File_Prog.QuadPart = 0; Total_FilesCopied = Total_Files = 0; GetDirStat(Source); } else { //DebugMsg("Scanning File"); DWORD high = 0; DWORD size = 0; aGetFileSize(Source,size,high); Total_Size.QuadPart = File_Size.QuadPart = size; Total_Prog.QuadPart = File_Prog.QuadPart = 0; Total_Files = 1; Total_FilesCopied = 0; } //DebugMsg("Processing a total of %d bytes, %d files",Total_Size,Total_Files); Stage = CS_COPYING; if (Source.substr(Source.size()-1,1) == "\\") { //DebugMsg("Processing Dir"); if (Dest.substr(Dest.size()-1,1) == "\\") { if (!FileExistsA(Dest)) _mkdir(Dest.c_str()); DoCopyDir(Source,Dest); if (Action == CDA_COPYDVD) DoCopyFile(Source + "default.xex",Dest + "default.xex"); } } else { //DebugMsg("Processing File"); // dest is a directory, do get filename from source and copy to that if (Dest.substr(Dest.size()-1,1) == "\\") { Dest += Source.substr(Source.rfind("\\")+1); } if (Action == CDA_DELETE) { _unlink(Source.c_str()); Total_FilesCopied++; } else { DoCopyFile(Source,Dest); } } // fake file done prog bar, looks better File_Size.QuadPart = 1024; File_Prog.QuadPart = 1024; if (Cancel) { Stage = CS_CANCEL; } else { Stage = CS_DONE; } XamSetDvdSpindleSpeed(DVD_SPEED_2X); return 0; }
void CCopyThread::DoCopyDir(string source, string dest) { WIN32_FIND_DATA findFileData; memset(&findFileData,0,sizeof(WIN32_FIND_DATA)); string searchcmd = source + "\\*.*"; searchcmd = str_replaceallA(searchcmd,"\\\\","\\"); HANDLE hFind = FindFirstFile(searchcmd.c_str(), &findFileData); if (hFind == INVALID_HANDLE_VALUE) { if (Action == CDA_MOVEFILES || Action == CDA_SDMODE || Action == CDA_DELETE) { source = str_replaceallA(source,"\\\\","\\"); //DebugMsg("rmdir %s",source.c_str()); int res = _rmdir(source.c_str()); if (res != 0) DebugMsg("CopyThread","rmdir error %d - %d",res,GetLastError()); } return; } do { if (Cancel) { FindClose(hFind); return; } if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { string newdest = dest + "\\" + findFileData.cFileName; newdest = str_replaceallA(newdest,"\\\\","\\"); if (Action != CDA_DELETE) { //DebugMsg("Make dir %s",newdest.c_str()); /*if(Action == CDA_COPYDVD && newdest.find("$SystemUpdate") ) { continue; }*/ _mkdir(newdest.c_str()); } DoCopyDir(source + "\\" + findFileData.cFileName,newdest); } else { if (Action == CDA_COPYDVD && make_lowercaseA(string(findFileData.cFileName)) == "default.xex") { continue; } if (Action == CDA_DELETE) { string filename = source + "\\" + findFileData.cFileName; filename = str_replaceallA(filename,"\\\\","\\"); //DebugMsg("unlink %s",filename.c_str()); _unlink(filename.c_str()); Total_FilesCopied++; } else { DoCopyFile(source + "\\" + findFileData.cFileName,dest + "\\" + findFileData.cFileName); } } } while (FindNextFile(hFind, &findFileData)); FindClose(hFind); if (Action == CDA_MOVEFILES || Action == CDA_SDMODE || Action == CDA_DELETE) { source = str_replaceallA(source,"\\\\","\\"); //DebugMsg("rmdir %s",source.c_str()); int res = _rmdir(source.c_str()); if (res != 0) DebugMsg("CopyThread","rmdir error %d - %d",res,GetLastError()); } }