diff options
-rw-r--r-- | uisimulator/common/file.h | 5 | ||||
-rw-r--r-- | uisimulator/common/io.c | 5 | ||||
-rw-r--r-- | uisimulator/win32/dir-win32.c | 91 | ||||
-rw-r--r-- | uisimulator/win32/dir-win32.h | 47 | ||||
-rw-r--r-- | uisimulator/win32/rockbox.dsp | 6 |
5 files changed, 151 insertions, 3 deletions
diff --git a/uisimulator/common/file.h b/uisimulator/common/file.h index 8d91b61831..0e50031556 100644 --- a/uisimulator/common/file.h +++ b/uisimulator/common/file.h | |||
@@ -32,6 +32,11 @@ | |||
32 | #ifdef WIN32 | 32 | #ifdef WIN32 |
33 | #ifndef _commit | 33 | #ifndef _commit |
34 | extern int _commit( int handle ); | 34 | extern int _commit( int handle ); |
35 | |||
36 | #ifdef _MSC_VER | ||
37 | typedef unsigned int mode_t; | ||
38 | #endif | ||
39 | |||
35 | #endif | 40 | #endif |
36 | #endif | 41 | #endif |
37 | 42 | ||
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 745e417fa6..e321c1adcc 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -27,8 +27,13 @@ | |||
27 | #elif !defined(WIN32) | 27 | #elif !defined(WIN32) |
28 | #include <sys/vfs.h> | 28 | #include <sys/vfs.h> |
29 | #endif | 29 | #endif |
30 | |||
31 | #ifndef _MSC_VER | ||
30 | #include <dirent.h> | 32 | #include <dirent.h> |
31 | #include <unistd.h> | 33 | #include <unistd.h> |
34 | #else | ||
35 | #include "dir-win32.h" | ||
36 | #endif | ||
32 | 37 | ||
33 | #include <fcntl.h> | 38 | #include <fcntl.h> |
34 | #include "debug.h" | 39 | #include "debug.h" |
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 | ||
30 | DIR *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 | ||
66 | int 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 | ||
76 | struct 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 | } | ||
diff --git a/uisimulator/win32/dir-win32.h b/uisimulator/win32/dir-win32.h new file mode 100644 index 0000000000..888a83767a --- /dev/null +++ b/uisimulator/win32/dir-win32.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Björn Stenberg | ||
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 | #ifndef _DIR_WIN32_H_ | ||
20 | #define _DIR_WIN32_H_ | ||
21 | |||
22 | #include <stdbool.h> | ||
23 | #include "file.h" | ||
24 | |||
25 | struct dirent { | ||
26 | unsigned char d_name[MAX_PATH]; | ||
27 | int attribute; | ||
28 | int size; | ||
29 | int startcluster; | ||
30 | }; | ||
31 | |||
32 | typedef struct | ||
33 | { | ||
34 | struct dirent fd; | ||
35 | int handle; | ||
36 | } DIR; | ||
37 | |||
38 | extern DIR* opendir(const char* name); | ||
39 | extern int closedir(DIR* dir); | ||
40 | extern int mkdir(const char* name); | ||
41 | extern int rmdir(const char* name); | ||
42 | |||
43 | extern struct dirent* readdir(DIR* dir); | ||
44 | |||
45 | #define S_ISDIR(x) (((x) & _S_IFDIR) == _S_IFDIR) | ||
46 | |||
47 | #endif | ||
diff --git a/uisimulator/win32/rockbox.dsp b/uisimulator/win32/rockbox.dsp index 8e1a092c5c..4c54889c97 100644 --- a/uisimulator/win32/rockbox.dsp +++ b/uisimulator/win32/rockbox.dsp | |||
@@ -43,7 +43,7 @@ RSC=rc.exe | |||
43 | # PROP Ignore_Export_Lib 0 | 43 | # PROP Ignore_Export_Lib 0 |
44 | # PROP Target_Dir "" | 44 | # PROP Target_Dir "" |
45 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c | 45 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c |
46 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../firmware/export" /I "../../firmware/drivers" /I "../../firmware/common" /I "../common" /I "../win32" /I "../../apps" /I "../../apps/recorder" /D "HAVE_LCD_BITMAP" /D "HAVE_RECORDER_KEYPAD" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_CONFIG_H" /D "GETTIMEOFDAY_TWO_ARGS" /D "SIMULATOR" /D "HAVE_RTC" /D APPSVERSION=\"WIN32SIM\" /FR /YX /FD /GZ /c | 46 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../win32" /I "../../apps/recorder" /I "../../firmware/export" /I "../../firmware/drivers" /I "../../firmware/common" /I "../common" /I "../../apps" /D "HAVE_LCD_BITMAP" /D "HAVE_RECORDER_KEYPAD" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_CONFIG_H" /D "GETTIMEOFDAY_TWO_ARGS" /D "SIMULATOR" /D "HAVE_RTC" /D APPSVERSION=\"WIN32SIM\" /FR /YX /FD /GZ /c |
47 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | 47 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 |
48 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | 48 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 |
49 | # ADD BASE RSC /l 0x407 /d "_DEBUG" | 49 | # ADD BASE RSC /l 0x407 /d "_DEBUG" |
@@ -69,7 +69,7 @@ LINK32=link.exe | |||
69 | # PROP Ignore_Export_Lib 0 | 69 | # PROP Ignore_Export_Lib 0 |
70 | # PROP Target_Dir "" | 70 | # PROP Target_Dir "" |
71 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c | 71 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c |
72 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../firmware/export" /I "../../firmware/drivers" /I "../../firmware/common" /I "../common" /I "../win32" /I "../../apps" /I "../../apps/player" /D "HAVE_LCD_CHARCELLS" /D "HAVE_PLAYER_KEYPAD" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_CONFIG_H" /D "GETTIMEOFDAY_TWO_ARGS" /D "SIMULATOR" /D APPSVERSION=\"WIN32SIM\" /FR /YX /FD /GZ /c | 72 | # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../win32" /I "../../apps/player" /I "../../firmware/export" /I "../../firmware/drivers" /I "../../firmware/common" /I "../common" /I "../../apps" /D "HAVE_LCD_CHARCELLS" /D "HAVE_PLAYER_KEYPAD" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_CONFIG_H" /D "GETTIMEOFDAY_TWO_ARGS" /D "SIMULATOR" /D APPSVERSION=\"WIN32SIM\" /FR /YX /FD /GZ /c |
73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | 73 | # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 |
74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | 74 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 |
75 | # ADD BASE RSC /l 0x407 /d "_DEBUG" | 75 | # ADD BASE RSC /l 0x407 /d "_DEBUG" |
@@ -478,7 +478,7 @@ SOURCE="..\common\font-player.c" | |||
478 | # End Source File | 478 | # End Source File |
479 | # Begin Source File | 479 | # Begin Source File |
480 | 480 | ||
481 | SOURCE=.\io.c | 481 | SOURCE=..\common\io.c |
482 | # End Source File | 482 | # End Source File |
483 | # Begin Source File | 483 | # Begin Source File |
484 | 484 | ||