1 |
dpavlin |
1 |
/* |
2 |
|
|
* libhfs - library for reading and writing Macintosh HFS volumes. |
3 |
|
|
* |
4 |
|
|
* a record contains a key and a folder or file and is part |
5 |
|
|
* of a btree. |
6 |
|
|
* |
7 |
|
|
* Copyright (C) 2000 Klaus Halfmann <klaus.halfmann@feri.de> |
8 |
|
|
* Original 1996-1998 Robert Leslie <rob@mars.org> |
9 |
|
|
* Additional work by Brad Boyer (flar@pants.nu) |
10 |
|
|
* |
11 |
|
|
* This program is free software; you can redistribute it and/or modify |
12 |
|
|
* it under the terms of the GNU General Public License as published by |
13 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
14 |
|
|
* (at your option) any later version. |
15 |
|
|
* |
16 |
|
|
* This program is distributed in the hope that it will be useful, |
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
|
* GNU General Public License for more details. |
20 |
|
|
* |
21 |
|
|
* You should have received a copy of the GNU General Public License |
22 |
|
|
* along with this program; if not, write to the Free Software |
23 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 |
|
|
* |
25 |
|
|
*/ |
26 |
|
|
|
27 |
|
|
/* Compare two cat_keys ... */ |
28 |
|
|
extern int record_key_compare(void* k1, void* k2); |
29 |
|
|
|
30 |
|
|
/* Compare two extent_keys ... */ |
31 |
|
|
extern int record_extent_key_compare(void* k1, void* k2); |
32 |
|
|
|
33 |
|
|
/* read a catalog key into a given buffer */ |
34 |
|
|
extern char* record_readkey(char* p, void* buf); |
35 |
|
|
|
36 |
|
|
/* read an extent key into a given buffer */ |
37 |
|
|
extern char* record_extent_readkey(char* p, void* buf); |
38 |
|
|
|
39 |
|
|
/* read a hfsp_cat_entry (catalog record) from memory */ |
40 |
|
|
extern char* record_readentry(char *p, void* entry); |
41 |
|
|
|
42 |
|
|
/* read an extent record from memory */ |
43 |
|
|
// For dependency reasons this actually is found in volume.c |
44 |
|
|
extern char* record_extent_readrecord(char *p, void* entry); |
45 |
|
|
|
46 |
|
|
/* intialize the record to the first record of the tree |
47 |
|
|
* which is (per design) the root node. |
48 |
|
|
*/ |
49 |
|
|
extern int record_init_root(record* r, btree* tree); |
50 |
|
|
|
51 |
|
|
/* intialize the record to the folder given by cnid. |
52 |
|
|
*/ |
53 |
|
|
extern int record_init_cnid(record* r, btree* tree, UInt32 cnid); |
54 |
|
|
|
55 |
|
|
/* intialize the record to the first record of the parent. |
56 |
|
|
*/ |
57 |
|
|
extern int record_init_parent(record* r, record* parent); |
58 |
|
|
|
59 |
|
|
extern int record_init_key(record* r, btree* tree, hfsp_cat_key* key); |
60 |
|
|
|
61 |
|
|
|
62 |
|
|
/* intialize the record to the parent directory of the given record. |
63 |
|
|
*/ |
64 |
|
|
extern int record_find_parent(record* r, record* from); |
65 |
|
|
|
66 |
|
|
/* intialize the record by searching for the given string in the given folder. |
67 |
|
|
* |
68 |
|
|
* parent and r may be the same. |
69 |
|
|
*/ |
70 |
|
|
extern int record_init_string_parent(record* r, record* parent, char* key); |
71 |
|
|
|
72 |
|
|
/* initialize a new (catalog) record with given type and (ascii) name. |
73 |
|
|
* parent must be a HFSP_FOLDER or FOLDER_THREAD |
74 |
|
|
* You should normally call record_insert afterwards. |
75 |
|
|
*/ |
76 |
|
|
extern int record_init_string(record* r, UInt16 type, char* name, record* parent); |
77 |
|
|
|
78 |
|
|
/* move record up in folder hierarchy (if possible) */ |
79 |
|
|
extern int record_up(record* r); |
80 |
|
|
|
81 |
|
|
/* move record foreward to next entry. |
82 |
|
|
* |
83 |
|
|
* In case of an error the value of *r is undefined ! |
84 |
|
|
*/ |
85 |
|
|
extern int record_next(record* r); |
86 |
|
|
|
87 |
|
|
/* intialize the extent_record to the extent identified by |
88 |
|
|
* a given file */ |
89 |
|
|
extern int record_init_file(extent_record* r, btree* tree, |
90 |
|
|
UInt8 forktype, UInt32 fileId, UInt32 blockindex); |
91 |
|
|
|
92 |
|
|
/* move foreward to next entent record. */ |
93 |
|
|
extern int record_next_extent(extent_record *r); |
94 |
|
|
|
95 |
|
|
/* intialize the record with the given index entry in the btree. |
96 |
|
|
* |
97 |
|
|
* needed by fscheck, do not use in normal code. |
98 |
|
|
*/ |
99 |
|
|
extern int record_init(record* r, btree* bt, node_buf* buf, UInt16 index); |
100 |
|
|
|
101 |
|
|
/* remove record from btree, It does not (yet) care about any |
102 |
|
|
* forks associated with a file, see below for flags */ |
103 |
|
|
|
104 |
|
|
extern int record_delete(record* r, int flags); |
105 |
|
|
|
106 |
|
|
/* insert record into btree, It does not care about any |
107 |
|
|
* forks associated with a file (yet) */ |
108 |
|
|
extern int record_insert(record* r); |
109 |
|
|
|
110 |
|
|
/* Do not care about files/folders/threads, needed internally */ |
111 |
|
|
#define RECORD_DELETE_DIRECT 0x0001 |
112 |
|
|
|
113 |
|
|
/* Similar to the rm -f flag, may not be supported */ |
114 |
|
|
#define RECORD_DELETE_FORCE 0x0002 |
115 |
|
|
|
116 |
|
|
/* Descend recursivly in directories and delete them (like rm -R) |
117 |
|
|
* Non-empty directories can not be deleted otherwise */ |
118 |
|
|
#define RECORD_DELETE_RECURSE 0x0004 |
119 |
|
|
|