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