xref: /aosp_15_r20/external/mtools/mtoolsDirentry.h (revision d5c9a868b113e0ec0db2f27bc2ce8a253e77c4b0)
1 #ifndef MTOOLS_DIRENTRY_H
2 #define MTOOLS_DIRENTRY_H
3 /*  Copyright 1998,2000-2002,2005,2008-2010 Alain Knaff.
4  *  This file is part of mtools.
5  *
6  *  Mtools is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  Mtools is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include "sysincludes.h"
20 #include "vfat.h"
21 
22 typedef struct direntry_t {
23 	struct Stream_t *Dir;
24 	/* struct direntry_t *parent; parent level */
25 	int entry; /* slot in parent directory  */
26 	/* Negative values have the following meanings:
27 	   -1 not initialized
28 	   -2 entry searched for, but not found
29 	   -3 root directory */
30 	struct directory dir; /* descriptor in parent directory (random if
31 			       * root)*/
32 	wchar_t name[MAX_VNAMELEN+1]; /* name in its parent directory, or
33 				       * NULL if root */
34 	int beginSlot; /* begin and end slot, for delete */
35 	int endSlot;
36 } direntry_t;
37 
38 #include "stream.h"
39 
40 int vfat_lookup(direntry_t *entry, const char *filename, size_t length,
41 		int flags,
42 		char *shortname, size_t shortname_len,
43 		char *longname, size_t longname_len);
44 
45 int vfat_lookup_zt(direntry_t *entry, const char *filename,
46 		   int flags,
47 		   char *shortname, size_t shortname_len,
48 		   char *longname, size_t longname_len);
49 
50 
51 struct directory *dir_read(direntry_t *entry, int *error);
52 
53 void initializeDirentry(direntry_t *entry, struct Stream_t *Dir);
54 int isNotFound(direntry_t *entry);
55 direntry_t *getParent(direntry_t *entry);
56 void dir_write(direntry_t *entry);
57 void low_level_dir_write(direntry_t *entry);
58 void low_level_dir_write_end(Stream_t *Dir, int entry);
59 int fatFreeWithDirentry(direntry_t *entry);
60 int labelit(struct dos_name_t *dosname,
61 	    char *longname,
62 	    void *arg0,
63 	    direntry_t *entry);
64 int isSubdirOf(Stream_t *inside, Stream_t *outside);
65 char *getPwd(direntry_t *entry);
66 void fprintPwd(FILE *f, direntry_t *entry, int escape);
67 void fprintShortPwd(FILE *f, direntry_t *entry);
68 int write_vfat(Stream_t *, dos_name_t *, char *, unsigned int, direntry_t *);
69 
70 void wipeEntry(struct direntry_t *entry);
71 
72 void dosnameToDirentry(const struct dos_name_t *n, struct directory *dir);
73 
74 int lookupForInsert(Stream_t *Dir,
75 		    direntry_t *direntry,
76 		    struct dos_name_t *dosname,
77 		    char *longname,
78 		    struct scan_state *ssp,
79 		    int ignore_entry,
80 		    int source_entry,
81 		    int pessimisticShortRename,
82 		    int use_longname);
83 #endif
84