| version 1.5, 2003/06/22 18:40:33 |
version 1.6, 2003/06/27 02:18:30 |
|
|
| * |
* |
| * Changelog: |
* Changelog: |
| * 19/05/2003 - created |
* 19/05/2003 - created |
| * |
* 27/06/2003 - added Win32 support |
| */ |
*/ |
| |
|
| /* $Platon: games/3do-view/dir.c,v 1.4 2003/05/20 23:37:29 nepto Exp $ */ |
/* $Platon: games/3do-view/dir.c,v 1.5 2003/06/22 18:40:33 nepto Exp $ */ |
| |
|
| #include <string.h> |
#include <string.h> |
| #include <stdlib.h> |
#include <stdlib.h> |
|
|
| /* If current directory cannot be opened, fallback to root directory. */ |
/* If current directory cannot be opened, fallback to root directory. */ |
| #endif |
#endif |
| |
|
| |
#if PLATON_SYSTEM_WIN32 |
| |
# include <windows.h> |
| |
# define DIR_DIRECTORY_CONDITION (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) |
| |
# define DIR_FILENAME (FindFileData.cFileName) |
| |
# define DIR_NEXT_CONDITION (FindNextFile(hFind, &FindFileData)) |
| |
# define DIR_INIT_CONDITION ((hFind = FindFirstFile("*.*", &FindFileData)) != INVALID_HANDLE_VALUE) |
| |
#endif |
| |
|
| #if PLATON_SYSTEM_MSDOS |
#if PLATON_SYSTEM_MSDOS |
| # include <dos.h> |
# include <dos.h> |
| # include <dir.h> |
# include <dir.h> |
| # define DIR_DIRECTORY_CONDITION (ffblk.ff_attrib & FA_DIREC) |
# define DIR_DIRECTORY_CONDITION (ffblk.ff_attrib & FA_DIREC) |
| # define DIR_FILENAME (ffblk.ff_name) |
# define DIR_FILENAME (ffblk.ff_name) |
| |
# define DIR_NEXT_CONDITION (! findnext(&ffblk)) |
| # define DIR_INIT_CONDITION (! (findfirst("*.*", &ffblk, \ |
# define DIR_INIT_CONDITION (! (findfirst("*.*", &ffblk, \ |
| FA_DIREC + FA_HIDDEN + FA_RDONLY + FA_SYSTEM))) |
FA_DIREC + FA_HIDDEN + FA_RDONLY + FA_SYSTEM))) |
| #endif |
#endif |
| Line 56 void get_directories_and_files(char ***d |
|
| Line 65 void get_directories_and_files(char ***d |
|
| struct dirent *dp; |
struct dirent *dp; |
| struct stat st; |
struct stat st; |
| #endif |
#endif |
| |
#if PLATON_SYSTEM_WIN32 |
| |
WIN32_FIND_DATA FindFileData; |
| |
HANDLE hFind; |
| |
#endif |
| #if PLATON_SYSTEM_MSDOS |
#if PLATON_SYSTEM_MSDOS |
| struct ffblk ffblk; |
struct ffblk ffblk; |
| #endif |
#endif |
| Line 76 void get_directories_and_files(char ***d |
|
| Line 89 void get_directories_and_files(char ***d |
|
| if (stat(DIR_FILENAME, &st)) |
if (stat(DIR_FILENAME, &st)) |
| continue; |
continue; |
| #endif |
#endif |
| #if PLATON_SYSTEM_MSDOS |
#if PLATON_SYSTEM_MSDOS || PLATON_SYSTEM_WIN32 |
| do { |
do { |
| #endif |
#endif |
| |
|
| Line 107 void get_directories_and_files(char ***d |
|
| Line 120 void get_directories_and_files(char ***d |
|
| } |
} |
| closedir(dirp); |
closedir(dirp); |
| #endif |
#endif |
| #if PLATON_SYSTEM_MSDOS |
#if PLATON_SYSTEM_MSDOS || PLATON_SYSTEM_WIN32 |
| } while (! findnext(&ffblk)); |
} while (DIR_NEXT_CONDITION); |
| #endif |
#endif |
| |
|
| if (*directories != NULL) |
if (*directories != NULL) |