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, ... )
34 va_start (argptr,text);
35 vsprintf (buf, text,argptr);
38 Sys_Printf("Camera::ERROR->%s", buf);
41 char* UnixToDosPath( char* path )
46 for(char* p = path; *p; p++)
55 void ExtractFilePath( const char *path, char *dest )
59 src = path + strlen(path) - 1;
62 // back up until a \ or the start
64 while (src != path && *(src-1) != '/' && *(src-1) != '\\')
67 memcpy (dest, path, src-path);
71 const char* ExtractFilename( const char* path )
73 char* p = strrchr(path, '/');
76 p = strrchr(path, '\\');
84 int Q_stricmp (const char *s1, const char *s2) {
85 return string_equal_nocase( s1, s2 );
93 bool FileExists (const char *filename)
97 f = fopen( filename, "r" );
106 // empty wrappers, don't really use them here
108 void Cbuf_AddText( const char *text ) {};
109 void Cbuf_Execute (void) {};
115 void CDECL Com_Error( int level, const char *error, ... )
120 va_start (argptr,error);
121 vsprintf (buf, error,argptr);
124 Sys_Printf("Camera::ERROR->%s", buf);
127 void CDECL Com_Printf( const char* msg, ... )
132 va_start (argptr,msg);
133 vsprintf (buf, msg,argptr);
136 Sys_Printf("Camera::%s", buf);
139 void CDECL Com_DPrintf( const char* msg, ... )
145 va_start (argptr,msg);
146 vsprintf (buf, msg,argptr);
149 Sys_Printf("Camera::%s", buf);
153 void *Com_Allocate( int bytes ) {
154 return( malloc( bytes ) );
157 void Com_Dealloc( void *ptr ) {
166 #pragma warning(disable : 4311)
167 #pragma warning(disable : 4312)
170 int FS_Read( void *buffer, int len, fileHandle_t f ) {
171 return fread( buffer, len, 1, (FILE *)f );
174 int FS_Write( const void *buffer, int len, fileHandle_t h ) {
175 return fwrite( buffer, len, 1, (FILE *)h );
178 int FS_ReadFile( const char *qpath, void **buffer ) {
185 len = FS_FOpenFileRead( qpath, &h, qfalse );
195 buf = (byte *)Com_Allocate( len + 1 );
199 FS_Read (buf, len, h);
207 void FS_FreeFile( void *buffer ) {
208 Com_Dealloc( buffer );
211 int FS_FOpenFileRead( const char *filename, fileHandle_t *file, bool uniqueFILE ) {
215 fh = fopen( filename, "rb" );
216 *file = *(fileHandle_t *)&fh;
220 fseek (fh, 0, SEEK_END);
229 fileHandle_t FS_FOpenFileWrite( const char *filename ) {
233 memset( &f, 0, sizeof(f) );
235 fh = fopen( filename, "wb" );
237 f = (fileHandle_t)fh;
241 void FS_FCloseFile( fileHandle_t f ) {