platform/shared/ruby/win32/win32.c in rhodes-3.5.1.12 vs platform/shared/ruby/win32/win32.c in rhodes-5.5.0

- old
+ new

@@ -10,10 +10,12 @@ * */ #include "ruby/ruby.h" #include "ruby/encoding.h" +#include "common/app_build_capabilities.h" + #include "dln.h" #include <fcntl.h> #include <process.h> #include <sys/stat.h> /* #include <sys/wait.h> */ @@ -24,30 +26,43 @@ #include <ctype.h> #include <windows.h> #include <winbase.h> #include <wincon.h> + +#ifndef _WIN32_WCE #include <share.h> +#endif #ifndef _WP8_LIB #include <shlobj.h> #endif +#if defined(APP_BUILD_CAPABILITY_WINXPE) +#define _WIN32_WCE +#endif + #ifndef _WIN32_WCE #include <mbstring.h> #if _MSC_VER >= 1400 #include <crtdbg.h> #include <rtcapi.h> #endif #endif //_WIN32_WCE #ifdef __MINGW32__ #include <mswsock.h> #endif + #include "ruby/win32.h" #include "win32/dir.h" + #define isdirsep(x) ((x) == '/' || (x) == '\\') +#if defined(APP_BUILD_CAPABILITY_WINXPE) +#include "wince/wince.h" +#endif + #undef stat #undef fclose #undef close #undef setsockopt @@ -656,20 +671,28 @@ // // Initialization stuff // void rb_w32_sysinit(int *argc, char ***argv) -{ +{ #if RT_VER >= 80 static void set_pioinfo_extra(void); +#if !defined(APP_BUILD_CAPABILITY_WINXPE) _CrtSetReportMode(_CRT_ASSERT, 0); +#endif + _set_invalid_parameter_handler(invalid_parameter); + _RTC_SetErrorFunc(rtc_error_handler); + +#if !defined(APP_BUILD_CAPABILITY_WINXPE) set_pioinfo_extra(); #endif +#endif + get_version(); // // subvert cmd.exe's feeble attempt at command line parsing // @@ -1778,11 +1801,11 @@ DIR * rb_w32_opendir(const char *filename) { struct stati64 sbuf; - WIN32_FIND_DATAW fd; + WIN32_FIND_DATAW fd = {0}; HANDLE fh; WCHAR *wpath; if (!(wpath = filecp_to_wstr(filename, NULL))) return NULL; @@ -4214,11 +4237,11 @@ } static int check_valid_dir(const WCHAR *path) { - WIN32_FIND_DATAW fd; + WIN32_FIND_DATAW fd = {0}; HANDLE fh = open_dir_handle(path, &fd); if (fh == INVALID_HANDLE_VALUE) return -1; FindClose(fh); return 0; @@ -4226,11 +4249,11 @@ static int winnt_stat(const WCHAR *path, struct stati64 *st) { HANDLE h; - WIN32_FIND_DATAW wfd; + WIN32_FIND_DATAW wfd = {0}; memset(st, 0, sizeof(*st)); st->st_nlink = 1; if (wcspbrk(path, L"?*")) { @@ -4474,10 +4497,11 @@ return (off_t)-1; } return ((off_t)u << 32) | l; } +#if !defined(APP_BUILD_CAPABILITY_WINXPE) off_t _lseeki64(int fd, off_t offset, int whence) { long u, l; int e; @@ -4493,10 +4517,11 @@ errno = map_errno(e); return -1; } return ((off_t)u << 32) | l; } +#endif //APP_BUILD_CAPABILITY_WINXPE #endif int fseeko(FILE *stream, off_t offset, int whence) { @@ -5134,10 +5159,10 @@ } _set_osfhnd(fd, (SOCKET)INVALID_HANDLE_VALUE); key = (st_data_t)sock; st_delete(socklist, &key, NULL); sock = (SOCKET)key; - _close(fd); + //_close(fd); errno = save_errno; if (closesocket(sock) == SOCKET_ERROR) { errno = map_errno(WSAGetLastError()); return -1; }