VirtualBox

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

Last change on this file since 2013 was 1816, checked in by vboxsync, 18 years ago

moved magics to a common header to avoid duplicating the same defines all over the place.

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