[Scummvm-cvs-logs] SF.net SVN: scummvm: [26017] scummvm/trunk/common
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Mar 8 17:46:03 CET 2007
Revision: 26017
http://scummvm.svn.sourceforge.net/scummvm/?rev=26017&view=rev
Author: fingolfin
Date: 2007-03-08 08:46:02 -0800 (Thu, 08 Mar 2007)
Log Message:
-----------
Changed File::_handle to be of type void* instead of FILE* (to ease porting); moved PS2 std C I/O defines to file.cpp (no code other than the file & savegame code should use fopen etc. directly)
Modified Paths:
--------------
scummvm/trunk/common/file.cpp
scummvm/trunk/common/file.h
scummvm/trunk/common/scummsys.h
Modified: scummvm/trunk/common/file.cpp
===================================================================
--- scummvm/trunk/common/file.cpp 2007-03-08 16:43:33 UTC (rev 26016)
+++ scummvm/trunk/common/file.cpp 2007-03-08 16:46:02 UTC (rev 26017)
@@ -30,6 +30,29 @@
#include "CoreFoundation/CoreFoundation.h"
#endif
+#ifdef __PLAYSTATION2__
+ // for those replaced fopen/fread/etc functions
+ typedef unsigned long uint64;
+ typedef signed long int64;
+ #include "backends/platform/ps2/fileio.h"
+
+ #define fopen(a, b) ps2_fopen(a, b)
+ #define fclose(a) ps2_fclose(a)
+ #define fflush(a) ps2_fflush(a)
+ #define fseek(a, b, c) ps2_fseek(a, b, c)
+ #define ftell(a) ps2_ftell(a)
+ #define feof(a) ps2_feof(a)
+ #define fread(a, b, c, d) ps2_fread(a, b, c, d)
+ #define fwrite(a, b, c, d) ps2_fwrite(a, b, c, d)
+ #define fgetc(a) ps2_fgetc(a)
+ #define fgets(a, b, c) ps2_fgets(a, b, c)
+ #define fputc(a, b) ps2_fputc(a, b)
+ #define fputs(a, b) ps2_fputs(a, b)
+ #define fprintf ps2_fprintf
+ #define fsize(a) ps2_fsize(a)
+#endif
+
+
namespace Common {
typedef HashMap<String, int, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringIntMap;
@@ -337,7 +360,7 @@
void File::close() {
if (_handle)
- fclose(_handle);
+ fclose((FILE *)_handle);
_handle = NULL;
}
@@ -359,7 +382,7 @@
return false;
}
- return feof(_handle) != 0;
+ return feof((FILE *)_handle) != 0;
}
uint32 File::pos() const {
@@ -368,7 +391,7 @@
return 0;
}
- return ftell(_handle);
+ return ftell((FILE *)_handle);
}
uint32 File::size() const {
@@ -377,10 +400,10 @@
return 0;
}
- uint32 oldPos = ftell(_handle);
- fseek(_handle, 0, SEEK_END);
- uint32 length = ftell(_handle);
- fseek(_handle, oldPos, SEEK_SET);
+ uint32 oldPos = ftell((FILE *)_handle);
+ fseek((FILE *)_handle, 0, SEEK_END);
+ uint32 length = ftell((FILE *)_handle);
+ fseek((FILE *)_handle, oldPos, SEEK_SET);
return length;
}
@@ -391,8 +414,8 @@
return;
}
- if (fseek(_handle, offs, whence) != 0)
- clearerr(_handle);
+ if (fseek((FILE *)_handle, offs, whence) != 0)
+ clearerr((FILE *)_handle);
}
uint32 File::read(void *ptr, uint32 len) {
@@ -407,7 +430,7 @@
if (len == 0)
return 0;
- real_len = fread(ptr2, 1, len, _handle);
+ real_len = fread(ptr2, 1, len, (FILE *)_handle);
if (real_len < len) {
_ioFailed = true;
}
@@ -424,7 +447,7 @@
if (len == 0)
return 0;
- if ((uint32)fwrite(ptr, 1, len, _handle) != len) {
+ if ((uint32)fwrite(ptr, 1, len, (FILE *)_handle) != len) {
_ioFailed = true;
}
Modified: scummvm/trunk/common/file.h
===================================================================
--- scummvm/trunk/common/file.h 2007-03-08 16:43:33 UTC (rev 26016)
+++ scummvm/trunk/common/file.h 2007-03-08 16:46:02 UTC (rev 26017)
@@ -34,8 +34,8 @@
class File : public SeekableReadStream, public WriteStream {
protected:
- /** POSIX file handle to the actual file; 0 if no file is open. */
- FILE *_handle;
+ /** File handle to the actual file; 0 if no file is open. */
+ void *_handle;
/** Status flag which tells about recent I/O failures. */
bool _ioFailed;
Modified: scummvm/trunk/common/scummsys.h
===================================================================
--- scummvm/trunk/common/scummsys.h 2007-03-08 16:43:33 UTC (rev 26016)
+++ scummvm/trunk/common/scummsys.h 2007-03-08 16:46:02 UTC (rev 26017)
@@ -279,21 +279,6 @@
#define SCUMM_LITTLE_ENDIAN
#define SCUMM_NEED_ALIGNMENT
- #define fopen(a, b) ps2_fopen(a, b)
- #define fclose(a) ps2_fclose(a)
- #define fflush(a) ps2_fflush(a)
- #define fseek(a, b, c) ps2_fseek(a, b, c)
- #define ftell(a) ps2_ftell(a)
- #define feof(a) ps2_feof(a)
- #define fread(a, b, c, d) ps2_fread(a, b, c, d)
- #define fwrite(a, b, c, d) ps2_fwrite(a, b, c, d)
- #define fgetc(a) ps2_fgetc(a)
- #define fgets(a, b, c) ps2_fgets(a, b, c)
- #define fputc(a, b) ps2_fputc(a, b)
- #define fputs(a, b) ps2_fputs(a, b)
- #define fprintf ps2_fprintf
- #define fsize(a) ps2_fsize(a)
-
#elif defined(__PSP__)
#define scumm_stricmp strcasecmp
@@ -407,16 +392,5 @@
typedef int16 OverlayColor;
#endif
-#ifdef __PLAYSTATION2__
- // for libmpeg2...
- typedef uint8 uint8_t;
- typedef uint32 uint32_t;
- // for those replaced fopen/fread/etc functions
- typedef unsigned long uint64;
- typedef signed long int64;
- #include "backends/platform/ps2/fileio.h"
#endif
-
-
-#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list