StRoot
1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
RTS
src
SFS
sfs_base.h
1
#ifndef _SFS_BASE_H_
2
#define _SFS_BASE_H_
3
4
#include <string.h>
5
6
#define SFS_ATTR_INVALID 0x01
7
#define SFS_ATTR_NOCD 0x08
8
#define SFS_ATTR_CD 0x00
9
#define SFS_ATTR_STICKY_CD 0x02
10
#define SFS_ATTR_POPSTICKY 0x04 // path relative to last "sticky_cd"
11
12
struct
SFS_VolumeSpec
{
13
char
fs[12];
// "SFS V00.01"
14
};
15
16
struct
SFS_Header
{
17
char
type[4];
// "HEAD"
18
UINT32 byte_order;
19
UINT32 time;
20
};
21
22
struct
SFS_File
{
23
char
type[4];
// "FILE"
24
UINT32 byte_order;
25
UINT32 sz;
// any number, but file will be padded to be x4
26
UINT8 head_sz;
// must be x4
27
UINT8 attr;
28
UINT16 reserved;
29
char
name[4];
// get rid of padding confusions... by alligning
30
};
31
32
/* Tonko: I need this convenience function */
33
inline
int
sfs_calcfileheader(
char
*fn)
34
{
35
int
n =
sizeof
(
SFS_File
) - 4 ;
36
n += strlen(fn) + 1 ;
37
n = (n+3)&0xfffffffc;
38
39
return
n ;
40
}
41
42
inline
int
sfs_putfileheader(
char
*ptr,
char
*fn,
int
filesz,
int
flags)
43
{
44
SFS_File
*file = (
SFS_File
*)ptr;
45
46
int
n =
sizeof
(
SFS_File
) - 4;
47
n += strlen(fn) + 1;
48
n = (n+3)&0xfffffffc;
49
50
memcpy(file->type,
"FILE"
, 4);
51
file->byte_order = 0x04030201;
52
file->sz = filesz;
53
file->head_sz = n;
54
file->attr = flags;
55
file->reserved = 0;
56
57
// u_int nm = (u_int)file->name;
58
// u_int fl = (u_int)file;
59
// u_int ct = (u_int)(((u_int)file->name) + n - 4);
60
// printf("offset of file: %d. offset to write to: %d\n",nm-fl, n-4);
61
62
memcpy(((
char
*)file) + n - 4,
"\0\0\0\0"
, 4);
63
strcpy(file->name, fn);
64
return
n;
65
}
66
67
#endif
SFS_Header
Definition:
sfs_base.h:16
SFS_File
Definition:
sfs_base.h:22
SFS_VolumeSpec
Definition:
sfs_base.h:12
Generated by
1.8.5