2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 Camera plugin for GtkRadiant
24 Copyright (C) 2002 Splash Damage Ltd.
29 void Sys_ERROR( char* text, ... ){
33 va_start( argptr,text );
34 vsprintf( buf, text,argptr );
37 Sys_Printf( "Camera::ERROR->%s", buf );
40 char* UnixToDosPath( char* path ){
44 for ( char* p = path; *p; p++ )
54 void ExtractFilePath( const char *path, char *dest ){
57 src = path + strlen( path ) - 1;
60 // back up until a \ or the start
62 while ( src != path && *( src - 1 ) != '/' && *( src - 1 ) != '\\' )
65 memcpy( dest, path, src - path );
69 const char* ExtractFilename( const char* path ){
70 char* p = strrchr( path, '/' );
72 p = strrchr( path, '\\' );
81 int Q_stricmp( const char *s1, const char *s2 ) {
82 return string_equal_nocase( s1, s2 );
90 bool FileExists( const char *filename ){
93 f = fopen( filename, "r" );
103 // empty wrappers, don't really use them here
105 void Cbuf_AddText( const char *text ) {};
106 void Cbuf_Execute( void ) {};
112 void CDECL Com_Error( int level, const char *error, ... ){
116 va_start( argptr,error );
117 vsprintf( buf, error,argptr );
120 Sys_Printf( "Camera::ERROR->%s", buf );
123 void CDECL Com_Printf( const char* msg, ... ){
127 va_start( argptr,msg );
128 vsprintf( buf, msg,argptr );
131 Sys_Printf( "Camera::%s", buf );
134 void CDECL Com_DPrintf( const char* msg, ... ){
139 va_start( argptr,msg );
140 vsprintf( buf, msg,argptr );
143 Sys_Printf( "Camera::%s", buf );
147 void *Com_Allocate( int bytes ) {
148 return( malloc( bytes ) );
151 void Com_Dealloc( void *ptr ) {
160 #pragma warning(disable : 4311)
161 #pragma warning(disable : 4312)
164 int FS_Read( void *buffer, int len, fileHandle_t f ) {
165 return fread( buffer, len, 1, (FILE *)f );
168 int FS_Write( const void *buffer, int len, fileHandle_t h ) {
169 return fwrite( buffer, len, 1, (FILE *)h );
172 int FS_ReadFile( const char *qpath, void **buffer ) {
179 len = FS_FOpenFileRead( qpath, &h, qfalse );
189 buf = (byte *)Com_Allocate( len + 1 );
193 FS_Read( buf, len, h );
201 void FS_FreeFile( void *buffer ) {
202 Com_Dealloc( buffer );
205 int FS_FOpenFileRead( const char *filename, fileHandle_t *file, bool uniqueFILE ) {
209 fh = fopen( filename, "rb" );
210 *file = *(fileHandle_t *)&fh;
213 fseek( fh, 0, SEEK_END );
223 fileHandle_t FS_FOpenFileWrite( const char *filename ) {
227 memset( &f, 0, sizeof( f ) );
229 fh = fopen( filename, "wb" );
231 f = (fileHandle_t)fh;
235 void FS_FCloseFile( fileHandle_t f ) {