VirtualBox

source: kBuild/trunk/src/lib/nt/ntdir.h@ 3004

Last change on this file since 3004 was 3004, checked in by bird, 9 years ago

fts-nt.c: Wide char support, part 3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1/* $Id: ntdir.h 3004 2016-11-05 23:18:51Z 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
37typedef 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
52typedef struct direntw
53{
54 /** Optional stat information.
55 * Only provided if using birdDirOpenExtraInfo(). */
56 BirdStat_T d_stat;
57 /** The record length. */
58 unsigned __int16 d_reclen;
59 /** The name length (in wchar_t). */
60 unsigned __int16 d_namlen;
61 /** The name type. */
62 unsigned char d_type;
63 /** The name. */
64 wchar_t d_name[512 - sizeof(BirdStat_T) - 2 - 2 - 1];
65} BirdDirEntryW_T;
66
67#define d_ino d_stat.st_ino;
68
69/** @name d_type values.
70 * @{ */
71#define DT_UNKNOWN 0
72#define DT_FIFO 1
73#define DT_CHR 2
74#define DT_DIR 4
75#define DT_BLK 6
76#define DT_REG 8
77#define DT_LNK 10
78#define DT_SOCK 12
79#define DT_WHT 14
80/** @} */
81
82/** @name BIRDDIR_F_XXX - birdDirOpenFromHandle & BirdDir_T::fFlags
83 * @{ */
84/** birdDirClose should also close pvHandle. */
85#define BIRDDIR_F_CLOSE_HANDLE 1U
86/** birdDirClose should not close the handle. */
87#define BIRDDIR_F_KEEP_HANDLE 0U
88/** Provide extra info (stat). */
89#define BIRDDIR_F_EXTRA_INFO 2U
90/** Whether to restart the scan. */
91#define BIRDDIR_F_RESTART_SCAN 4U
92/** @} */
93
94typedef struct BirdDir
95{
96 /** Magic value. */
97 unsigned uMagic;
98 /** Flags. */
99 unsigned fFlags;
100 /** The directory handle. */
101 void *pvHandle;
102 /** The device number (st_dev). */
103 unsigned __int64 uDev;
104 /** The current position. */
105 long offPos;
106
107 /** Set if we haven't yet read anything. */
108 int fFirst;
109 /** Set if we have data in the buffer. */
110 int fHaveData;
111 /** The info type we're querying. */
112 int iInfoClass;
113 /** The current buffer position. */
114 unsigned offBuf;
115 /** The number of bytes allocated for pabBuf. */
116 unsigned cbBuf;
117 /** Buffer of size cbBuf. */
118 unsigned char *pabBuf;
119
120 /** Static directory entry. */
121 union
122 {
123 BirdDirEntry_T DirEntry;
124 BirdDirEntryW_T DirEntryW;
125 } u;
126} BirdDir_T;
127/** Magic value for BirdDir. */
128#define BIRD_DIR_MAGIC 0x19731120
129
130
131BirdDir_T *birdDirOpen(const char *pszPath);
132BirdDir_T *birdDirOpenExtraInfo(const char *pszPath);
133BirdDir_T *birdDirOpenExW(void *hRoot, const wchar_t *pwszPath, const wchar_t *pwszFilter, unsigned fFlags);
134BirdDir_T *birdDirOpenFromHandle(void *hDir, const void *pvReserved, unsigned fFlags);
135BirdDirEntry_T *birdDirRead(BirdDir_T *pDir);
136BirdDirEntryW_T *birdDirReadW(BirdDir_T *pDir);
137long birdDirTell(BirdDir_T *pDir);
138void birdDirSeek(BirdDir_T *pDir, long offDir);
139int birdDirClose(BirdDir_T *pDir);
140
141#define opendir birdDirOpen
142#define readdir birdDirRead
143#define telldir birdDirTell
144#define seekdir birdDirSeek
145#define rewinddir(a_pDir, a_offDir) birdDirSeek(a_pDir, 0)
146#define closedir birdDirClose
147#define _D_NAMLEN(a_pEnt) ((a_pEnt)->d_namlen)
148typedef BirdDir_T DIR;
149
150#endif
151
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette