-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfile.h
92 lines (75 loc) · 2.74 KB
/
file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
* PARTICULAR PURPOSE.
*
* Copyright (c) Microsoft Corporation. All Rights Reserved.
*/
#ifndef __FILE_H__
#define __FILE_H__
/*
* FILEDATA - represents a file name and its contents.
*
* The file name is held in the form of a DIRITEM which is managed
* by SCANDIR (see scandir.h). A DIRITEM must be supplied to initialise
* a FILEDATA.
*
* On demand, the FILEDATA will return a handle to a list of lines.
* These are the lines in the file in the form of LINE handles (see line.h)
* this list can be discarded by a call to file_discardlines, or file_delete.
*/
/* handle to filedata */
typedef struct filedata FAR * FILEDATA;
/*
* make a new FILEDATA, based on a DIRITEM. the filedata will retain
* the diritem handle for use in fetching filenames and handles.
*
* if the bRead is set, the file will be read into memory. If not, this
* will be done during the first call to file_getlines
*/
FILEDATA file_new(DIRITEM fiName, BOOL bRead);
/*
* return a handle to the DIRITEM used to create this FILEDATA
*/
DIRITEM file_getdiritem(FILEDATA fi);
/* delete a FILEDATA and its associated list of LINEs. note that the
* DIRITEM is NOT deleted.
*/
void file_delete(FILEDATA fi);
/*
* return a list of the lines in the file. This is a standard list that can
* be traversed with the list functions. The list should only be deleted
* by calls to file_delete or file_discardlines for the owning FILEDATA.
* The items in the list are LINE handles.
*
* this call will cause the file to be read into memory if necessary (if
* the lines had been discarded using file_discardlines, or if bRead were
* false in the initial call to file_new
*/
LIST file_getlinelist(FILEDATA fi);
/*
* free up the line list and any associated memory until it is needed again.
*/
void file_discardlines(FILEDATA fi);
/*
* force all lines in the line list to reset their hashcodes and any line
* links. Does not cause the file to be re-read.
*/
void file_reset(FILEDATA fi);
/*
* give me a checksum for the file. whether or not actually calculated by
* dir_getchecksum(), it will be the same checksum as if it were.
*/
DWORD file_checksum(FILEDATA fi);
/*
* Retrieve the checksum that we have for this file, valid or not.
* Indicate in bValid whether it is actually valid or not.
* Do NOT recalculate it or make any new attempt to read the file!
*/
DWORD file_retrievechecksum(FILEDATA fi, BOOL * bValid);
/* returns TRUE if the file is unicode */
BOOL file_IsUnicode(FILEDATA fd);
/* retrieve the filetime for the file */
FILETIME file_GetTime(FILEDATA fd);
#endif