~ubuntu-branches/debian/sid/astromenace/sid

« back to all changes in this revision

Viewing changes to AstroMenaceSource/Core/VirtualFileSystem/VFS.h

  • Committer: Package Import Robot
  • Author(s): Boris Pek
  • Date: 2013-04-09 02:04:25 UTC
  • Revision ID: package-import@ubuntu.com-20130409020425-a7fl9xk4diamw6di
Tags: upstream-1.3.1+repack
Import upstream version 1.3.1+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/************************************************************************************
 
2
 
 
3
        AstroMenace (Hardcore 3D space shooter with spaceship upgrade possibilities)
 
4
        Copyright © 2006-2012 Michael Kurinnoy, Viewizard
 
5
 
 
6
 
 
7
        AstroMenace 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 3 of the License, or
 
10
        (at your option) any later version.
 
11
 
 
12
        AstroMenace 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.
 
16
 
 
17
        You should have received a copy of the GNU General Public License
 
18
        along with AstroMenace. If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
 
 
21
        Web Site: http://www.viewizard.com/
 
22
        Project: http://sourceforge.net/projects/openastromenace/
 
23
        E-mail: viewizard@viewizard.com
 
24
 
 
25
*************************************************************************************/
 
26
 
 
27
 
 
28
#ifndef VFS_H
 
29
#define VFS_H
 
30
 
 
31
 
 
32
#include "../Base.h"
 
33
 
 
34
 
 
35
 
 
36
// File present in the VFS
 
37
#define VFS_FILE_VFS                                                    0x0031
 
38
// File present in the File System
 
39
#define VFS_FILE_FS                                                             0x0032
 
40
 
 
41
 
 
42
 
 
43
 
 
44
 
 
45
// Current VFS version
 
46
#define VFS_VER                                                                 "v1.5"
 
47
// Data compression
 
48
#define VFS_DATA_ARH_NONE                                               '0'
 
49
#define VFS_DATA_ARH_RLE                                                '1'
 
50
#define VFS_DATA_ARH_HAFF                                               '2'
 
51
 
 
52
 
 
53
 
 
54
struct eFILE
 
55
{
 
56
        char*   Name;           // File name
 
57
        int             VFS_Offset;     // File offset in the VFS file
 
58
        int             PackLength;     // File size in the VFS file
 
59
        int             RealLength;     // File size in the memory (unpacked file size)
 
60
        long    Pos;            // Current position in the file
 
61
        BYTE*   Data;           // Pointer to the file data (unpacked) in the memory
 
62
 
 
63
        // Read data
 
64
        int fread(void *buffer, size_t size, size_t count);
 
65
        // Set current position in the file
 
66
        int fseek(long offset, int origin);
 
67
        // Get current position in the file
 
68
        long ftell();
 
69
        // Check End-of-File indicator
 
70
        int feof();
 
71
        // Get string from stream
 
72
        char *fgets(char *str, int num);
 
73
 
 
74
 
 
75
        eFILE*  Prev;           // Pointer to the previous opened file
 
76
        eFILE*  Next;           // Pointer to the next opened file
 
77
};
 
78
 
 
79
 
 
80
 
 
81
// VFS functions
 
82
 
 
83
// Create VFS file
 
84
int             vw_CreateVFS(const char *Name, unsigned int BuildNumber);
 
85
// Write data from memory into VFS file
 
86
int             vw_WriteIntoVFSfromMemory(const char *Name, const BYTE * buffer, int size);
 
87
// Open VFS file
 
88
int             vw_OpenVFS(const char *Name, unsigned int BuildNumber);
 
89
// Close VFS file
 
90
void    vw_CloseVFS(void);
 
91
// Shutdown VFS (all eFILE files will be closed)
 
92
void    vw_ShutdownVFS(void);
 
93
// Get file location status (FS or VFS)
 
94
int     FileDetect(const char *FileName);
 
95
// Create file "symlink"
 
96
bool    vw_CreateEntryLinkVFS(const char *FileName, const char *FileNameLink);
 
97
// Delete file "symlink"
 
98
bool    vw_DeleteEntryLinkVFS(const char *FileNameLink);
 
99
// Delete all "symlinks" in VFS
 
100
bool    vw_DeleteAllLinksVFS();
 
101
 
 
102
// eFILE functions
 
103
 
 
104
// Open file
 
105
eFILE*  vw_fopen(const char *FileName);
 
106
// Close file
 
107
int             vw_fclose(eFILE *stream);
 
108
 
 
109
 
 
110
 
 
111
 
 
112
int vw_HAFFtoDATA(int size, BYTE **dstVFS, BYTE *srcVFS, int *dsizeVFS, int ssizeVFS);
 
113
int vw_RLEtoDATA(int size, BYTE **dstVFS, BYTE *srcVFS, int *dsizeVFS, int ssizeVFS);
 
114
int vw_DATAtoHAFF(BYTE **dstVFS, BYTE *srcVFS, int *dsizeVFS, int ssizeVFS);
 
115
int vw_DATAtoRLE(BYTE **dstVFS, BYTE *srcVFS, int *dsizeVFS, int ssizeVFS);
 
116
 
 
117
 
 
118
/*
 
119
VFS v1.5
 
120
 
 
121
  4b - 'VFS_'
 
122
  4b - 'v1.5'
 
123
  4b - VFS build number
 
124
  4b - file table offset
 
125
  4b - file table size
 
126
  ?b - data (file data one by one)
 
127
 
 
128
  - File table structure
 
129
  1b - 00, if no encoding key
 
130
        or
 
131
  1b - encoding key size in byte
 
132
  ?b - encoding key
 
133
  2b - file name size
 
134
  ?b - file name
 
135
  4b - file position offset in VFS file
 
136
  4b - file size in VFS file
 
137
  4b - original file size
 
138
*/
 
139
 
 
140
 
 
141
 
 
142
#endif // VFS_H
 
143