From 58dd553d00287bce9fedca55641c66d5c912e1b7 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 18 Sep 2005 01:14:23 +0000 Subject: [PATCH] Loads from non-cwd now --- compiler/amxxpc/amxxpc.cpp | 25 ++++++++++++++++++++++--- compiler/amxxpc/amxxpc.h | 6 +++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/compiler/amxxpc/amxxpc.cpp b/compiler/amxxpc/amxxpc.cpp index e405893c..9c355b58 100755 --- a/compiler/amxxpc/amxxpc.cpp +++ b/compiler/amxxpc/amxxpc.cpp @@ -30,7 +30,11 @@ int main(int argc, char **argv) #endif #ifdef __linux__ - HINSTANCE lib = dlmount("./amxxpc32.so"); + HINSTANCE lib = NULL; + if (FileExists("./amxxpc32.so")) + lib = dlmount("./amxxpc32.so"); + else + lib = dlmount("amxxpc32.so"); #else HINSTANCE lib = dlmount("amxxpc32.dll"); #endif @@ -101,9 +105,12 @@ int main(int argc, char **argv) unlink(file); - HINSTANCE lib64 = 0; + HINSTANCE lib64 = NULL; #ifdef __linux__ - lib64 = dlmount("./amxxpc64.so"); + if (FileExists("./amxxpc64.so")) + lib64 = dlmount("./amxxpc64.so"); + else + lib64 = dlmount("amxxpc64.so"); #else lib64 = dlmount("amxxpc64.dll"); #endif @@ -374,3 +381,15 @@ void show_help() printf("\t-p set name of \"prefix\" file\n"); printf("\t-r[name] write cross reference report to console or to specified file\n"); } + +#ifdef __linux__ +bool FileExists(const char *file) +{ + FILE *fp = fopen(file, "rb"); + if (!fp) + return false; + fclose(fp); + return true; +} +#endif + diff --git a/compiler/amxxpc/amxxpc.h b/compiler/amxxpc/amxxpc.h index cf662980..a04130c5 100755 --- a/compiler/amxxpc/amxxpc.h +++ b/compiler/amxxpc/amxxpc.h @@ -1,7 +1,7 @@ #ifndef _AMXXSC_INCLUDE_H #define _AMXXSC_INCLUDE_H -#define VERSION_STRING "1.56-300" +#define VERSION_STRING "1.60-300" #define VERSION 03000 #define MAGIC_HEADER 0x414D5842 #define MAGIC_HEADER2 0x414D5858 @@ -67,4 +67,8 @@ struct BinPlugin int32_t offs; //file offset }; +#ifdef __linux__ +bool FileExists(const char *file); +#endif + #endif //_AMXXSC_INCLUDE_H