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, ...)
35 va_start(argptr, text);
36 vsprintf(buf, text, argptr);
39 Sys_Printf("Camera::ERROR->%s", buf);
42 char *UnixToDosPath(char *path)
47 for ( char* p = path; *p; p++ )
57 void ExtractFilePath(const char *path, char *dest)
61 src = path + strlen(path) - 1;
64 // back up until a \ or the start
66 while (src != path && *(src - 1) != '/' && *(src - 1) != '\\') {
70 memcpy(dest, path, src - path);
74 const char *ExtractFilename(const char *path)
76 char *p = strrchr(path, '/');
78 p = strrchr(path, '\\');
87 int Q_stricmp(const char *s1, const char *s2)
89 return string_equal_nocase(s1, s2);
97 bool FileExists(const char *filename)
101 f = fopen(filename, "r");
111 // empty wrappers, don't really use them here
113 void Cbuf_AddText(const char *text)
116 void Cbuf_Execute(void)
123 void CDECL Com_Error(int level, const char *error, ...)
128 va_start(argptr, error);
129 vsprintf(buf, error, argptr);
132 Sys_Printf("Camera::ERROR->%s", buf);
135 void CDECL Com_Printf(const char *msg, ...)
140 va_start(argptr, msg);
141 vsprintf(buf, msg, argptr);
144 Sys_Printf("Camera::%s", buf);
147 void CDECL Com_DPrintf(const char *msg, ...)
153 va_start( argptr,msg );
154 vsprintf( buf, msg,argptr );
157 Sys_Printf( "Camera::%s", buf );
161 void *Com_Allocate(int bytes)
163 return (malloc(bytes));
166 void Com_Dealloc(void *ptr)
175 #if GDEF_COMPILER_MSVC
176 #pragma warning(disable : 4311)
177 #pragma warning(disable : 4312)
180 int FS_Read(void *buffer, int len, fileHandle_t f)
182 return fread(buffer, len, 1, (FILE *) f);
185 int FS_Write(const void *buffer, int len, fileHandle_t h)
187 return fwrite(buffer, len, 1, (FILE *) h);
190 int FS_ReadFile(const char *qpath, void **buffer)
198 len = FS_FOpenFileRead(qpath, &h, qfalse);
208 buf = (byte *) Com_Allocate(len + 1);
212 FS_Read(buf, len, h);
220 void FS_FreeFile(void *buffer)
225 int FS_FOpenFileRead(const char *filename, fileHandle_t *file, bool uniqueFILE)
230 fh = fopen(filename, "rb");
231 *file = *(fileHandle_t *) &fh;
234 fseek(fh, 0, SEEK_END);
243 fileHandle_t FS_FOpenFileWrite(const char *filename)
248 memset(&f, 0, sizeof(f));
250 fh = fopen(filename, "wb");
252 f = (fileHandle_t) fh;
256 void FS_FCloseFile(fileHandle_t f)