From f212710ea752bc473566c493a8530f02d9b82827 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Thu, 8 Oct 2015 22:47:21 +0600 Subject: [PATCH] Make osal as separate library. I need filesystem functions in the plugin, thus I decided to move osal code from GLideNHQ to osal lib. --- projects/msvc12/GLideN64.sln | 17 ++++ projects/msvc12/GLideN64.vcxproj | 16 ++-- projects/msvc12/libGLideNHQ.vcxproj | 7 +- projects/msvc12/libGLideNHQ.vcxproj.filters | 3 - projects/msvc12/osal.vcxproj | 84 +++++++++++++++++++ projects/msvc12/osal.vcxproj.filters | 23 +++++ src/CMakeLists.txt | 12 +-- src/GLideNHQ/CMakeLists.txt | 6 +- src/GLideNHQ/TxCache.cpp | 2 +- src/GLideNHQ/TxFilter.cpp | 2 +- src/GLideNHQ/TxHiResCache.cpp | 2 +- src/GLideNHQ/TxTexCache.cpp | 2 +- .../{osal => }/txWidestringWrapper.cpp | 0 src/GLideNHQ/{osal => }/txWidestringWrapper.h | 0 src/osal/CMakeLists.txt | 53 ++++++++++++ src/{GLideNHQ => }/osal/osal_files.h | 36 +++++--- src/{GLideNHQ => }/osal/osal_files_unix.c | 21 +++-- src/{GLideNHQ => }/osal/osal_files_win32.c | 22 +++-- 18 files changed, 253 insertions(+), 55 deletions(-) create mode 100644 projects/msvc12/osal.vcxproj create mode 100644 projects/msvc12/osal.vcxproj.filters rename src/GLideNHQ/{osal => }/txWidestringWrapper.cpp (100%) rename src/GLideNHQ/{osal => }/txWidestringWrapper.h (100%) create mode 100644 src/osal/CMakeLists.txt rename src/{GLideNHQ => }/osal/osal_files.h (65%) rename src/{GLideNHQ => }/osal/osal_files_unix.c (88%) rename src/{GLideNHQ => }/osal/osal_files_win32.c (90%) diff --git a/projects/msvc12/GLideN64.sln b/projects/msvc12/GLideN64.sln index 288ff98d..099a09ab 100644 --- a/projects/msvc12/GLideN64.sln +++ b/projects/msvc12/GLideN64.sln @@ -5,11 +5,14 @@ VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GLideN64", "GLideN64.vcxproj", "{37D31D7F-C4E7-45B0-AEF6-D6824A243CF7}" ProjectSection(ProjectDependencies) = postProject + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C} = {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C} {DA965BCF-2219-47AF-ACE7-EAF76D5D4756} = {DA965BCF-2219-47AF-ACE7-EAF76D5D4756} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGLideNHQ", "libGLideNHQ.vcxproj", "{DA965BCF-2219-47AF-ACE7-EAF76D5D4756}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osal", "osal.vcxproj", "{7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug_mupenplus|Win32 = Debug_mupenplus|Win32 @@ -49,6 +52,20 @@ Global {DA965BCF-2219-47AF-ACE7-EAF76D5D4756}.Release|Win32.Build.0 = Release|Win32 {DA965BCF-2219-47AF-ACE7-EAF76D5D4756}.RelWithDebInfo|Win32.ActiveCfg = RelWithDebInfo|Win32 {DA965BCF-2219-47AF-ACE7-EAF76D5D4756}.RelWithDebInfo|Win32.Build.0 = RelWithDebInfo|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Debug_mupenplus|Win32.ActiveCfg = Debug|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Debug_mupenplus|Win32.Build.0 = Debug|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Debug|Win32.ActiveCfg = Debug|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Debug|Win32.Build.0 = Debug|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.MinSizeRel|Win32.ActiveCfg = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.MinSizeRel|Win32.Build.0 = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Release_dll|Win32.ActiveCfg = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Release_dll|Win32.Build.0 = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Release_mupenplus|Win32.ActiveCfg = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Release_mupenplus|Win32.Build.0 = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Release|Win32.ActiveCfg = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.Release|Win32.Build.0 = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C}.RelWithDebInfo|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/projects/msvc12/GLideN64.vcxproj b/projects/msvc12/GLideN64.vcxproj index c7e0bb47..be1c5d78 100644 --- a/projects/msvc12/GLideN64.vcxproj +++ b/projects/msvc12/GLideN64.vcxproj @@ -111,10 +111,10 @@ EditAndContinue Async true - ../../src/inc;../../../freetype/include + ../../src/inc;../../src/osal;../../../freetype/include - freetype253MT_D.lib;..\..\src\GLideNUI\debug\GLideNUI.lib;GLideNHQ\Debug\libGLideNHQ.lib;opengl32.lib;glu32.lib;winmm.lib;%(AdditionalDependencies) + freetype253MT_D.lib;..\..\src\GLideNUI\debug\GLideNUI.lib;osal\Debug\osal.lib;GLideNHQ\Debug\libGLideNHQ.lib;opengl32.lib;glu32.lib;winmm.lib;%(AdditionalDependencies) c:\Games\N64\Plugin\GLideN64.dll true $(OutDir)New glNintendo64().pdb @@ -136,12 +136,12 @@ glN64.h Level3 EditAndContinue - ../../src/inc;../../../freetype/include + ../../src/inc;../../src/osal;../../../freetype/include Async true - freetype253MT_D.lib;GLideNHQ\Debug\libGLideNHQ.lib;opengl32.lib;glu32.lib;winmm.lib;%(AdditionalDependencies) + freetype253MT_D.lib;osal\Debug\osal.lib;GLideNHQ\Debug\libGLideNHQ.lib;opengl32.lib;glu32.lib;winmm.lib;%(AdditionalDependencies) c:\Games\N64\M64Py\mupen64plus-video-GLideN64.dll true $(OutDir)New glNintendo64().pdb @@ -168,10 +168,10 @@ ProgramDatabase Async true - ../../src/inc;../../../freetype/include + ../../src/inc;../../src/osal;../../../freetype/include - freetype253MT.lib;..\..\src\GLideNUI\release\GLideNUI.lib;GLideNHQ\Release\libGLideNHQ.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies) + freetype253MT.lib;..\..\src\GLideNUI\release\GLideNUI.lib;osal\Release\osal.lib;GLideNHQ\Release\libGLideNHQ.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies) c:\Games\N64\Plugin\GLideN64.dll false Windows @@ -197,12 +197,12 @@ Level3 ProgramDatabase - ../../src/inc;../../../freetype/include + ../../src/inc;../../src/osal;../../../freetype/include Async true - freetype253MT.lib;GLideNHQ\Release\libGLideNHQ.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies) + freetype253MT.lib;osal\Release\osal.lib;GLideNHQ\Release\libGLideNHQ.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies) c:\Games\N64\M64Py\mupen64plus-video-GLideN64.dll false Windows diff --git a/projects/msvc12/libGLideNHQ.vcxproj b/projects/msvc12/libGLideNHQ.vcxproj index 7ee37ad0..093a8bc1 100644 --- a/projects/msvc12/libGLideNHQ.vcxproj +++ b/projects/msvc12/libGLideNHQ.vcxproj @@ -96,7 +96,7 @@ - ..\..\src\inc;..\..\src\GLideNHQ\osal;..\..\src\GLideNHQ\inc;%(AdditionalIncludeDirectories) + ..\..\src\inc;..\..\src\osal;..\..\src\GLideNHQ\inc;%(AdditionalIncludeDirectories) Debug/ EnableFastChecks CompileAsCpp @@ -133,7 +133,7 @@ - ..\..\src\inc;..\..\src\GLideNHQ\osal;..\..\src\GLideNHQ\inc;%(AdditionalIncludeDirectories) + ..\..\src\inc;..\..\src\osal;..\..\src\GLideNHQ\inc;%(AdditionalIncludeDirectories) Release/ CompileAsCpp Sync @@ -145,7 +145,7 @@ Level3 - UNICODE;WIN32;_WINDOWS;NDEBUG;WIN32;OS_WINDOWS;_CRT_SECURE_NO_WARNINGS;DEBUG;__MSC__;CMAKE_INTDIR="Release";%(PreprocessorDefinitions) + UNICODE;WIN32;_WINDOWS;NDEBUG;OS_WINDOWS;_CRT_SECURE_NO_WARNINGS;__MSC__;CMAKE_INTDIR="Release";%(PreprocessorDefinitions) $(IntDir) true @@ -269,7 +269,6 @@ - diff --git a/projects/msvc12/libGLideNHQ.vcxproj.filters b/projects/msvc12/libGLideNHQ.vcxproj.filters index ea85b5ea..55eed07a 100644 --- a/projects/msvc12/libGLideNHQ.vcxproj.filters +++ b/projects/msvc12/libGLideNHQ.vcxproj.filters @@ -46,9 +46,6 @@ Source Files - - Source Files - diff --git a/projects/msvc12/osal.vcxproj b/projects/msvc12/osal.vcxproj new file mode 100644 index 00000000..2d010dd0 --- /dev/null +++ b/projects/msvc12/osal.vcxproj @@ -0,0 +1,84 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {7BF6F100-31DB-44AE-A2A5-5DDEED9A909C} + osal + + + + StaticLibrary + true + v120 + MultiByte + + + StaticLibrary + false + v120 + true + MultiByte + + + + + + + + + + + + + $(SolutionDir)osal\$(Configuration)\ + + + $(SolutionDir)osal\$(Configuration)\ + + + + Level3 + Disabled + true + MultiThreadedDebug + _CRT_SECURE_NO_WARNINGS;UNICODE;OS_WINDOWS;_MBCS;%(PreprocessorDefinitions) + + + true + + + + + Level3 + MaxSpeed + true + true + true + MultiThreaded + _CRT_SECURE_NO_WARNINGS;UNICODE;OS_WINDOWS;_MBCS;%(PreprocessorDefinitions) + + + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/msvc12/osal.vcxproj.filters b/projects/msvc12/osal.vcxproj.filters new file mode 100644 index 00000000..ef9b56bf --- /dev/null +++ b/projects/msvc12/osal.vcxproj.filters @@ -0,0 +1,23 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f1a8e477..8c4a6d2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,7 +80,9 @@ else(MUPENPLUSAPI) set(GLideN64_DLL_NAME GLideN64) endif(MUPENPLUSAPI) -add_subdirectory(GLideNHQ) +add_subdirectory( osal ) +include_directories( osal ) +add_subdirectory( GLideNHQ ) include_directories( GLideNHQ ) if(UNIX) @@ -192,9 +194,9 @@ if( CMAKE_BUILD_TYPE STREQUAL "Debug") ) if(SDL) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} GLideNHQd ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osald GLideNHQd ) else(SDL) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} GLideNHQd ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osald GLideNHQd ) endif(SDL) endif( CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -208,9 +210,9 @@ if( CMAKE_BUILD_TYPE STREQUAL "Release") ) if(SDL) - target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} GLideNHQ ) + target_link_libraries(${GLideN64_DLL_NAME} ${OPENGL_LIBRARIES} ${SDL_LIBRARIES} ${FREETYPE_LIBRARIES} osal GLideNHQ ) else(SDL) - target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} GLideNHQ ) + target_link_libraries(${GLideN64_DLL_NAME} PRIVATE ${OPENGL_LIBRARIES} ${FREETYPE_LIBRARIES} osal GLideNHQ ) endif(SDL) endif( CMAKE_BUILD_TYPE STREQUAL "Release") diff --git a/src/GLideNHQ/CMakeLists.txt b/src/GLideNHQ/CMakeLists.txt index f3f4ad8d..328a1312 100644 --- a/src/GLideNHQ/CMakeLists.txt +++ b/src/GLideNHQ/CMakeLists.txt @@ -21,14 +21,13 @@ set(GLideNHQ_SOURCES ) if(PANDORA) -include_directories( osal ) +include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../osal ) else(PANDORA) -include_directories( inc osal ) +include_directories( inc ${CMAKE_CURRENT_SOURCE_DIR}/../osal ) endif(PANDORA) LINK_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/lib ) if(UNIX) - list(APPEND GLideNHQ_SOURCES osal/osal_files_unix.c) add_definitions( -DNDEBUG -DOS_LINUX @@ -36,7 +35,6 @@ if(UNIX) endif(UNIX) if(WIN32) - list(APPEND GLideNHQ_SOURCES osal/osal_files_win32.c) LINK_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/lib ) add_definitions( -DWIN32 diff --git a/src/GLideNHQ/TxCache.cpp b/src/GLideNHQ/TxCache.cpp index 8c085ed7..c77ea1cd 100644 --- a/src/GLideNHQ/TxCache.cpp +++ b/src/GLideNHQ/TxCache.cpp @@ -27,7 +27,7 @@ #include "TxCache.h" #include "TxDbg.h" -#include "osal_files.h" +#include #include #include #include diff --git a/src/GLideNHQ/TxFilter.cpp b/src/GLideNHQ/TxFilter.cpp index d2ff93fe..d657d232 100644 --- a/src/GLideNHQ/TxFilter.cpp +++ b/src/GLideNHQ/TxFilter.cpp @@ -29,7 +29,7 @@ #include #include -#include "osal_files.h" +#include #include "TxFilter.h" #include "TextureFilters.h" #include "TxDbg.h" diff --git a/src/GLideNHQ/TxHiResCache.cpp b/src/GLideNHQ/TxHiResCache.cpp index 604cd5fc..f403ab5a 100644 --- a/src/GLideNHQ/TxHiResCache.cpp +++ b/src/GLideNHQ/TxHiResCache.cpp @@ -47,7 +47,7 @@ #include "TxHiResCache.h" #include "TxDbg.h" -#include "osal_files.h" +#include #include #include #include diff --git a/src/GLideNHQ/TxTexCache.cpp b/src/GLideNHQ/TxTexCache.cpp index ad82a423..763c7231 100644 --- a/src/GLideNHQ/TxTexCache.cpp +++ b/src/GLideNHQ/TxTexCache.cpp @@ -30,7 +30,7 @@ #include "TxTexCache.h" #include "TxDbg.h" -#include "osal_files.h" +#include #include TxTexCache::~TxTexCache() diff --git a/src/GLideNHQ/osal/txWidestringWrapper.cpp b/src/GLideNHQ/txWidestringWrapper.cpp similarity index 100% rename from src/GLideNHQ/osal/txWidestringWrapper.cpp rename to src/GLideNHQ/txWidestringWrapper.cpp diff --git a/src/GLideNHQ/osal/txWidestringWrapper.h b/src/GLideNHQ/txWidestringWrapper.h similarity index 100% rename from src/GLideNHQ/osal/txWidestringWrapper.h rename to src/GLideNHQ/txWidestringWrapper.h diff --git a/src/osal/CMakeLists.txt b/src/osal/CMakeLists.txt new file mode 100644 index 00000000..96989298 --- /dev/null +++ b/src/osal/CMakeLists.txt @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 2.6) + +project( osal ) + +LINK_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/lib ) + +if(UNIX) + set(OSAL_SOURCES osal_files_unix.c) + add_definitions( + -DNDEBUG + -DOS_LINUX + ) +endif(UNIX) + +if(WIN32) + set(OSAL_SOURCES osal_files_win32.c) + add_definitions( + -DOS_WINDOWS + -D_CRT_SECURE_NO_WARNINGS + ) +endif(WIN32) + +# Build type + +if( NOT CMAKE_BUILD_TYPE) + set( CMAKE_BUILD_TYPE Release) +endif( NOT CMAKE_BUILD_TYPE) + +if( CMAKE_BUILD_TYPE STREQUAL "Debug") + set( CMAKE_BUILD_TYPE Debug) + set( DEBUG_BUILD TRUE) + add_definitions( + -DDEBUG + ) +endif( CMAKE_BUILD_TYPE STREQUAL "Debug") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_definitions( -D__MSC__) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + SET(GCC_CPP11_COMPILE_FLAGS "-std=c++0x") + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_CPP11_COMPILE_FLAGS} -static -fPIC " ) + SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -fPIC " ) +endif() + +if( CMAKE_BUILD_TYPE STREQUAL "Debug") + add_library( osald STATIC ${OSAL_SOURCES}) +endif( CMAKE_BUILD_TYPE STREQUAL "Debug") + +if( CMAKE_BUILD_TYPE STREQUAL "Release") + add_library( osal STATIC ${OSAL_SOURCES}) +endif( CMAKE_BUILD_TYPE STREQUAL "Release") diff --git a/src/GLideNHQ/osal/osal_files.h b/src/osal/osal_files.h similarity index 65% rename from src/GLideNHQ/osal/osal_files.h rename to src/osal/osal_files.h index f5af4772..aaae9404 100644 --- a/src/GLideNHQ/osal/osal_files.h +++ b/src/osal/osal_files.h @@ -33,23 +33,33 @@ extern "C" { #define OSAL_DIR_SEPARATOR_STR L"/" #define OSAL_DIR_SEPARATOR_CHAR L'/' -#if defined(WIN32) - #define PATH_MAX _MAX_PATH - #define strdup _strdup +#if defined(OS_WINDOWS) +#define EXPORT __declspec(dllexport) +#define CALL __cdecl +#define PATH_MAX _MAX_PATH +#define strdup _strdup #else /* Not WIN32 */ - #ifndef PATH_MAX - #define PATH_MAX 260 - #endif +#define EXPORT __attribute__((visibility("default"))) +#define CALL +#ifndef PATH_MAX +#define PATH_MAX 260 +#endif #endif -int osal_is_directory(const wchar_t* name); -int osal_mkdirp(const wchar_t *dirpath); -int osal_path_existsA(const char *path); -int osal_path_existsW(const wchar_t *path); +// Returns 1 if name contains path to a directory, 0 otherwise +EXPORT int CALL osal_is_directory(const wchar_t* name); +// Returns 1 if path points to file or directory, 0 otherwise +EXPORT int CALL osal_path_existsA(const char *path); +// Returns 1 if path points to file or directory, 0 otherwise +EXPORT int CALL osal_path_existsW(const wchar_t *path); +// Returns 0 if all directories on the path exist or successfully created +// Returns 1 if path is bad +// Returns 2 if we can't create some directory on the path +EXPORT int CALL osal_mkdirp(const wchar_t *dirpath); -void * osal_search_dir_open(const wchar_t *_pathname); -const wchar_t *osal_search_dir_read_next(void * dir_handle); -void osal_search_dir_close(void * dir_handle); +EXPORT void * CALL osal_search_dir_open(const wchar_t *_pathname); +EXPORT const wchar_t * CALL osal_search_dir_read_next(void * dir_handle); +EXPORT void CALL osal_search_dir_close(void * dir_handle); #ifdef __cplusplus } diff --git a/src/GLideNHQ/osal/osal_files_unix.c b/src/osal/osal_files_unix.c similarity index 88% rename from src/GLideNHQ/osal/osal_files_unix.c rename to src/osal/osal_files_unix.c index e66884b3..5db34281 100644 --- a/src/GLideNHQ/osal/osal_files_unix.c +++ b/src/osal/osal_files_unix.c @@ -35,13 +35,17 @@ /* global functions */ -int osal_path_existsA(const char *path) +#ifdef __cplusplus +extern "C"{ +#endif + +EXPORT int CALL osal_path_existsA(const char *path) { struct stat fileinfo; return stat(path, &fileinfo) == 0 ? 1 : 0; } -int osal_path_existsW(const wchar_t *_path) +EXPORT int CALL osal_path_existsW(const wchar_t *_path) { char path[PATH_MAX]; wcstombs(path, _path, PATH_MAX); @@ -49,7 +53,7 @@ int osal_path_existsW(const wchar_t *_path) return stat(path, &fileinfo) == 0 ? 1 : 0; } -int osal_is_directory(const wchar_t * _name) +EXPORT int CALL osal_is_directory(const wchar_t * _name) { char name[PATH_MAX + 1]; wcstombs(name, _name, PATH_MAX); @@ -63,7 +67,7 @@ int osal_is_directory(const wchar_t * _name) return 0; } -int osal_mkdirp(const wchar_t *_dirpath) +EXPORT int CALL osal_mkdirp(const wchar_t *_dirpath) { char dirpath[PATH_MAX]; wcstombs(dirpath, _dirpath, PATH_MAX); @@ -109,7 +113,7 @@ int osal_mkdirp(const wchar_t *_dirpath) return 0; } -void * osal_search_dir_open(const wchar_t *_pathname) +EXPORT void * CALL osal_search_dir_open(const wchar_t *_pathname) { char pathname[PATH_MAX]; wcstombs(pathname, _pathname, PATH_MAX); @@ -118,7 +122,7 @@ void * osal_search_dir_open(const wchar_t *_pathname) return dir; } -const wchar_t *osal_search_dir_read_next(void * dir_handle) +EXPORT const wchar_t * CALL osal_search_dir_read_next(void * dir_handle) { static wchar_t last_filename[PATH_MAX]; DIR *dir = (DIR *) dir_handle; @@ -131,8 +135,11 @@ const wchar_t *osal_search_dir_read_next(void * dir_handle) return last_filename; } -void osal_search_dir_close(void * dir_handle) +EXPORT void CALL osal_search_dir_close(void * dir_handle) { closedir((DIR *) dir_handle); } +#ifdef __cplusplus +} +#endif diff --git a/src/GLideNHQ/osal/osal_files_win32.c b/src/osal/osal_files_win32.c similarity index 90% rename from src/GLideNHQ/osal/osal_files_win32.c rename to src/osal/osal_files_win32.c index e9a093fb..3f9cccf8 100644 --- a/src/GLideNHQ/osal/osal_files_win32.c +++ b/src/osal/osal_files_win32.c @@ -35,19 +35,23 @@ /* global functions */ -int osal_path_existsA(const char *path) +#ifdef __cplusplus +extern "C"{ +#endif + +EXPORT int CALL osal_path_existsA(const char *path) { struct _stat fileinfo; return _stat(path, &fileinfo) == 0 ? 1 : 0; } -int osal_path_existsW(const wchar_t *path) +EXPORT int CALL osal_path_existsW(const wchar_t *path) { struct _stat fileinfo; return _wstat(path, &fileinfo) == 0 ? 1 : 0; } -int osal_is_directory(const wchar_t* _name) +EXPORT int CALL osal_is_directory(const wchar_t* _name) { wchar_t DirName[MAX_PATH + 1]; int namelen = 0; @@ -61,7 +65,7 @@ int osal_is_directory(const wchar_t* _name) return (GetFileAttributes(DirName) & FILE_ATTRIBUTE_DIRECTORY); } -int osal_mkdirp(const wchar_t * dirpath) +EXPORT int CALL osal_mkdirp(const wchar_t * dirpath) { struct _stat fileinfo; size_t dirpathlen = wcslen(dirpath); @@ -102,7 +106,7 @@ typedef struct { WIN32_FIND_DATA find_data; } dir_search_info; -void * osal_search_dir_open(const wchar_t *pathname) +EXPORT void * CALL osal_search_dir_open(const wchar_t *pathname) { wchar_t SearchString[MAX_PATH + 1]; dir_search_info *pInfo = (dir_search_info *)malloc(sizeof(dir_search_info)); @@ -123,7 +127,7 @@ void * osal_search_dir_open(const wchar_t *pathname) return (void *) pInfo; } -const wchar_t *osal_search_dir_read_next(void * search_info) +EXPORT const wchar_t * CALL osal_search_dir_read_next(void * search_info) { static wchar_t last_filename[_MAX_PATH]; dir_search_info *pInfo = (dir_search_info *) search_info; @@ -141,7 +145,7 @@ const wchar_t *osal_search_dir_read_next(void * search_info) return last_filename; } -void osal_search_dir_close(void * search_info) +EXPORT void CALL osal_search_dir_close(void * search_info) { dir_search_info *pInfo = (dir_search_info *) search_info; @@ -152,3 +156,7 @@ void osal_search_dir_close(void * search_info) free(pInfo); } } + +#ifdef __cplusplus +} +#endif