From a7f3cf151ac97bc84d7652b457a414234affaf0c Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 23 Jun 2005 18:34:30 +0000 Subject: [PATCH] Add patch from Espen Wiborg. Adding dirname for win32. fix compilation problem. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2224 --- src/dos/cdrom_image.cpp | 27 ++++++++++++++++++++------- src/hardware/joystick.cpp | 3 ++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/dos/cdrom_image.cpp b/src/dos/cdrom_image.cpp index 4684102b..648c43f6 100644 --- a/src/dos/cdrom_image.cpp +++ b/src/dos/cdrom_image.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: cdrom_image.cpp,v 1.7 2005-04-15 15:58:07 qbix79 Exp $ */ +/* $Id: cdrom_image.cpp,v 1.8 2005-06-23 18:34:29 qbix79 Exp $ */ #include #include @@ -32,6 +32,8 @@ #if !defined(WIN32) #include +#else +#include #endif using namespace std; @@ -387,6 +389,23 @@ bool CDROM_Interface_Image::CanReadPVD(TrackFile *file, int sectorSize, bool mod return (pvd[0] == 1 && !strncmp((char*)(&pvd[1]), "CD001", 5) && pvd[6] == 1); } +#if defined(WIN32) +static string dirname(const char * file) { + char * sep = strrchr(file, '\\'); + if (sep == NULL) + sep = strrchr(file, '/'); + if (sep == NULL) + return ""; + else { + int len = (int)(sep - file); + char tmp[MAX_FILENAME_LENGTH]; + strncpy(tmp, file, len); + tmp[len] = '\0'; + return tmp; + } +} +#endif + bool CDROM_Interface_Image::LoadCueSheet(char *cuefile) { Track track = {0, 0, 0, 0, 0, 0, false, NULL}; @@ -399,11 +418,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile) bool canAddTrack = false; char tmp[MAX_FILENAME_LENGTH]; // dirname can change its argument strncpy(tmp, cuefile, MAX_FILENAME_LENGTH); -#if defined(WIN32) - string pathname(""); -#else string pathname(dirname(tmp)); -#endif ifstream in; in.open(cuefile, ios::in); if (in.fail()) return false; @@ -572,13 +587,11 @@ bool CDROM_Interface_Image::GetRealFileName(string &filename, string &pathname) if (stat(filename.c_str(), &test) == 0) return true; // check if file with path relative to cue file exists -#if !defined(WIN32) string tmpstr(pathname + "/" + filename); if (stat(tmpstr.c_str(), &test) == 0) { filename = tmpstr; return true; } -#endif // finally check if file is in a dosbox local drive char fullname[CROSS_LEN]; char tmp[CROSS_LEN]; diff --git a/src/hardware/joystick.cpp b/src/hardware/joystick.cpp index 591e344b..1f6d9c12 100644 --- a/src/hardware/joystick.cpp +++ b/src/hardware/joystick.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: joystick.cpp,v 1.12 2005-06-13 14:48:02 qbix79 Exp $ */ +/* $Id: joystick.cpp,v 1.13 2005-06-23 18:34:30 qbix79 Exp $ */ #include #include "dosbox.h" @@ -24,6 +24,7 @@ #include "setup.h" #include "joystick.h" #include "pic.h" +#include "support.h" #define RANGE 64 #define TIMEOUT 10