openMSX
win32-dirent.hh
Go to the documentation of this file.
1#ifndef WIN32_DIRENT_HH
2#define WIN32_DIRENT_HH
3
4/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/* Directory stream type.
22 The miscellaneous Unix `readdir' implementations read directory data
23 into a buffer and return `struct dirent *' pointers into it. */
24
25// NB: Taken from http://www.koders.com/c/fid5F00BC983E0F005E15E8E590E461D363F6146CEB.aspx
26// Slightly reformatted/simplified to fit openMSX coding style.
27
28#ifdef _WIN32
29
30#include <sys/types.h>
31#include <basetsd.h> // for INT_PTR
32#include <string>
33
34namespace openmsx {
35
36struct dirstream
37{
38 INT_PTR fd; // File descriptor.
39 void* data; // Directory block.
40 off_t filepos; // Position of next entry to read.
41 std::wstring mask; // Initial file mask.
42};
43
44struct dirent
45{
46 long d_ino;
47 off_t d_off;
48 unsigned short d_reclen;
49 unsigned char d_type; // always DT_UNKNOWN in current implementation
50 char d_name[256];
51};
52
53inline constexpr unsigned char DT_UNKNOWN = 0;
54inline constexpr unsigned char DT_REG = 1;
55inline constexpr unsigned char DT_DIR = 2;
56
57#define d_fileno d_ino // Backwards compatibility.
58
59// This is the data type of directory stream objects.
60// The actual structure is opaque to users.
61using DIR = struct dirstream;
62
63DIR* opendir(const char* name);
64struct dirent* readdir(DIR* dir);
65int closedir(DIR* dir);
66void rewinddir(DIR* dir);
67void seekdir(DIR* dir, off_t offset);
68off_t telldir(DIR* dir);
69//int dirfd(DIR* dir);
70
71} // namespace openmsx
72
73#endif
74
75#endif // WIN32_DIRENT_HH
This file implemented 3 utility functions:
Definition Autofire.cc:9