VirtualBox

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

Last change on this file since 3598 was 3005, checked in by bird, 8 years ago

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1/* $Id: ntdir.h 3005 2016-11-06 00:07:37Z 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/** Set if the BirdDir_T structure is statically allocated. */
93#define BIRDDIR_F_STATIC_ALLOC 8U
94/** @} */
95
96typedef struct BirdDir
97{
98 /** Magic value. */
99 unsigned uMagic;
100 /** Flags. */
101 unsigned fFlags;
102 /** The directory handle. */
103 void *pvHandle;
104 /** The device number (st_dev). */
105 unsigned __int64 uDev;
106 /** The current position. */
107 long offPos;
108
109 /** Set if we haven't yet read anything. */
110 int fFirst;
111 /** Set if we have data in the buffer. */
112 int fHaveData;
113 /** The info type we're querying. */
114 int iInfoClass;
115 /** The current buffer position. */
116 unsigned offBuf;
117 /** The number of bytes allocated for pabBuf. */
118 unsigned cbBuf;
119 /** Buffer of size cbBuf. */
120 unsigned char *pabBuf;
121
122 /** Static directory entry. */
123 union
124 {
125 BirdDirEntry_T DirEntry;
126 BirdDirEntryW_T DirEntryW;
127 } u;
128} BirdDir_T;
129/** Magic value for BirdDir. */
130#define BIRD_DIR_MAGIC 0x19731120
131
132
133BirdDir_T *birdDirOpen(const char *pszPath);
134BirdDir_T *birdDirOpenExtraInfo(const char *pszPath);
135BirdDir_T *birdDirOpenExW(void *hRoot, const wchar_t *pwszPath, const wchar_t *pwszFilter, unsigned fFlags);
136BirdDir_T *birdDirOpenFromHandle(void *hDir, const void *pvReserved, unsigned fFlags);
137BirdDir_T *birdDirOpenFromHandleWithReuse(BirdDir_T *pDir, void *pvHandle, const void *pvReserved, unsigned fFlags);
138BirdDirEntry_T *birdDirRead(BirdDir_T *pDir);
139BirdDirEntryW_T *birdDirReadW(BirdDir_T *pDir);
140long birdDirTell(BirdDir_T *pDir);
141void birdDirSeek(BirdDir_T *pDir, long offDir);
142int birdDirClose(BirdDir_T *pDir);
143
144#define opendir birdDirOpen
145#define readdir birdDirRead
146#define telldir birdDirTell
147#define seekdir birdDirSeek
148#define rewinddir(a_pDir, a_offDir) birdDirSeek(a_pDir, 0)
149#define closedir birdDirClose
150#define _D_NAMLEN(a_pEnt) ((a_pEnt)->d_namlen)
151typedef BirdDir_T DIR;
152
153#endif
154
Note: See TracBrowser for help on using the repository browser.

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