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.
28 #include "globaldefs.h"
30 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 ){
45 for ( char* p = path; *p; p++ )
55 void ExtractFilePath( const char *path, char *dest ){
58 src = path + strlen( path ) - 1;
61 // back up until a \ or the start
63 while ( src != path && *( src - 1 ) != '/' && *( src - 1 ) != '\\' )
66 memcpy( dest, path, src - path );
70 const char* ExtractFilename( const char* path ){
71 char* p = strrchr( path, '/' );
73 p = strrchr( path, '\\' );
82 int Q_stricmp( const char *s1, const char *s2 ) {
83 return string_equal_nocase( s1, s2 );
91 bool FileExists( const char *filename ){
94 f = fopen( filename, "r" );
104 // empty wrappers, don't really use them here
106 void Cbuf_AddText( const char *text ) {};
107 void Cbuf_Execute( void ) {};
113 void CDECL Com_Error( int level, const char *error, ... ){
117 va_start( argptr,error );
118 vsprintf( buf, error,argptr );
121 Sys_Printf( "Camera::ERROR->%s", buf );
124 void CDECL Com_Printf( const char* msg, ... ){
128 va_start( argptr,msg );
129 vsprintf( buf, msg,argptr );
132 Sys_Printf( "Camera::%s", buf );
135 void CDECL Com_DPrintf( const char* msg, ... ){
140 va_start( argptr,msg );
141 vsprintf( buf, msg,argptr );
144 Sys_Printf( "Camera::%s", buf );
148 void *Com_Allocate( int bytes ) {
149 return( malloc( bytes ) );
152 void Com_Dealloc( void *ptr ) {
160 #if GDEF_COMPILER_MSVC
161 #pragma warning(disable : 4311)
162 #pragma warning(disable : 4312)
165 int FS_Read( void *buffer, int len, fileHandle_t f ) {
166 return fread( buffer, len, 1, (FILE *)f );
169 int FS_Write( const void *buffer, int len, fileHandle_t h ) {
170 return fwrite( buffer, len, 1, (FILE *)h );
173 int FS_ReadFile( const char *qpath, void **buffer ) {
180 len = FS_FOpenFileRead( qpath, &h, qfalse );
190 buf = (byte *)Com_Allocate( len + 1 );
194 FS_Read( buf, len, h );
202 void FS_FreeFile( void *buffer ) {
203 Com_Dealloc( buffer );
206 int FS_FOpenFileRead( const char *filename, fileHandle_t *file, bool uniqueFILE ) {
210 fh = fopen( filename, "rb" );
211 *file = *(fileHandle_t *)&fh;
214 fseek( fh, 0, SEEK_END );
224 fileHandle_t FS_FOpenFileWrite( const char *filename ) {
228 memset( &f, 0, sizeof( f ) );
230 fh = fopen( filename, "wb" );
232 f = (fileHandle_t)fh;
236 void FS_FCloseFile( fileHandle_t f ) {