Niotso
git revision 558726a9f13d7c3423a683dd2f4323589b66c310
The New Implementation of The Sims Online
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
Libraries
FileHandler
FileHandler.hpp
Go to the documentation of this file.
1
/*
2
FileHandler - General-purpose file handling library for Niotso
3
FileHandler.hpp - Copyright (c) 2011-2012 Niotso Project <http://niotso.org/>
4
Author(s): Fatbag <X-Fi6@phppoll.org>
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
19
#ifndef FILEHANDLER_HPP
20
#define FILEHANDLER_HPP
21
22
#include <stdlib.h>
23
#include <stdint.h>
24
#include <stddef.h>
25
#include <stdio.h>
26
#include <string.h>
27
28
#ifdef WIN32
29
#define fhexport __declspec(dllexport)
30
#else
31
#define fhexport __attribute__((visibility ("default")))
32
#endif
33
34
struct
Asset_t
{
35
uint32_t
Group
;
36
uint32_t
File
;
37
uint32_t
Type
;
38
};
39
40
enum
FErr
{
41
FERR_NOT_FOUND
,
42
FERR_OPEN
,
43
FERR_BLANK
,
44
FERR_MEMORY
,
45
FERR_READ
,
46
FERR_UNRECOGNIZED
,
47
FERR_INVALIDDATA
48
};
49
50
enum
ImageFormat_t
{
51
FIMG_BGR24
,
52
FIMG_BGRA32
53
};
54
55
struct
Image_t
{
56
unsigned
Width
,
Height
;
57
ImageFormat_t
Format
;
58
uint8_t *
Data
;
59
};
60
61
struct
Sound_t
{
62
unsigned
Channels
;
63
unsigned
SamplingRate
;
64
unsigned
BitDepth
;
65
unsigned
Duration
;
66
uint8_t *
Data
;
67
};
68
69
namespace
File {
70
71
inline
size_t
GetFileSize
(FILE *
hFile
){
72
fseek(hFile, 0, SEEK_END);
73
size_t
FileSize
= ftell(hFile);
74
fseek(hFile, 0, SEEK_SET);
75
return
FileSize
;
76
}
77
78
fhexport
extern
int
Error
;
79
fhexport
extern
size_t
FileSize
;
80
81
fhexport
uint8_t *
ReadFile
(
const
char
*
Filename
);
82
fhexport
Image_t
*
ReadImageFile
(
const
char
*
Filename
);
83
fhexport
Sound_t
*
ReadSoundFile
(
const
char
*
Filename
);
84
85
}
86
87
#endif
Generated on Sat Jun 15 2013 03:02:15 for Niotso by
1.8.4