From 2d32a07198daea117687ef595c941204251e461a Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Mon, 10 Jan 2011 14:32:42 +0000 Subject: [PATCH] SDL OS/2 fixes [K.O. Myung-Hun] --- .gitattributes | 1 + src/emu/debug/debugcpu.c | 2 +- src/osd/sdl/sdlos_os2.c | 66 +++++++++++++++++++++++++++++++++++++++ src/osd/sdl/sdlptty_os2.c | 35 +++++++++++++++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 src/osd/sdl/sdlptty_os2.c diff --git a/.gitattributes b/.gitattributes index 4941b1c24c7..331bd35a7e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4414,6 +4414,7 @@ src/osd/sdl/sdlos_unix.c svneol=native#text/plain src/osd/sdl/sdlos_win32.c svneol=native#text/plain src/osd/sdl/sdlprefix.h svneol=native#text/plain src/osd/sdl/sdlptty_macosx.c svneol=native#text/plain +src/osd/sdl/sdlptty_os2.c svneol=native#text/plain src/osd/sdl/sdlptty_unix.c svneol=native#text/plain src/osd/sdl/sdlptty_win32.c svneol=native#text/plain src/osd/sdl/sdlsocket.c svneol=native#text/plain diff --git a/src/emu/debug/debugcpu.c b/src/emu/debug/debugcpu.c index db2fac0d4cf..ee2b85a9d5c 100644 --- a/src/emu/debug/debugcpu.c +++ b/src/emu/debug/debugcpu.c @@ -51,7 +51,7 @@ #include "xmlfile.h" #include #include -#ifdef SDLMAME_FREEBSD +#if defined(SDLMAME_FREEBSD) || defined(SDLMAME_OS2) # undef tolower #endif diff --git a/src/osd/sdl/sdlos_os2.c b/src/osd/sdl/sdlos_os2.c index a3fc8065bc7..fa9e1c11c1a 100644 --- a/src/osd/sdl/sdlos_os2.c +++ b/src/osd/sdl/sdlos_os2.c @@ -16,6 +16,7 @@ #include #include #include +#include #define INCL_DOS #include @@ -240,3 +241,68 @@ char *osd_get_clipboard_text(void) return result; } + +//============================================================ +// osd_stat +//============================================================ + +osd_directory_entry *osd_stat(const char *path) +{ + int err; + osd_directory_entry *result = NULL; + struct stat st; + + err = stat(path, &st); + + if( err == -1) return NULL; + + // create an osd_directory_entry; be sure to make sure that the caller can + // free all resources by just freeing the resulting osd_directory_entry + result = (osd_directory_entry *) osd_malloc(sizeof(*result) + strlen(path) + 1); + strcpy(((char *) result) + sizeof(*result), path); + result->name = ((char *) result) + sizeof(*result); + result->type = S_ISDIR(st.st_mode) ? ENTTYPE_DIR : ENTTYPE_FILE; + result->size = (UINT64)st.st_size; + + return result; +} + +//============================================================ +// osd_get_volume_name +//============================================================ + +const char *osd_get_volume_name(int idx) +{ + static char szDrive[] = "A:\\"; + + ULONG ulCurDisk; + ULONG ulDriveMap; + + DosQueryCurrentDisk(&ulCurDisk, &ulDriveMap); + + szDrive[ 0 ] = 'A'; + while(idx--) { + do + { + ulDriveMap >>= 1; + szDrive[ 0 ]++; + } while(ulDriveMap && (ulDriveMap & 1) == 0); + if (!ulDriveMap) return NULL; + } + + return szDrive; +} + +//============================================================ +// osd_get_full_path +//============================================================ + +file_error osd_get_full_path(char **dst, const char *path) +{ + *dst = (char *)osd_malloc(CCHMAXPATH + 1); + if (*dst == NULL) + return FILERR_OUT_OF_MEMORY; + + _abspath(*dst, path, CCHMAXPATH + 1); + return FILERR_NONE; diff --git a/src/osd/sdl/sdlptty_os2.c b/src/osd/sdl/sdlptty_os2.c new file mode 100644 index 00000000000..edb0fbb2175 --- /dev/null +++ b/src/osd/sdl/sdlptty_os2.c @@ -0,0 +1,35 @@ +//============================================================ +// +// sdlptty_os2 - SDL psuedo tty access functions +// (OS/2 has no pttys - maybe named pipes?) +// +// Copyright (c) 1996-2010, Nicola Salmoria and the MAME Team. +// Visit http://mamedev.org for licensing and usage restrictions. +// +// SDLMAME by Olivier Galibert and R. Belmont +// +//============================================================ + +#include "sdlfile.h" + +const char *sdlfile_ptty_identifier = ""; + +file_error sdl_open_ptty(const char *path, UINT32 openflags, osd_file **file, UINT64 *filesize) +{ + return FILERR_ACCESS_DENIED; +} + +file_error sdl_read_ptty(osd_file *file, void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) +{ + return FILERR_ACCESS_DENIED; +} + +file_error sdl_write_ptty(osd_file *file, const void *buffer, UINT64 offset, UINT32 count, UINT32 *actual) +{ + return FILERR_ACCESS_DENIED; +} + +file_error sdl_close_ptty(osd_file *file) +{ + return FILERR_ACCESS_DENIED; +}