1 | /* $Id: ntdir.h 2708 2013-11-21 10:26:40Z bird $ */
|
---|
2 | /** @file
|
---|
3 | * MSC + NT opendir, readdir, closedir and friends.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 2005-2013 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
---|
25 | * IN THE SOFTWARE.
|
---|
26 | *
|
---|
27 | * Alternatively, the content of this file may be used under the terms of the
|
---|
28 | * GPL version 2 or later, or LGPL version 2.1 or later.
|
---|
29 | */
|
---|
30 |
|
---|
31 | #ifndef ___nt_ntdir_h
|
---|
32 | #define ___nt_ntdir_h
|
---|
33 |
|
---|
34 | #include "nttypes.h"
|
---|
35 | #include "ntstat.h"
|
---|
36 |
|
---|
37 | typedef struct dirent
|
---|
38 | {
|
---|
39 | /** Optional stat information.
|
---|
40 | * Only provided if using birdDirOpenExtraInfo(). */
|
---|
41 | BirdStat_T d_stat;
|
---|
42 | /** The record length. */
|
---|
43 | unsigned __int16 d_reclen;
|
---|
44 | /** The name length. */
|
---|
45 | unsigned __int16 d_namlen;
|
---|
46 | /** The name type. */
|
---|
47 | unsigned char d_type;
|
---|
48 | /** The name. */
|
---|
49 | char d_name[512 - sizeof(BirdStat_T) - 2 - 2 - 1];
|
---|
50 | } BirdDirEntry_T;
|
---|
51 |
|
---|
52 | #define d_ino d_stat.st_ino;
|
---|
53 |
|
---|
54 | /** @name d_type values.
|
---|
55 | * @{ */
|
---|
56 | #define DT_UNKNOWN 0
|
---|
57 | #define DT_FIFO 1
|
---|
58 | #define DT_CHR 2
|
---|
59 | #define DT_DIR 4
|
---|
60 | #define DT_BLK 6
|
---|
61 | #define DT_REG 8
|
---|
62 | #define DT_LNK 10
|
---|
63 | #define DT_SOCK 12
|
---|
64 | #define DT_WHT 14
|
---|
65 | /** @} */
|
---|
66 |
|
---|
67 | typedef struct BirdDir
|
---|
68 | {
|
---|
69 | /** Magic value. */
|
---|
70 | unsigned uMagic;
|
---|
71 | /** The directory handle. */
|
---|
72 | void *pvHandle;
|
---|
73 | /** The device number (st_dev). */
|
---|
74 | unsigned __int64 uDev;
|
---|
75 | /** The current position. */
|
---|
76 | long offPos;
|
---|
77 |
|
---|
78 | /** Set if we haven't yet read anything. */
|
---|
79 | int fFirst;
|
---|
80 | /** Set if we have data in the buffer. */
|
---|
81 | int fHaveData;
|
---|
82 | /** The info type we're querying. */
|
---|
83 | int iInfoClass;
|
---|
84 | /** The current buffer position. */
|
---|
85 | unsigned offBuf;
|
---|
86 | /** The number of bytes allocated for pabBuf. */
|
---|
87 | unsigned cbBuf;
|
---|
88 | /** Buffer of size cbBuf. */
|
---|
89 | unsigned char *pabBuf;
|
---|
90 |
|
---|
91 | /** Static directory entry. */
|
---|
92 | BirdDirEntry_T DirEntry;
|
---|
93 | } BirdDir_T;
|
---|
94 | /** Magic value for BirdDir. */
|
---|
95 | #define BIRD_DIR_MAGIC 0x19731120
|
---|
96 |
|
---|
97 |
|
---|
98 | BirdDir_T *birdDirOpen(const char *pszPath);
|
---|
99 | BirdDir_T *birdDirOpenExtraInfo(const char *pszPath);
|
---|
100 | BirdDirEntry_T *birdDirRead(BirdDir_T *pDir);
|
---|
101 | long birdDirTell(BirdDir_T *pDir);
|
---|
102 | void birdDirSeek(BirdDir_T *pDir, long offDir);
|
---|
103 | int birdDirClose(BirdDir_T *pDir);
|
---|
104 |
|
---|
105 | #define opendir birdDirOpen
|
---|
106 | #define readdir birdDirRead
|
---|
107 | #define telldir birdDirTell
|
---|
108 | #define seekdir birdDirSeek
|
---|
109 | #define rewinddir(a_pDir, a_offDir) birdDirSeek(a_pDir, 0)
|
---|
110 | #define closedir birdDirClose
|
---|
111 | #define _D_NAMLEN(a_pEnt) ((a_pEnt)->d_namlen)
|
---|
112 | typedef BirdDir_T DIR;
|
---|
113 |
|
---|
114 | #endif
|
---|
115 |
|
---|