summaryrefslogtreecommitdiff
path: root/uisimulator/win32/dir-win32.c
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2004-06-14 07:00:50 +0000
committerHardeep Sidhu <dyp@pobox.com>2004-06-14 07:00:50 +0000
commitfb26bfb662e7939b6646d290ad658fe1bdbffc8e (patch)
tree6db2aa5049259834333885891f7af6903625cbe2 /uisimulator/win32/dir-win32.c
parent2dafebfe1698ee32cce48b9cf4cb3b59a17b295d (diff)
downloadrockbox-fb26bfb662e7939b6646d290ad658fe1bdbffc8e.tar.gz
rockbox-fb26bfb662e7939b6646d290ad658fe1bdbffc8e.zip
Fixed VC++ build.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4739 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/win32/dir-win32.c')
-rw-r--r--uisimulator/win32/dir-win32.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/uisimulator/win32/dir-win32.c b/uisimulator/win32/dir-win32.c
new file mode 100644
index 0000000000..6f14e798be
--- /dev/null
+++ b/uisimulator/win32/dir-win32.c
@@ -0,0 +1,91 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Felix Arends
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <io.h>
21#include <windows.h>
22#include <malloc.h>
23#include "dir-win32.h"
24
25// Directory operations
26//
27
28// opendir
29// open directory for scanning
30DIR *opendir (
31 const char *dirname // directory name
32 )
33{
34 DIR *p = (DIR*)malloc(sizeof(DIR));
35 struct _finddata_t fd;
36 unsigned int i;
37 char *s = (char*)malloc(strlen(dirname) + 5);
38 wsprintf (s, "%s", dirname);
39
40 for (i = 0; i < strlen(s); i++)
41 if (s[i] == '/')
42 s[i] = '\\';
43
44 if (s[i - 1] != '\\')
45 {
46 s[i] = '\\';
47 s[++i] = '\0';
48 }
49
50 OutputDebugString (s);
51
52 wsprintf (s, "%s*.*", s);
53
54 if ((p->handle = _findfirst (s, &fd)) == -1)
55 {
56 free (s);
57 free (p);
58 return 0;
59 }
60 free (s);
61 return p;
62}
63
64// closedir
65// close directory
66int closedir (
67 DIR *dir // previously opened dir search
68 )
69{
70 free(dir);
71 return 0;
72}
73
74// read dir
75// read next entry in directory
76struct dirent *readdir (
77 DIR *dir
78 )
79{
80 struct _finddata_t fd;
81 if (_findnext (dir->handle, &fd) == -1)
82 return 0;
83 memcpy (dir->fd.d_name, fd.name, 256);
84
85 dir->fd.attribute = fd.attrib & 0x3f;
86 dir->fd.size = fd.size;
87 dir->fd.startcluster = 0 ;
88
89
90 return &dir->fd;
91}