2007-11-04 03:51:54 +00:00
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2017-08-30 11:07:42 +00:00
|
|
|
#if defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __APPLE__ )
|
2007-11-04 03:51:54 +00:00
|
|
|
#include <dirent.h>
|
|
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
#include "pakstuff.h"
|
|
|
|
#include "unzip.h"
|
|
|
|
#include "str.h"
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
int m_nPAKIndex;
|
2007-11-04 03:51:54 +00:00
|
|
|
FILE* pakfile[16];
|
2012-03-17 20:01:54 +00:00
|
|
|
struct PACKDirectory pakdir;
|
|
|
|
PACKDirPtr pakdirptr = &pakdir;
|
|
|
|
UInt16 dirsize;
|
|
|
|
bool pakopen = false;
|
|
|
|
int f_type;
|
|
|
|
DIRECTORY *paktextures = NULL;
|
|
|
|
UInt32 PakColormapOffset;
|
|
|
|
UInt32 PakColormapSize;
|
|
|
|
DIRECTORY *dirhead = NULL;
|
|
|
|
bool g_bPK3 = false;
|
|
|
|
char g_strBasePaths[16][1024];
|
|
|
|
int g_numBasePaths = 0;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
struct PK3FileInfo
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
unzFile m_zFile;
|
|
|
|
char *m_pName;
|
|
|
|
unz_s m_zInfo;
|
|
|
|
long m_lSize;
|
|
|
|
~PK3FileInfo(){
|
|
|
|
delete []m_pName;
|
|
|
|
}
|
|
|
|
bool operator ==( const PK3FileInfo& rhs ) const { return strcmp( m_pName, rhs.m_pName ) == 0; }
|
2007-11-04 03:51:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define __PATHSEPERATOR '/'
|
|
|
|
|
|
|
|
//#define LOG_PAKFAIL
|
|
|
|
|
|
|
|
#ifdef LOG_PAKFAIL
|
|
|
|
|
2017-08-30 11:07:42 +00:00
|
|
|
#if defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __APPLE__ )
|
2007-11-04 03:51:54 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
class LogFile
|
|
|
|
{
|
|
|
|
public:
|
2012-03-17 20:01:54 +00:00
|
|
|
FILE *m_pFile;
|
|
|
|
LogFile( const char* pName ){
|
2017-08-30 11:07:42 +00:00
|
|
|
#if defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __APPLE__ )
|
2012-03-17 20:01:54 +00:00
|
|
|
// leo: use ~/.q3a/radiant/paklog instead of /tmp/paklog.txt
|
|
|
|
char *home = NULL;
|
|
|
|
|
|
|
|
home = getenv( "HOME" );
|
|
|
|
if ( home == NULL ) {
|
|
|
|
uid_t id = getuid();
|
|
|
|
struct passwd *pwd;
|
|
|
|
|
|
|
|
setpwent();
|
|
|
|
while ( ( pwd = getpwent() ) != NULL )
|
|
|
|
if ( pwd->pw_uid == id ) {
|
|
|
|
home = pwd->pw_dir;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
endpwent();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( home != NULL ) {
|
|
|
|
char path[PATH_MAX];
|
|
|
|
strcpy( path, home );
|
|
|
|
if ( path[strlen( path ) - 1] != '/' ) {
|
|
|
|
strcat( path, "/" );
|
|
|
|
}
|
|
|
|
strcat( path, ".q3a/radiant/paklog" );
|
|
|
|
m_pFile = fopen( path, "w" );
|
|
|
|
}
|
|
|
|
else
|
2007-11-04 03:51:54 +00:00
|
|
|
#endif
|
2012-03-17 20:01:54 +00:00
|
|
|
m_pFile = fopen( pName, "w" );
|
|
|
|
}
|
|
|
|
~LogFile(){
|
|
|
|
if ( m_pFile ) {
|
|
|
|
fclose( m_pFile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void Log( const char *pFormat, ... ){
|
|
|
|
if ( m_pFile == NULL ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
va_list arg_ptr;
|
|
|
|
va_start( arg_ptr, pFormat );
|
|
|
|
fprintf( m_pFile, pFormat, arg_ptr );
|
|
|
|
va_end( arg_ptr );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
};
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
LogFile g_LogFile( "/tmp/paklog.txt" );
|
2007-11-04 03:51:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
template <class T> class StrPtr : public Str
|
|
|
|
{
|
|
|
|
protected:
|
2012-03-17 20:01:54 +00:00
|
|
|
T* m_pPtr;
|
|
|
|
StrPtr(){
|
|
|
|
m_pPtr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
StrPtr( const char *pStr, T *p ) : Str( pStr ){
|
|
|
|
m_pPtr = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
T* Ptr(){
|
|
|
|
return m_pPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
T& Ref(){
|
|
|
|
return *m_pPtr;
|
|
|
|
}
|
|
|
|
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
// PtrList
|
|
|
|
// a list of ptrs
|
2012-03-17 20:01:54 +00:00
|
|
|
//
|
2007-11-04 03:51:54 +00:00
|
|
|
template <class T> class PtrList
|
|
|
|
{
|
|
|
|
protected:
|
2012-03-17 20:01:54 +00:00
|
|
|
T *m_pPtr;
|
|
|
|
PtrList *m_pNext;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
PtrList(){
|
|
|
|
m_pNext = NULL;
|
|
|
|
m_pPtr = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
PtrList( T *ip ){
|
|
|
|
m_pNext = NULL;
|
|
|
|
m_pPtr = ip;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~PtrList(){
|
|
|
|
delete m_pPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
PtrList* Next(){
|
|
|
|
return m_pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Add( T *ip ){
|
|
|
|
PtrList *pl = this;
|
|
|
|
while ( pl && pl->m_pNext )
|
|
|
|
{
|
|
|
|
pl = pl->Next();
|
|
|
|
}
|
|
|
|
pl->m_pNext = new PtrList( ip );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Remove(){
|
|
|
|
PtrList *p = m_pNext;
|
|
|
|
if ( p ) {
|
|
|
|
while ( p->m_pNext != this && p->m_pNext != NULL )
|
|
|
|
{
|
|
|
|
p = p->m_pNext;
|
|
|
|
}
|
|
|
|
if ( p->m_pNext == this ) {
|
|
|
|
p->m_pNext = m_pNext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual PtrList* Find( T *ip ){
|
|
|
|
PtrList *p = m_pNext;
|
|
|
|
while ( p )
|
|
|
|
{
|
|
|
|
if ( *p->m_pPtr == *ip ) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
p = p->m_pNext;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove vp from the list
|
|
|
|
void Remove( T *ip ){
|
|
|
|
PtrList *p = Find( ip );
|
|
|
|
if ( p ) {
|
|
|
|
p->Remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
T* Ptr(){
|
|
|
|
return m_pPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
T& Ref(){
|
|
|
|
return *m_pPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveAll(){
|
|
|
|
PtrList *p = m_pNext;
|
|
|
|
while ( p )
|
|
|
|
{
|
|
|
|
PtrList *p2 = p;
|
|
|
|
p = p->m_pNext;
|
|
|
|
delete p2;
|
|
|
|
}
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef PtrList<unzFile> ZFileList;
|
|
|
|
typedef PtrList<Str> StrList;
|
|
|
|
typedef PtrList<PK3FileInfo> PK3List;
|
|
|
|
|
|
|
|
|
|
|
|
StrList g_PK3TexturePaths;
|
|
|
|
PK3List g_PK3Files;
|
|
|
|
ZFileList g_zFiles;
|
|
|
|
#define WORK_LEN 1024
|
|
|
|
#define TEXTURE_PATH "textures"
|
|
|
|
#define PATH_SEPERATORS "/\\:\0"
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
char* __StrDup(char* pStr)
|
|
|
|
{
|
|
|
|
if (pStr == NULL)
|
2007-11-04 03:51:54 +00:00
|
|
|
pStr = "";
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
return strcpy(new char[strlen(pStr)+1], pStr);
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char* __StrDup(const char* pStr)
|
|
|
|
{
|
|
|
|
if (pStr == NULL)
|
2007-11-04 03:51:54 +00:00
|
|
|
pStr = "";
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
return strcpy(new char[strlen(pStr)+1], pStr);
|
|
|
|
}
|
|
|
|
*/
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
#define MEM_BLOCKSIZE 4096
|
2012-03-17 20:01:54 +00:00
|
|
|
void* __qblockmalloc( size_t nSize ){
|
2007-11-04 03:51:54 +00:00
|
|
|
void *b;
|
2012-03-17 20:01:54 +00:00
|
|
|
// round up to threshold
|
|
|
|
int nAllocSize = nSize % MEM_BLOCKSIZE;
|
|
|
|
if ( nAllocSize > 0 ) {
|
|
|
|
nSize += MEM_BLOCKSIZE - nAllocSize;
|
|
|
|
}
|
|
|
|
b = malloc( nSize + 1 );
|
|
|
|
memset( b, 0, nSize );
|
2007-11-04 03:51:54 +00:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void* __qmalloc( size_t nSize ){
|
2007-11-04 03:51:54 +00:00
|
|
|
void *b;
|
2012-03-17 20:01:54 +00:00
|
|
|
b = malloc( nSize + 1 );
|
|
|
|
memset( b, 0, nSize );
|
2007-11-04 03:51:54 +00:00
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
====================
|
|
|
|
Extract file parts
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
void __ExtractFilePath( const char *path, char *dest ){
|
2007-11-04 03:51:54 +00:00
|
|
|
const char *src;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
src = path + strlen( path ) - 1;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// back up until a \ or the start
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( src != path && *( src - 1 ) != __PATHSEPERATOR )
|
2007-11-04 03:51:54 +00:00
|
|
|
src--;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
memcpy( dest, path, src - path );
|
|
|
|
dest[src - path] = 0;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void __ExtractFileName( const char *path, char *dest ){
|
2007-11-04 03:51:54 +00:00
|
|
|
const char *src;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
src = path + strlen( path ) - 1;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// back up until a \ or the start
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( src != path && *( src - 1 ) != '/'
|
|
|
|
&& *( src - 1 ) != '\\' )
|
2007-11-04 03:51:54 +00:00
|
|
|
src--;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( *src )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
|
|
|
*dest = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void __ExtractFileBase( const char *path, char *dest ){
|
2007-11-04 03:51:54 +00:00
|
|
|
const char *src;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
src = path + strlen( path ) - 1;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// back up until a \ or the start
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( src != path && *( src - 1 ) != '/'
|
|
|
|
&& *( src - 1 ) != '\\' )
|
2007-11-04 03:51:54 +00:00
|
|
|
src--;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( *src && *src != '.' )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
|
|
|
*dest = 0;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void __ExtractFileExtension( const char *path, char *dest ){
|
2007-11-04 03:51:54 +00:00
|
|
|
const char *src;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
src = path + strlen( path ) - 1;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// back up until a . or the start
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( src != path && *( src - 1 ) != '.' )
|
2007-11-04 03:51:54 +00:00
|
|
|
src--;
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( src == path ) {
|
|
|
|
*dest = 0; // no extension
|
2007-11-04 03:51:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( dest,src );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void __ConvertDOSToUnixName( char *dst, const char *src ){
|
2007-11-04 03:51:54 +00:00
|
|
|
while ( *src )
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( *src == '\\' ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
*dst = '/';
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:51:54 +00:00
|
|
|
*dst = *src;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
dst++; src++;
|
|
|
|
}
|
|
|
|
*dst = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void AddSlash( Str& str ){
|
|
|
|
int nLen = str.GetLength();
|
|
|
|
if ( nLen > 0 ) {
|
|
|
|
if ( str[nLen - 1] != '\\' && str[nLen - 1] != '/' ) {
|
|
|
|
str += '\\';
|
|
|
|
}
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
static void FindReplace( Str& strContents, const char* pTag, const char* pValue ){
|
|
|
|
if ( strcmp( pTag, pValue ) == 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for ( int nPos = strContents.Find( pTag ); nPos >= 0; nPos = strContents.Find( pTag ) )
|
|
|
|
{
|
|
|
|
int nRightLen = strContents.GetLength() - strlen( pTag ) - nPos;
|
|
|
|
Str strLeft( strContents.Left( nPos ) );
|
|
|
|
Str strRight( strContents.Right( nRightLen ) );
|
|
|
|
strLeft += pValue;
|
|
|
|
strLeft += strRight;
|
|
|
|
strContents = strLeft;
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ClearFileList( FILELIST **list ){
|
|
|
|
FILELIST *temp;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( *list )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
temp = *list;
|
2012-03-17 20:01:54 +00:00
|
|
|
*list = ( *list )->next;
|
|
|
|
free( temp );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ClearDirList( DIRLIST **list ){
|
|
|
|
DIRLIST *temp;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( *list )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
temp = *list;
|
2012-03-17 20:01:54 +00:00
|
|
|
*list = ( *list )->next;
|
|
|
|
free( temp );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DIRECTORY *FindPakDir( DIRECTORY *dir, char *name ){
|
|
|
|
DIRECTORY *currentPtr;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( currentPtr = dir; currentPtr; currentPtr = currentPtr->next )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !stricmp( name, currentPtr->name ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return currentPtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LoadPK3FileList
|
|
|
|
// ---------------
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
// This gets passed a file mask which we want to remove as
|
2007-11-04 03:51:54 +00:00
|
|
|
// we are only interested in the directory name and any given
|
|
|
|
// extension. Only handles explicit filenames or *.something
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
bool LoadPK3FileList( FILELIST **filelist, const char *pattern ){
|
|
|
|
char cSearch[WORK_LEN];
|
2007-11-04 03:51:54 +00:00
|
|
|
__ConvertDOSToUnixName( cSearch, pattern );
|
2012-03-17 20:01:54 +00:00
|
|
|
char cPath[WORK_LEN];
|
|
|
|
char cExt[WORK_LEN];
|
|
|
|
char cFile[WORK_LEN];
|
|
|
|
char cWork[WORK_LEN];
|
|
|
|
__ExtractFilePath( pattern, cPath );
|
|
|
|
__ExtractFileName( pattern, cFile );
|
|
|
|
__ExtractFileExtension( pattern, cExt );
|
|
|
|
const char *pCompare = ( strnicmp( cFile, "*.", 2 ) == 0 ) ? cExt : cFile;
|
|
|
|
|
|
|
|
PK3List *p = g_PK3Files.Next();
|
|
|
|
while ( p != NULL )
|
|
|
|
{
|
|
|
|
// qualify the path
|
|
|
|
PK3FileInfo *pKey = p->Ptr();
|
|
|
|
if ( strstr( pKey->m_pName, cPath ) && strstr( pKey->m_pName, pCompare ) ) {
|
|
|
|
__ExtractFileName( pKey->m_pName, cWork );
|
|
|
|
AddToFileListAlphabetized( filelist, cWork, 0, 0, false );
|
|
|
|
}
|
|
|
|
p = p->Next();
|
|
|
|
}
|
|
|
|
return ( *filelist ) != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetPackFileList( FILELIST **filelist, char *pattern ){
|
|
|
|
char *str1, *str2;
|
|
|
|
int i;
|
|
|
|
DIRECTORY *dummy = paktextures;
|
|
|
|
FILELIST *temp;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !pakopen ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return false;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_bPK3 ) {
|
|
|
|
return LoadPK3FileList( filelist, pattern );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
str1 = pattern;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; pattern[i] != '\0'; i++ )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( pattern[i] == '\\' ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
pattern[i] = '/';
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( strchr( str1, '/' ) )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
str2 = strchr( str1, '/' );
|
2007-11-04 03:51:54 +00:00
|
|
|
*str2++ = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
dummy = FindPakDir( dummy, str1 );
|
|
|
|
if ( !dummy ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return false;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
str1 = str2;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( temp = dummy->files; temp; temp = temp->next )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
AddToFileListAlphabetized( filelist, temp->filename, temp->offset, 0, false );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
bool GetPackTextureDirs( DIRLIST **dirlist ){
|
|
|
|
UInt16 i;
|
|
|
|
char buf[57];
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !pakopen ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return 1;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_bPK3 ) {
|
|
|
|
StrList *pl = g_PK3TexturePaths.Next();
|
|
|
|
while ( pl != NULL )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
AddToDirListAlphabetized( dirlist, pl->Ref(), 0 );
|
|
|
|
pl = pl->Next();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( i = 0; i < dirsize; i++ )
|
|
|
|
{
|
|
|
|
if ( !strnicmp( pakdirptr[i].name, "textures", 8 ) ) {
|
|
|
|
strncpy( buf, &( pakdirptr[i].name[9] ), 46 );
|
|
|
|
if ( strchr( buf, '\\' ) ) {
|
|
|
|
*strchr( buf, '\\' ) = '\0';
|
|
|
|
}
|
|
|
|
else if ( strchr( buf, '/' ) ) {
|
|
|
|
*strchr( buf, '/' ) = '\0';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
buf[56] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( strchr( buf, '.' ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
AddToDirListAlphabetized( dirlist, buf, 0 );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
bool AddToDirListAlphabetized( DIRLIST **list, char *dirname, int from ){
|
|
|
|
DIRLIST *currentPtr, *previousPtr, *newPtr;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strlwr( dirname );
|
|
|
|
for ( currentPtr = *list; currentPtr; currentPtr = currentPtr->next )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !stricmp( dirname, currentPtr->dirname ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
previousPtr = NULL;
|
|
|
|
currentPtr = *list;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( newPtr = (DIRLIST *)__qmalloc( sizeof( DIRLIST ) ) ) == NULL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return false;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( newPtr->dirname, dirname );
|
2007-11-04 03:51:54 +00:00
|
|
|
newPtr->from = from;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( currentPtr != NULL && stricmp( dirname, currentPtr->dirname ) > 0 )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
previousPtr = currentPtr;
|
|
|
|
currentPtr = currentPtr->next;
|
|
|
|
} //End while
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( previousPtr == NULL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newPtr->next = *list;
|
|
|
|
*list = newPtr;
|
|
|
|
} //End if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
previousPtr->next = newPtr;
|
|
|
|
newPtr->next = currentPtr;
|
|
|
|
} //End else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
bool AddToFileListAlphabetized( FILELIST **list, char *filename, UInt32 offset, UInt32 size, bool dirs ){
|
|
|
|
FILELIST *currentPtr, *previousPtr, *newPtr;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( currentPtr = *list; currentPtr; currentPtr = currentPtr->next )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !stricmp( filename, currentPtr->filename ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
previousPtr = NULL;
|
|
|
|
currentPtr = *list;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( newPtr = (FILELIST *)__qmalloc( sizeof( FILELIST ) ) ) == NULL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return false;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( newPtr->filename, filename );
|
2007-11-04 03:51:54 +00:00
|
|
|
newPtr->offset = offset;
|
|
|
|
newPtr->size = size;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( currentPtr != NULL && stricmp( filename, currentPtr->filename ) > 0 )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
previousPtr = currentPtr;
|
|
|
|
currentPtr = currentPtr->next;
|
|
|
|
} //End while
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( previousPtr == NULL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newPtr->next = *list;
|
|
|
|
*list = newPtr;
|
|
|
|
} //End if
|
|
|
|
else
|
|
|
|
{
|
|
|
|
previousPtr->next = newPtr;
|
|
|
|
newPtr->next = currentPtr;
|
|
|
|
} //End else
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
int PakLoadAnyFile( const char *filename, void **bufferptr ){
|
|
|
|
char cWork[WORK_LEN];
|
|
|
|
if ( g_bPK3 ) {
|
|
|
|
// leo: hack to be able to use pak files from multiple directories
|
|
|
|
for ( int i = 0; i < g_numBasePaths; i++ )
|
|
|
|
{
|
|
|
|
PK3FileInfo *pInfo;
|
|
|
|
Str strKey;
|
|
|
|
// need to lookup the file without the base/texture path on it
|
|
|
|
Str strBase( g_strBasePaths[i] );
|
|
|
|
AddSlash( strBase );
|
|
|
|
__ConvertDOSToUnixName( cWork, strBase );
|
|
|
|
Str strFile( filename );
|
|
|
|
__ConvertDOSToUnixName( strFile, strFile );
|
|
|
|
strFile.MakeLower();
|
|
|
|
strlwr( cWork );
|
|
|
|
FindReplace( strFile, cWork, "" );
|
|
|
|
|
|
|
|
PK3FileInfo infoFind;
|
|
|
|
infoFind.m_pName = __StrDup( strFile.GetBuffer() );
|
|
|
|
PK3List *pList = g_PK3Files.Find( &infoFind );
|
|
|
|
if ( pList ) {
|
|
|
|
pInfo = pList->Ptr();
|
|
|
|
memcpy( pInfo->m_zFile, &pInfo->m_zInfo, sizeof( unz_s ) );
|
|
|
|
if ( unzOpenCurrentFile( pInfo->m_zFile ) == UNZ_OK ) {
|
|
|
|
void *buffer = __qblockmalloc( pInfo->m_lSize + 1 );
|
|
|
|
int n = unzReadCurrentFile( pInfo->m_zFile, buffer, pInfo->m_lSize );
|
|
|
|
*bufferptr = buffer;
|
|
|
|
unzCloseCurrentFile( pInfo->m_zFile );
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
|
|
|
#ifdef LOG_PAKFAIL
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( cWork, "PAK failed on %s\n", filename );
|
|
|
|
g_LogFile.Log( cWork );
|
2007-11-04 03:51:54 +00:00
|
|
|
#endif
|
2012-03-17 20:01:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( int i = 0; i < dirsize; i++ )
|
|
|
|
{
|
|
|
|
if ( !stricmp( filename, pakdirptr[i].name ) ) {
|
|
|
|
if ( fseek( pakfile[m_nPAKIndex], pakdirptr[i].offset, SEEK_SET ) >= 0 ) {
|
|
|
|
void *buffer = __qmalloc( pakdirptr[i].size + 1 );
|
|
|
|
( (char *)buffer )[pakdirptr[i].size] = 0;
|
|
|
|
if ( fread( buffer, 1, pakdirptr[i].size, pakfile[m_nPAKIndex] ) == pakdirptr[i].size ) {
|
|
|
|
*bufferptr = buffer;
|
|
|
|
return pakdirptr[i].size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
#ifdef LOG_PAKFAIL
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( cWork, "PAK failed on %s\n", filename );
|
|
|
|
g_LogFile.Log( cWork );
|
2007-11-04 03:51:54 +00:00
|
|
|
#endif
|
2012-03-17 20:01:54 +00:00
|
|
|
return -1;
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
DIRECTORY *AddPakDir( DIRECTORY **dir, char *name ){
|
|
|
|
DIRECTORY *currentPtr, *previousPtr, *newPtr;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( currentPtr = *dir; currentPtr; currentPtr = currentPtr->next )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !stricmp( name, currentPtr->name ) ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return currentPtr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
previousPtr = NULL;
|
|
|
|
currentPtr = *dir;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( ( newPtr = (DIRECTORY *)__qmalloc( sizeof( DIRECTORY ) ) ) == NULL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
return NULL;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( newPtr->name, name );
|
2007-11-04 03:51:54 +00:00
|
|
|
newPtr->files = NULL;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( currentPtr != NULL && stricmp( name, currentPtr->name ) > 0 )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
|
|
|
previousPtr = currentPtr;
|
|
|
|
currentPtr = currentPtr->next;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( previousPtr == NULL ) {
|
2007-11-04 03:51:54 +00:00
|
|
|
newPtr->next = *dir;
|
|
|
|
*dir = newPtr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
previousPtr->next = newPtr;
|
|
|
|
newPtr->next = currentPtr;
|
|
|
|
}
|
|
|
|
return newPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// OpenPK3
|
|
|
|
// -------
|
|
|
|
// Opens a PK3 ( or zip ) file and creates a list of filenames
|
|
|
|
// and zip info structures
|
2012-03-17 20:01:54 +00:00
|
|
|
//
|
|
|
|
bool OpenPK3( const char *filename ){
|
|
|
|
char cFilename[WORK_LEN];
|
|
|
|
char cName[WORK_LEN];
|
|
|
|
char cWork[WORK_LEN];
|
|
|
|
unz_file_info zInfo;
|
|
|
|
unzFile *zFile = new unzFile( unzOpen( filename ) );
|
|
|
|
g_zFiles.Add( zFile );
|
|
|
|
if ( zFile != NULL ) {
|
|
|
|
int nStatus = unzGoToFirstFile( *zFile );
|
|
|
|
while ( nStatus == UNZ_OK )
|
|
|
|
{
|
|
|
|
cFilename[0] = '\0';
|
|
|
|
unzGetCurrentFileInfo( *zFile, &zInfo, cFilename, WORK_LEN, NULL, 0, NULL, 0 );
|
|
|
|
strlwr( cFilename );
|
|
|
|
__ConvertDOSToUnixName( cWork, cFilename );
|
|
|
|
if ( strstr( cWork, "." ) != NULL ) {
|
|
|
|
PK3FileInfo *pInfo = new PK3FileInfo();
|
|
|
|
pInfo->m_pName = __StrDup( cWork );
|
|
|
|
memcpy( &pInfo->m_zInfo, (unz_s*)*zFile, sizeof( unz_s ) );
|
|
|
|
pInfo->m_lSize = zInfo.uncompressed_size;
|
|
|
|
pInfo->m_zFile = *zFile;
|
|
|
|
g_PK3Files.Add( pInfo );
|
|
|
|
}
|
|
|
|
char *p = strstr( cFilename, TEXTURE_PATH );
|
|
|
|
if ( p != NULL ) {
|
|
|
|
// FIXME: path differences per os ?
|
|
|
|
// catch solo directory entry
|
|
|
|
if ( strlen( p ) > strlen( TEXTURE_PATH ) + 1 ) {
|
|
|
|
// skip textures + path seperator
|
|
|
|
p += strlen( TEXTURE_PATH ) + 1;
|
|
|
|
int nEnd = strcspn( p, PATH_SEPERATORS );
|
|
|
|
strncpy( cName, p, nEnd );
|
|
|
|
cName[nEnd] = '\0';
|
|
|
|
|
|
|
|
bool bFound = false;
|
|
|
|
StrList *pl = g_PK3TexturePaths.Next();
|
|
|
|
while ( pl != NULL )
|
|
|
|
{
|
|
|
|
if ( strcmpi( pl->Ref(), cName ) == 0 ) {
|
|
|
|
// already have this, continue
|
|
|
|
bFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pl = pl->Next();
|
|
|
|
}
|
|
|
|
if ( !bFound ) {
|
|
|
|
g_PK3TexturePaths.Add( new Str( cName ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nStatus = unzGoToNextFile( *zFile );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ( zFile != NULL );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void closePK3( unzFile zf ){
|
|
|
|
unzClose( zf );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void OpenPakFile( const char *filename ){
|
|
|
|
if ( !pakopen ) {
|
|
|
|
paktextures = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pakopen = g_bPK3 = OpenPK3( filename );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ClearPaKDir( DIRECTORY **dir ){
|
|
|
|
DIRECTORY *d1 = *dir, *d2;
|
2007-11-04 03:51:54 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( d1 )
|
2007-11-04 03:51:54 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
ClearFileList( &( d1->files ) );
|
2007-11-04 03:51:54 +00:00
|
|
|
d2 = d1;
|
|
|
|
d1 = d1->next;
|
2012-03-17 20:01:54 +00:00
|
|
|
free( d2 );
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void CleanUpPakDirs(){
|
|
|
|
ClearPaKDir( &paktextures );
|
|
|
|
paktextures = NULL;
|
|
|
|
dirhead = NULL;
|
|
|
|
g_PK3TexturePaths.RemoveAll();
|
|
|
|
g_PK3Files.RemoveAll();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ClosePakFile( void ){
|
|
|
|
if ( pakopen ) {
|
|
|
|
if ( g_bPK3 ) {
|
|
|
|
ZFileList *p = g_zFiles.Next();
|
|
|
|
while ( p != NULL )
|
|
|
|
{
|
|
|
|
unzFile uz = p->Ref();
|
|
|
|
closePK3( uz );
|
|
|
|
p = p->Next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fclose( pakfile[m_nPAKIndex] );
|
|
|
|
}
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
pakopen = false;
|
2012-03-17 20:01:54 +00:00
|
|
|
CleanUpPakDirs();
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void WINAPI InitPakFile( const char * pBasePath, const char *pName ){
|
|
|
|
if ( g_numBasePaths == 0 ) {
|
|
|
|
m_nPAKIndex = 0;
|
|
|
|
pakopen = false;
|
|
|
|
paktextures = NULL;
|
|
|
|
}
|
|
|
|
strcpy( g_strBasePaths[g_numBasePaths], pBasePath );
|
|
|
|
g_numBasePaths++;
|
|
|
|
|
|
|
|
if ( pName == NULL ) {
|
|
|
|
//++timo FIXME: use some kind of compatibility lib here!
|
2017-08-30 11:07:42 +00:00
|
|
|
#if defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __APPLE__ )
|
2012-03-17 20:01:54 +00:00
|
|
|
char cWork[WORK_LEN];
|
|
|
|
struct dirent *dirlist;
|
|
|
|
DIR *dir;
|
|
|
|
|
|
|
|
dir = opendir( pBasePath );
|
|
|
|
if ( dir != NULL ) {
|
|
|
|
while ( ( dirlist = readdir( dir ) ) != NULL )
|
|
|
|
{
|
|
|
|
if ( strstr( dirlist->d_name, ".pk3" ) == NULL ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sprintf( cWork, "%s/%s", pBasePath, dirlist->d_name );
|
|
|
|
OpenPakFile( cWork );
|
|
|
|
}
|
|
|
|
closedir( dir );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
2012-03-17 20:01:54 +00:00
|
|
|
char cWork[WORK_LEN];
|
|
|
|
Str strPath( pBasePath );
|
|
|
|
AddSlash( strPath );
|
|
|
|
strPath += "*.pk3";
|
|
|
|
bool bGo = true;
|
|
|
|
struct _finddata_t fileinfo;
|
|
|
|
int handle = _findfirst( strPath, &fileinfo );
|
|
|
|
if ( handle != -1 ) {
|
|
|
|
do
|
|
|
|
{
|
|
|
|
sprintf( cWork, "%s/%s", pBasePath, fileinfo.name );
|
|
|
|
OpenPakFile( cWork );
|
|
|
|
} while ( _findnext( handle, &fileinfo ) != -1 );
|
|
|
|
_findclose( handle );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
#endif
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OpenPakFile( pName );
|
|
|
|
}
|
2007-11-04 03:51:54 +00:00
|
|
|
}
|