# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1629096688 0 # Node ID 45a6b33a003a2caaf964dd07953c710ed1edf71a # Parent 28ca1e59e76f2713ce3ba25e526f19a7548a58f2 Linux: Isolate linux/android specific code in #ifdef __linux__ So on unrecognized platforms the functions should just return 0. This should allow Android to get filesystem info through Linux calls. diff -r 28ca1e59e76f -r 45a6b33a003a dwcompat.c --- a/dwcompat.c Fri Aug 13 22:19:45 2021 +0000 +++ b/dwcompat.c Mon Aug 16 06:51:28 2021 +0000 @@ -22,7 +22,7 @@ #include #include #include -#else +#elif defined(__linux__) #include #include #endif @@ -169,7 +169,7 @@ fclose(fp); } return 0; -#elif !defined(__ANDROID__) +#elif defined(__linux__) FILE *fp = setmntent(MOUNTED, "r"); struct mntent mnt; struct statfs sfs; @@ -277,7 +277,7 @@ fclose(fp); } return 0; -#elif !defined(__ANDROID__) +#elif defined(__linux__) FILE *fp = setmntent(MOUNTED, "r"); struct mntent mnt; char buffer[1024]; @@ -327,7 +327,6 @@ DosError(FERR_ENABLEHARDERR); if (rc == NO_ERROR) return 1; - #elif defined(__WIN32__) || defined(WINNT) char buffer[10] = "C:\\", volname[100]; DWORD spc, bps, fc; @@ -348,7 +347,6 @@ return 1; index++; } - return 0; #elif defined(__sun__) FILE *fp = fopen("/etc/mnttab", "r"); struct mnttab mnt; @@ -373,7 +371,7 @@ } fclose(fp); } -#elif !defined(__ANDROID__) +#elif defined(__linux__) FILE *fp = setmntent(MOUNTED, "r"); struct mntent mnt; char buffer[1024]; @@ -406,7 +404,7 @@ void API getfsname(int drive, char *buf, int len) { -#if defined(__UNIX__) || defined(__MAC__) || defined(__IOS__) +#if defined(__UNIX__) || defined(__MAC__) || defined(__IOS__) || defined(__ANDROID__) #if defined(__FreeBSD__) || defined(__MAC__) || defined(__IOS__) struct statfs *fsp = NULL; int entries, index = 1; @@ -438,7 +436,7 @@ } fclose(fp); } -#else +#elif defined(__linux__) FILE *fp = setmntent(MOUNTED, "r"); struct mntent mnt; char buffer[1024]; @@ -703,7 +701,7 @@ static int locale_number = -1, locale_count = 0; static char **locale_text = NULL; -void _compat_free_locale(void) +void _dwcompat_free_locale(void) { if(locale_text) { @@ -719,7 +717,7 @@ } } -int _stripcrlf(char *buf) +int _dwcompat_stripcrlf(char *buf) { int z, len = (int)strlen(buf); @@ -743,7 +741,7 @@ static char text[1025]; int count = 0; - _compat_free_locale(); + _dwcompat_free_locale(); if(fp) { @@ -755,7 +753,7 @@ while(!feof(fp)) { - if(fgets(text, 1024, fp) && _stripcrlf(text) && + if(fgets(text, 1024, fp) && _dwcompat_stripcrlf(text) && strncasecmp(text, "LOCALE=", 7) == 0) { if(current > -1) diff -r 28ca1e59e76f -r 45a6b33a003a dwcompat.h --- a/dwcompat.h Fri Aug 13 22:19:45 2021 +0000 +++ b/dwcompat.h Mon Aug 16 06:51:28 2021 +0000 @@ -11,6 +11,7 @@ #else #define HAVE_DIRENT_H 1 #define HAVE_PIPE 1 +#define HAVE_VSNPRINTF 1 #endif /* Attempt to include 64 bit file functions on various unix flavors */