VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/dir.h@ 17610

Last change on this file since 17610 was 14059, checked in by vboxsync, 16 years ago

IPRT: internal/dir.h: some unsigned -> size_t to keep MSC silent.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1/* $Id: dir.h 14059 2008-11-10 23:05:44Z vboxsync $ */
2/** @file
3 * IPRT - Internal Header for RTDir.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31#ifndef ___internal_dir_h
32#define ___internal_dir_h
33
34#include <iprt/cdefs.h>
35#include <iprt/types.h>
36#include "internal/magics.h"
37
38
39/**
40 * Filter a the filename in the against a filter.
41 *
42 * @returns true if the name matches the filter.
43 * @returns false if the name doesn't match filter.
44 * @param pDir The directory handle.
45 * @param pszName The path to match to the filter.
46 */
47typedef DECLCALLBACK(bool) FNRTDIRFILTER(PRTDIR pDir, const char *pszName);
48/** Pointer to a filter function. */
49typedef FNRTDIRFILTER *PFNRTDIRFILTER;
50
51
52/**
53 * Open directory.
54 */
55typedef struct RTDIR
56{
57 /** Magic value, RTDIR_MAGIC. */
58 uint32_t u32Magic;
59 /** The type of filter that's to be applied to the directory listing. */
60 RTDIRFILTER enmFilter;
61 /** The filter function. */
62 PFNRTDIRFILTER pfnFilter;
63 /** The filter Code Point string.
64 * This is allocated in the same block as this structure. */
65 PRTUNICP puszFilter;
66 /** The number of Code Points in the filter string. */
67 size_t cucFilter;
68 /** The filter string.
69 * This is allocated in the same block as this structure, thus the const. */
70 const char *pszFilter;
71 /** The length of the filter string. */
72 size_t cchFilter;
73 /** Normalized path to the directory including a trailing slash.
74 * We keep this around so we can query more information if required (posix).
75 * This is allocated in the same block as this structure, thus the const. */
76 const char *pszPath;
77 /** The length of the path. */
78 size_t cchPath;
79 /** Set to indicate that the Data member contains unread data. */
80 bool fDataUnread;
81#ifndef RT_DONT_CONVERT_FILENAMES
82 /** Pointer to the converted filename.
83 * This can be NULL. */
84 char *pszName;
85 /** The length of the converted filename. */
86 size_t cchName;
87#endif
88
89#ifdef RT_OS_WINDOWS
90 /** Handle to the opened directory search. */
91 HANDLE hDir;
92 /** Find data buffer.
93 * fDataUnread indicates valid data. */
94# ifdef RT_DONT_CONVERT_FILENAMES
95 WIN32_FIND_DATAA Data;
96# else
97 WIN32_FIND_DATAW Data;
98# endif
99
100#else /* 'POSIX': */
101 /** What opendir() returned. */
102 DIR *pDir;
103 /** The max size of the d_name member.
104 * This includes the 0 terminator of course.*/
105 size_t cbMaxName;
106 /** Find data buffer.
107 * fDataUnread indicates valid data. */
108 struct dirent Data;
109#endif
110} RTDIR;
111
112
113/**
114 * Validates a directory handle.
115 * @returns true if valid.
116 * @returns false if valid after having bitched about it first.
117 */
118DECLINLINE(bool) rtDirValidHandle(PRTDIR pDir)
119{
120 AssertMsgReturn(VALID_PTR(pDir), ("%p\n", pDir), false);
121 AssertMsgReturn(pDir->u32Magic == RTDIR_MAGIC, ("%#RX32\n", pDir->u32Magic), false);
122 return true;
123}
124
125
126/**
127 * Initialize the OS specific part of the handle and open the directory.
128 * Called by rtDirOpenCommon().
129 *
130 * @returns IPRT status code.
131 * @param pDir The directory to open. The pszPath member contains the
132 * path to the directory.
133 * @param pszPathBuf Pointer to a RTPATH_MAX sized buffer containing pszPath.
134 * Find-first style systems can use this to setup the
135 * wildcard expression.
136 */
137int rtOpenDirNative(PRTDIR pDir, char *pszPathBuf);
138
139#endif
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