VirtualBox

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

Last change on this file since 6696 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1/* $Id: dir.h 5999 2007-12-07 15:05:06Z vboxsync $ */
2/** @file
3 * innotek Portable Runtime - Internal Header for RTDir.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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
27#ifndef ___internal_dir_h
28#define ___internal_dir_h
29
30#include <iprt/cdefs.h>
31#include <iprt/types.h>
32#include "internal/magics.h"
33
34
35/**
36 * Filter a the filename in the against a filter.
37 *
38 * @returns true if the name matches the filter.
39 * @returns false if the name doesn't match filter.
40 * @param pDir The directory handle.
41 * @param pszName The path to match to the filter.
42 */
43typedef DECLCALLBACK(bool) FNRTDIRFILTER(PRTDIR pDir, const char *pszName);
44/** Pointer to a filter function. */
45typedef FNRTDIRFILTER *PFNRTDIRFILTER;
46
47
48/**
49 * Open directory.
50 */
51typedef struct RTDIR
52{
53 /** Magic value, RTDIR_MAGIC. */
54 uint32_t u32Magic;
55 /** The type of filter that's to be applied to the directory listing. */
56 RTDIRFILTER enmFilter;
57 /** The filter function. */
58 PFNRTDIRFILTER pfnFilter;
59 /** The filter Code Point string.
60 * This is allocated in the same block as this structure. */
61 PRTUNICP puszFilter;
62 /** The number of Code Points in the filter string. */
63 size_t cucFilter;
64 /** The filter string.
65 * This is allocated in the same block as this structure, thus the const. */
66 const char *pszFilter;
67 /** The length of the filter string. */
68 unsigned cchFilter;
69 /** Normalized path to the directory including a trailing slash.
70 * We keep this around so we can query more information if required (posix).
71 * This is allocated in the same block as this structure, thus the const. */
72 const char *pszPath;
73 /** The length of the path. */
74 unsigned cchPath;
75 /** Set to indicate that the Data member contains unread data. */
76 bool fDataUnread;
77#ifndef RT_DONT_CONVERT_FILENAMES
78 /** Pointer to the converted filename.
79 * This can be NULL. */
80 char *pszName;
81 /** The length of the converted filename. */
82 unsigned cchName;
83#endif
84
85#ifdef RT_OS_WINDOWS
86 /** Handle to the opened directory search. */
87 HANDLE hDir;
88 /** Find data buffer.
89 * fDataUnread indicates valid data. */
90# ifdef RT_DONT_CONVERT_FILENAMES
91 WIN32_FIND_DATAA Data;
92# else
93 WIN32_FIND_DATAW Data;
94# endif
95
96#else /* 'POSIX': */
97 /** What opendir() returned. */
98 DIR *pDir;
99 /** Find data buffer.
100 * fDataUnread indicates valid data. */
101 struct dirent Data;
102#endif
103} RTDIR;
104
105
106/**
107 * Validates a directory handle.
108 * @returns true if valid.
109 * @returns false if valid after having bitched about it first.
110 */
111DECLINLINE(bool) rtDirValidHandle(PRTDIR pDir)
112{
113 AssertMsgReturn(VALID_PTR(pDir), ("%p\n", pDir), false);
114 AssertMsgReturn(pDir->u32Magic == RTDIR_MAGIC, ("%#RX32\n", pDir->u32Magic), false);
115 return true;
116}
117
118
119/**
120 * Initialize the OS specific part of the handle and open the directory.
121 * Called by rtDirOpenCommon().
122 *
123 * @returns IPRT status code.
124 * @param pDir The directory to open. The pszPath member contains the
125 * path to the directory.
126 * @param pszPathBuf Pointer to a RTPATH_MAX sized buffer containing pszPath.
127 * Find-first style systems can use this to setup the
128 * wildcard expression.
129 */
130int rtOpenDirNative(PRTDIR pDir, char *pszPathBuf);
131
132#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