Sync with trunk head
[reactos.git] / lib / 3rdparty / fullfat / ff_dir.h
1 /*****************************************************************************
2 * FullFAT - High Performance, Thread-Safe Embedded FAT File-System *
3 * Copyright (C) 2009 James Walmsley (james@worm.me.uk) *
4 * *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17 * *
18 * IMPORTANT NOTICE: *
19 * ================= *
20 * Alternative Licensing is available directly from the Copyright holder, *
21 * (James Walmsley). For more information consult LICENSING.TXT to obtain *
22 * a Commercial license. *
23 * *
24 * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. *
25 * *
26 * Removing the above notice is illegal and will invalidate this license. *
27 *****************************************************************************
28 * See http://worm.me.uk/fullfat for more information. *
29 * Or http://fullfat.googlecode.com/ for latest releases and the wiki. *
30 *****************************************************************************/
31
32 /**
33 * @file ff_dir.h
34 * @author James Walmsley
35 * @ingroup DIR
36 **/
37 #ifndef _FF_DIR_H_
38 #define _FF_DIR_H_
39
40 #include "ff_types.h"
41 #include "ff_config.h"
42 #include "ff_error.h"
43 #include "ff_ioman.h"
44 #include "ff_blk.h"
45 #include "ff_fat.h"
46 #include "fat.h"
47 #include "ff_memory.h"
48 #include "ff_time.h"
49 #include "ff_hash.h"
50 #include "ff_crc.h"
51 #include "ff_file.h"
52 #include <string.h>
53
54 typedef struct {
55 FF_T_INT8 FileName[FF_MAX_FILENAME];
56 FF_T_UINT8 Attrib;
57 FF_T_UINT32 Filesize;
58 FF_T_UINT32 ObjectCluster;
59
60 #ifdef FF_TIME_SUPPORT
61 FF_SYSTEMTIME CreateTime; ///< Date and Time Created.
62 FF_SYSTEMTIME ModifiedTime; ///< Date and Time Modified.
63 FF_SYSTEMTIME AccessedTime; ///< Date of Last Access.
64 #endif
65
66 //---- Book Keeping for FF_Find Functions
67 FF_T_UINT16 CurrentItem;
68 FF_T_UINT32 DirCluster;
69 FF_T_UINT32 CurrentCluster;
70 FF_T_UINT32 AddrCurrentCluster;
71 //FF_T_UINT8 NumLFNs;
72 } FF_DIRENT;
73
74 FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
75 FF_T_SINT8 FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
76 FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs);
77 FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path);
78 FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent);
79 void FF_PopulateShortDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer);
80 FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry);
81 FF_T_SINT8 FF_FetchEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer);
82 FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer);
83 FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer);
84 FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
85 FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent);
86 FF_T_SINT8 FF_CreateShortName(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName);
87
88 void FF_lockDIR (FF_IOMAN *pIoman);
89 void FF_unlockDIR (FF_IOMAN *pIoman);
90 FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent);
91 FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path);
92 FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
93 FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
94 FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen);
95
96
97 FF_T_BOOL FF_CheckDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash);
98 FF_T_BOOL FF_DirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
99 FF_ERROR FF_AddDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash);
100 void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
101
102 void FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 DirEntry);
103
104 #endif
105