Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
ixfile.cpp
Go to the documentation of this file.
1/*
2 * ix -- stdio wrappers used by the streamer and its thread.
3 *
4 * Original address range: 0x0048C400 - 0x0048C589
5 * A separate object from the LZO decoder before it, pulled from a library
6 * of its own after the decoder's.
7 */
8#include "ix.h"
9#include <stdlib.h>
10#include <string.h>
11
12#pragma function(strcat)
13
14/* Function start: 0x48C400 */
15/* Unreferenced, like the matching pair in WC1: the file module's empty init
16 * and shutdown entry points. Nothing calls them, so ix.h does not declare
17 * them. */
18extern "C" void ix_file_init_hook(void)
19{
20}
21
22/* Function start: 0x48C410 */
23extern "C" void ix_file_shutdown_hook(void)
24{
25}
26
27/* Function start: 0x48C420 */
28extern "C" FILE *ix_file_open(const char *path, int mode)
29{
30 char modeString[4];
31
32 modeString[0] = 0;
33 if ((mode & 1) != 0)
34 strcat(modeString, "r");
35 if ((mode & 2) != 0)
36 strcat(modeString, "w");
37 strcat(modeString, "b");
38 return fopen(path, modeString);
39}
40
41/* Function start: 0x48C48E */
42extern "C" void ix_file_close(FILE *file)
43{
44 fclose(file);
45}
46
47/* Function start: 0x48C4AA */
48extern "C" void ix_file_seek(FILE *file, long position)
49{
50 fseek(file, position, SEEK_SET);
51}
52
53/* Function start: 0x48C4CC */
54extern "C" long ix_file_tell(FILE *file)
55{
56 return ftell(file);
57}
58
59/* Function start: 0x48C4E8 */
60extern "C" unsigned int ix_file_read(FILE *file, void *destination,
61 unsigned int bytes)
62{
63 return fread(destination, 1, bytes, file);
64}
65
66/* Function start: 0x48C50E */
67/* Unreferenced in WC2. */
68extern "C" unsigned int ix_file_write(FILE *file, const void *source,
69 unsigned int bytes)
70{
71 return fwrite(source, 1, bytes, file);
72}
73
74/* Function start: 0x48C534 */
75extern "C" long ix_file_size(FILE *file)
76{
77 long position;
78 long size;
79
80 position = ftell(file);
81 fseek(file, 0, SEEK_END);
82 size = ftell(file);
83 fseek(file, position, SEEK_SET);
84 return size;
85}
Audio classes, DirectSound interfaces and shared ix state.
void ix_file_close(FILE *file)
Definition ixfile.cpp:42
FILE * ix_file_open(const char *path, int mode)
Definition ixfile.cpp:28
unsigned int ix_file_read(FILE *file, void *destination, unsigned int bytes)
Definition ixfile.cpp:60
void ix_file_seek(FILE *file, long position)
Definition ixfile.cpp:48
long ix_file_tell(FILE *file)
Definition ixfile.cpp:54
long ix_file_size(FILE *file)
Definition ixfile.cpp:75
unsigned int ix_file_write(FILE *file, const void *source, unsigned int bytes)
Definition ixfile.cpp:68
void ix_file_init_hook(void)
Definition ixfile.cpp:18
void ix_file_shutdown_hook(void)
Definition ixfile.cpp:23