diff --git a/src/Environment/SDL/SDLIncluder.h b/src/Environment/SDL/SDLIncluder.h index ab5d1f0502..88ebc311f4 100644 --- a/src/Environment/SDL/SDLIncluder.h +++ b/src/Environment/SDL/SDLIncluder.h @@ -8,3 +8,8 @@ #include "SDL.h" #include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_filesystem.h" +#include "SDL_video.h" +#include "SDL_thread.h" +#include "SDL_timer.h" diff --git a/src/Environment/Windows/Win32FileHelper.cpp b/src/Environment/Windows/Win32FileHelper.cpp index 3caa6696b1..6ca874e213 100644 --- a/src/Environment/Windows/Win32FileHelper.cpp +++ b/src/Environment/Windows/Win32FileHelper.cpp @@ -105,15 +105,18 @@ namespace Mengine return handle; } ////////////////////////////////////////////////////////////////////////// - bool Win32ValidateFile( const WChar * _path ) + bool Win32ValidateFile( const WChar * _filePath ) { + WChar pathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( pathCorrect, _filePath ); + WIN32_FIND_DATA wfd; - HANDLE hFind = ::FindFirstFile( _path, &wfd ); + HANDLE hFind = ::FindFirstFile( pathCorrect, &wfd ); if( hFind == INVALID_HANDLE_VALUE ) { LOGGER_ERROR( "file invalid find ??? (%ls) get error %ls" - , _path + , pathCorrect , Helper::Win32GetLastErrorMessageW() ); @@ -122,12 +125,12 @@ namespace Mengine ::FindClose( hFind ); - const WChar * filename = ::PathFindFileNameW( _path ); + const WChar * filename = ::PathFindFileNameW( pathCorrect ); if( StdString::wcscmp( filename, wfd.cFileName ) != 0 ) { LOGGER_ERROR( "file invalid name lowercase|upcase:\npath - '%ls'\nneed file name - '%ls'\ncurrent file name - '%ls'\n\n" - , _path + , pathCorrect , filename , wfd.cFileName ); @@ -138,6 +141,135 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// + bool Win32ExistFile( const WChar * _filePath ) + { + WChar pathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( pathCorrect, _filePath ); + + size_t len = StdString::wcslen( pathCorrect ); + + if( len == 0 ) + { + return false; + } + + if( pathCorrect[len - 1] == L':' ) + { + return true; + } + + DWORD attributes = ::GetFileAttributesW( pathCorrect ); + + if( attributes == INVALID_FILE_ATTRIBUTES ) + { + return false; + } + + if( (attributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) + { + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool Win32CreateDirectory( const WChar * _basePath, const WChar * _directory ) + { + size_t unicode_directorySize = StdString::wcslen( _directory ); + + if( unicode_directorySize == 0 ) + { + return true; + } + + WChar pathDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( pathDirectory, _directory ); + + Helper::pathRemoveFileSpecW( pathDirectory ); + + if( StdString::wcslen( pathDirectory ) == 0 ) + { + return true; + } + + WChar pathTestDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; + StdString::wcsncpy( pathTestDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::wcsncat( pathTestDirectory, pathDirectory, MENGINE_MAX_PATH ); + + if( ::PathIsDirectoryW( pathTestDirectory ) == FILE_ATTRIBUTE_DIRECTORY ) + { + return true; + } + + Helper::pathRemoveBackslashW( pathDirectory ); + + uint32_t paths_count = 0; + WChar paths[MENGINE_MAX_PATH + 1][16]; + + for( ;; ) + { + StdString::wcsncpy( paths[paths_count++], pathDirectory, MENGINE_MAX_PATH ); + + if( Helper::pathRemoveFileSpecW( pathDirectory ) == false ) + { + break; + } + + Helper::pathRemoveBackslashW( pathDirectory ); + + StdString::wcsncpy( pathTestDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::wcsncat( pathTestDirectory, pathDirectory, MENGINE_MAX_PATH ); + + if( ::PathIsDirectoryW( pathTestDirectory ) == FILE_ATTRIBUTE_DIRECTORY ) + { + break; + } + } + + for( uint32_t index = paths_count; index != 0; --index ) + { + const WChar * path = paths[index - 1]; + + WChar pathCreateDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; + StdString::wcsncpy( pathCreateDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::wcsncat( pathCreateDirectory, path, MENGINE_MAX_PATH ); + + BOOL successful = ::CreateDirectory( pathCreateDirectory, NULL ); + + if( successful == FALSE ) + { + DWORD error = ::GetLastError(); + + switch( error ) + { + case ERROR_ALREADY_EXISTS: + { + continue; + }break; + case ERROR_PATH_NOT_FOUND: + { + LOGGER_ERROR( "directory '%ls' not found" + , pathCreateDirectory + ); + + return false; + }break; + default: + { + LOGGER_ERROR( "directory '%ls' unknown %ls" + , pathCreateDirectory + , Helper::Win32GetLastErrorMessageW() + ); + + return false; + }break; + } + } + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// bool Win32ListDirectory( const WChar * _dir, const WChar * _mask, const WChar * _path, const LambdaListDirectoryFilePath & _lambda, bool * const _stop ) { { diff --git a/src/Environment/Windows/Win32FileHelper.h b/src/Environment/Windows/Win32FileHelper.h index c75a72a2e2..286b7030de 100644 --- a/src/Environment/Windows/Win32FileHelper.h +++ b/src/Environment/Windows/Win32FileHelper.h @@ -14,7 +14,10 @@ namespace Mengine time_t Win32FileTimeToUnixTime( const FILETIME * _filetime ); HANDLE Win32CreateFile( const WChar * _filePath, DWORD _desiredAccess, DWORD _sharedMode, DWORD _creationDisposition ); - bool Win32ValidateFile( const WChar * _path ); + bool Win32ValidateFile( const WChar * _filePath ); + bool Win32ExistFile( const WChar * _filePath ); + + bool Win32CreateDirectory( const WChar * _basePath, const WChar * _directory ); typedef Lambda LambdaListDirectoryFilePath; bool Win32ListDirectory( const WChar * _dir, const WChar * _mask, const WChar * _path, const LambdaListDirectoryFilePath & _lambda, bool * const _stop ); diff --git a/src/Interface/FileSystemInterface.h b/src/Interface/FileSystemInterface.h index 5be93675c2..fd79fa4135 100644 --- a/src/Interface/FileSystemInterface.h +++ b/src/Interface/FileSystemInterface.h @@ -13,6 +13,20 @@ namespace Mengine { SERVICE_DECLARE( "FileSystem" ) + public: + virtual bool existDirectory( const Char * _directoryPath, const Char * _directory ) const = 0; + virtual bool createDirectory( const Char * _directoryPath, const Char * _directory ) = 0; + + public: + virtual bool existFile( const Char * _filePath ) = 0; + virtual bool removeFile( const Char * _filePath ) = 0; + virtual bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) = 0; + + public: + virtual bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const = 0; + + public: + virtual uint64_t getFileTime( const Char * _filePath ) const = 0; }; } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Interface/PlatformServiceInterface.h b/src/Interface/PlatformServiceInterface.h index 16dc966cca..e5af10dcfb 100644 --- a/src/Interface/PlatformServiceInterface.h +++ b/src/Interface/PlatformServiceInterface.h @@ -116,21 +116,6 @@ namespace Mengine virtual bool openMail( const Char * _email, const Char * _subject, const Char * _body ) = 0; virtual bool openDeleteAccount() = 0; - public: - virtual bool existDirectory( const Char * _directoryPath, const Char * _directory ) const = 0; - virtual bool createDirectory( const Char * _directoryPath, const Char * _directory ) = 0; - - public: - virtual bool existFile( const Char * _filePath ) = 0; - virtual bool removeFile( const Char * _filePath ) = 0; - virtual bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) = 0; - - public: - virtual bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const = 0; - - public: - virtual uint64_t getFileTime( const Char * _filePath ) const = 0; - public: virtual bool updateDesktopWallpaper( const Char * _directoryPath, const Char * _filePath ) = 0; diff --git a/src/Interface/ThreadTaskInterface.h b/src/Interface/ThreadTaskInterface.h index bed2b8c888..6529f5d937 100644 --- a/src/Interface/ThreadTaskInterface.h +++ b/src/Interface/ThreadTaskInterface.h @@ -17,7 +17,7 @@ namespace Mengine public: virtual void preparation() = 0; - virtual void main() = 0; + virtual void process() = 0; virtual void finish() = 0; virtual void finally() = 0; diff --git a/src/Kernel/ThreadTask.cpp b/src/Kernel/ThreadTask.cpp index 981c340cfa..59f665c4d2 100644 --- a/src/Kernel/ThreadTask.cpp +++ b/src/Kernel/ThreadTask.cpp @@ -23,7 +23,7 @@ namespace Mengine this->_onThreadTaskPreparation(); } ////////////////////////////////////////////////////////////////////////// - void ThreadTask::main() + void ThreadTask::process() { if( m_run == false || m_finish == true || diff --git a/src/Kernel/ThreadTask.h b/src/Kernel/ThreadTask.h index b6c92c7be2..f0b89f768e 100644 --- a/src/Kernel/ThreadTask.h +++ b/src/Kernel/ThreadTask.h @@ -27,7 +27,7 @@ namespace Mengine public: void preparation() override; - void main() override; + void process() override; public: bool run( const ThreadMutexInterfacePtr & _mutex ) override; diff --git a/src/Kernel/ThreadTaskPacket.cpp b/src/Kernel/ThreadTaskPacket.cpp index 8f87ed6fac..e6bd632190 100644 --- a/src/Kernel/ThreadTaskPacket.cpp +++ b/src/Kernel/ThreadTaskPacket.cpp @@ -50,7 +50,7 @@ namespace Mengine for( const ThreadTaskPtr & task : m_tasks ) { m_childMutex->lock(); - task->main(); + task->process(); m_childMutex->unlock(); } diff --git a/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp b/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp index b7f714a35f..88772215d2 100644 --- a/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp +++ b/src/Platforms/AndroidPlatform/AndroidPlatformService.cpp @@ -1277,256 +1277,6 @@ namespace Mengine MENGINE_UNUSED( _params ); } ////////////////////////////////////////////////////////////////////////// - namespace Detail - { - ////////////////////////////////////////////////////////////////////////// - static bool s_createDirectoryFullpath( const Char * _fullpath ) - { - int status = ::mkdir( _fullpath, S_IRWXU ); - - if( status != 0 ) - { - LOGGER_WARNING( "'%s' already exists" - , _fullpath - ); - - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static bool s_isDirectoryFullpath( const Char * _fullpath ) - { - struct stat sb; - int err = ::stat( _fullpath, &sb ); - - if( err != 0 ) - { - return false; - } - - if( (sb.st_mode & S_IFMT) != S_IFDIR ) - { - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static bool s_isFileFullpath( const Char * _fullpath ) - { - struct stat sb; - int err = ::stat( _fullpath, &sb ); - - if( err != 0 ) - { - return false; - } - - if( (sb.st_mode & S_IFMT) == S_IFDIR ) - { - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - } - ////////////////////////////////////////////////////////////////////////// - bool AndroidPlatformService::existDirectory( const Char * _path, const Char * _directory ) const - { - Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathDirectory, _directory ); - - Helper::pathRemoveFileSpecA( pathDirectory ); - - size_t len = StdString::strlen( pathDirectory ); - - if( len == 0 ) // current dir - { - return true; - } - - Char pathFull[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SNPRINTF( pathFull, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - - if( pathFull[len - 1] == ':' ) // root dir - { - return true; // let it be - } - - bool exist = Detail::s_isDirectoryFullpath( pathFull ); - - return exist; - } - ////////////////////////////////////////////////////////////////////////// - bool AndroidPlatformService::createDirectory( const Char * _path, const Char * _directory ) - { - size_t directorySize = StdString::strlen( _directory ); - - if( directorySize == 0 ) - { - return true; - } - - Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathDirectory, _directory ); - - Helper::pathRemoveFileSpecA( pathDirectory ); - - if( StdString::strlen( pathDirectory ) == 0 ) - { - return true; - } - - Char pathTestDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SNPRINTF( pathTestDirectory, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - - if( Detail::s_isDirectoryFullpath( pathTestDirectory ) == true ) - { - return true; - } - - Helper::pathRemoveBackslashA( pathDirectory ); - - VectorString paths; - - for( ;; ) - { - paths.push_back( pathDirectory ); - - if( Helper::pathRemoveFileSpecA( pathDirectory ) == false ) - { - break; - } - - if( StdString::strlen( _path ) == 0 ) - { - break; - } - - Helper::pathRemoveBackslashA( pathDirectory ); - - MENGINE_SNPRINTF( pathTestDirectory, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - - if( Detail::s_isDirectoryFullpath( pathTestDirectory ) == true ) - { - break; - } - } - - for( VectorString::reverse_iterator - it = paths.rbegin(), - it_end = paths.rend(); - it != it_end; - ++it ) - { - const String & path = *it; - - const Char * path_str = path.c_str(); - - Char pathCreateDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SNPRINTF( pathCreateDirectory, MENGINE_MAX_PATH, "%s%s", _path, path_str ); - - if( Detail::s_createDirectoryFullpath( pathCreateDirectory ) == false ) - { - return false; - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool AndroidPlatformService::existFile( const Char * _filePath ) - { - Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); - - bool exist = Detail::s_isFileFullpath( pathCorrect ); - - return exist; - } - ////////////////////////////////////////////////////////////////////////// - bool AndroidPlatformService::removeFile( const Char * _filePath ) - { - Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); - - int result = ::remove( pathCorrect ); - - if( result != 0 ) - { - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool AndroidPlatformService::moveFile( const Char * _oldFilePath, const Char * _newFilePath ) - { - Char oldPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( oldPathCorrect, _oldFilePath ); - - Char newPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( newPathCorrect, _newFilePath ); - - struct stat sb; - if( stat( newPathCorrect, &sb ) == 0 && ((sb.st_mode) & S_IFMT) != S_IFDIR ) - { - int result_remove = ::remove( newPathCorrect ); - - if( result_remove != 0 ) - { - const char * msg = ::strerror( errno ); - - LOGGER_ASSERTION( "invalid remove new move file from '%s' to '%s' error '%s' [%u]" - , _oldFilePath - , _newFilePath - , msg - , errno - ); - } - } - - int result_rename = ::rename( oldPathCorrect, newPathCorrect ); - - if( result_rename != 0 ) - { - const char * msg = ::strerror( errno ); - - LOGGER_ASSERTION( "invalid move file from '%s' to '%s' error '%s' [%u]" - , _oldFilePath - , _newFilePath - , msg - , errno - ); - - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool AndroidPlatformService::findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const - { - MENGINE_UNUSED( _base ); - MENGINE_UNUSED( _path ); - MENGINE_UNUSED( _mask ); - MENGINE_UNUSED( _lambda ); - - LOGGER_WARNING("AndroidPlatformService::findFiles not support"); - - return false; - } - ////////////////////////////////////////////////////////////////////////// - uint64_t AndroidPlatformService::getFileTime( const Char * _filePath ) const - { - MENGINE_UNUSED( _filePath ); - - return 0U; - } - ////////////////////////////////////////////////////////////////////////// bool AndroidPlatformService::updateDesktopWallpaper( const Char * _directoryPath, const Char * _filePath ) { MENGINE_UNUSED( _directoryPath ); diff --git a/src/Platforms/AndroidPlatform/AndroidPlatformService.h b/src/Platforms/AndroidPlatform/AndroidPlatformService.h index 1c8fa56486..39bb9011d6 100644 --- a/src/Platforms/AndroidPlatform/AndroidPlatformService.h +++ b/src/Platforms/AndroidPlatform/AndroidPlatformService.h @@ -133,21 +133,6 @@ namespace Mengine bool openMail( const Char * _email, const Char * _subject, const Char * _body ) override; bool openDeleteAccount() override; - public: - bool existDirectory( const Char * _path, const Char * _directory ) const override; - bool createDirectory( const Char * _path, const Char * _directory ) override; - - public: - bool existFile( const Char * _filePath ) override; - bool removeFile( const Char * _filePath ) override; - bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) override; - - public: - bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const override; - - public: - uint64_t getFileTime( const Char * _filePath ) const override; - public: bool updateDesktopWallpaper( const Char * _directoryPath, const Char * _filePath ) override; diff --git a/src/Platforms/SDLPlatform/SDLDynamicLibrary.cpp b/src/Platforms/SDLPlatform/SDLDynamicLibrary.cpp index 3ffd501095..726a1ba389 100644 --- a/src/Platforms/SDLPlatform/SDLDynamicLibrary.cpp +++ b/src/Platforms/SDLPlatform/SDLDynamicLibrary.cpp @@ -1,14 +1,13 @@ #include "SDLDynamicLibrary.h" +#include "Environment/SDL/SDLIncluder.h" + #include "Kernel/Logger.h" #include "Kernel/AssertionMemoryPanic.h" #include "Config/StdString.h" #include "Config/StdIO.h" -#include "SDL_loadso.h" -#include "SDL_filesystem.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// diff --git a/src/Platforms/SDLPlatform/SDLPlatformService.cpp b/src/Platforms/SDLPlatform/SDLPlatformService.cpp index 502ec4868b..3f901eb3c9 100644 --- a/src/Platforms/SDLPlatform/SDLPlatformService.cpp +++ b/src/Platforms/SDLPlatform/SDLPlatformService.cpp @@ -1639,539 +1639,6 @@ namespace Mengine MENGINE_UNUSED( _params ); } ////////////////////////////////////////////////////////////////////////// - namespace Detail - { - ////////////////////////////////////////////////////////////////////////// - static bool s_createDirectoryFullpath( const Char * _fullpath ) - { -#if defined(MENGINE_PLATFORM_MACOS) - int status = ::mkdir( _fullpath, S_IRWXU ); - - if( status != 0 ) - { - LOGGER_WARNING( "'%s' already exists" - , _fullpath - ); - - return false; - } - -#elif defined(MENGINE_PLATFORM_LINUX) - int status = ::mkdir( _fullpath, S_IRWXU ); - - if( status != 0 ) - { - LOGGER_WARNING( "'%s' already exists" - , _fullpath - ); - - return false; - } - -#elif defined(MENGINE_PLATFORM_WINDOWS) - WChar unicode_fullpath[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::utf8ToUnicode( _fullpath, unicode_fullpath, MENGINE_MAX_PATH - 1 ); - - BOOL successful = ::CreateDirectoryW( unicode_fullpath, NULL ); - - if( successful == FALSE ) - { - DWORD err = GetLastError(); - - switch( err ) - { - case ERROR_ALREADY_EXISTS: - { - return true; - }break; - case ERROR_PATH_NOT_FOUND: - { - LOGGER_WARNING( "'%s' not found" - , _fullpath - ); - - return false; - }break; - default: - { - LOGGER_WARNING( "'%s' unknown error %d" - , _fullpath - , err - ); - }break; - } - - return false; - } -#endif - - return true; - } - ////////////////////////////////////////////////////////////////////////// - static bool s_isDirectoryFullpath( const Char * _fullpath ) - { - struct stat sb; - int err = ::stat( _fullpath, &sb ); - - if( err != 0 ) - { - return false; - } - - if( (sb.st_mode & S_IFMT) == S_IFDIR ) - { - return true; - } - - return false; - } - ////////////////////////////////////////////////////////////////////////// - } - ////////////////////////////////////////////////////////////////////////// - bool SDLPlatformService::existDirectory( const Char * _path, const Char * _directory ) const - { - Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathDirectory, _directory ); - - Helper::pathRemoveFileSpecA( pathDirectory ); - - size_t len = StdString::strlen( pathDirectory ); - - if( len == 0 ) // current dir - { - return true; - } - - Char pathFull[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SNPRINTF( pathFull, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - - if( pathFull[len - 1] == ':' ) // root dir - { - return true; // let it be - } -#if defined(MENGINE_PLATFORM_MACOS) - else if( pathFull[len - 1] == '~' ) // root dir - { - return true; // let it be - } -#endif - - bool exist = Detail::s_isDirectoryFullpath( pathFull ); - - return exist; - } - ////////////////////////////////////////////////////////////////////////// - bool SDLPlatformService::createDirectory( const Char * _path, const Char * _directory ) - { - size_t directorySize = StdString::strlen( _directory ); - - if( directorySize == 0 ) - { - return true; - } - - Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathDirectory, _directory ); - - Helper::pathRemoveFileSpecA( pathDirectory ); - - if( StdString::strlen( pathDirectory ) == 0 ) - { - return true; - } - - Char pathTestDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SNPRINTF( pathTestDirectory, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - - if( Detail::s_isDirectoryFullpath( pathTestDirectory ) == true ) - { - return true; - } - - Helper::pathRemoveBackslashA( pathDirectory ); - - VectorString paths; - - for( ;; ) - { - paths.push_back( pathDirectory ); - - if( Helper::pathRemoveFileSpecA( pathDirectory ) == false ) - { - break; - } - - if( StdString::strlen( _path ) == 0 ) - { - break; - } - - Helper::pathRemoveBackslashA( pathDirectory ); - - MENGINE_SNPRINTF( pathTestDirectory, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - - if( Detail::s_isDirectoryFullpath( pathTestDirectory ) == true ) - { - break; - } - } - - for( VectorString::reverse_iterator - it = paths.rbegin(), - it_end = paths.rend(); - it != it_end; - ++it ) - { - const String & path = *it; - - const Char * path_str = path.c_str(); - - Char pathCreateDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SNPRINTF( pathCreateDirectory, MENGINE_MAX_PATH, "%s%s", _path, path_str ); - - if( Detail::s_createDirectoryFullpath( pathCreateDirectory ) == false ) - { - return false; - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool SDLPlatformService::existFile( const Char * _filePath ) - { - Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); - - SDL_SuppressError( SDL_TRUE ); - - SDL_RWops * rwops = SDL_RWFromFile( pathCorrect, "rb" ); - - SDL_SuppressError( SDL_FALSE ); - - if( rwops == nullptr ) - { - return false; - } - - if( SDL_RWclose( rwops ) != 0 ) - { - LOGGER_ERROR( "invalid close '%s' get error: %s" - , pathCorrect - , SDL_GetError() - ); - - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool SDLPlatformService::removeFile( const Char * _filePath ) - { - Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); - - int result = ::remove( pathCorrect ); - - if( result != 0 ) - { - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool SDLPlatformService::moveFile( const Char * _oldFilePath, const Char * _newFilePath ) - { - Char oldPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( oldPathCorrect, _oldFilePath ); - - Char newPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; - Helper::pathCorrectBackslashToA( newPathCorrect, _newFilePath ); - - struct stat sb; - if( stat( newPathCorrect, &sb ) == 0 && ((sb.st_mode) & S_IFMT) != S_IFDIR ) - { - int result_remove = ::remove( newPathCorrect ); - - if( result_remove != 0 ) - { - const char * msg = ::strerror( errno ); - - LOGGER_ASSERTION( "invalid remove new move file from '%s' to '%s' error '%s' [%u]" - , _oldFilePath - , _newFilePath - , msg - , errno - ); - } - } - - int result_rename = ::rename( oldPathCorrect, newPathCorrect ); - - if( result_rename != 0 ) - { - const char * msg = ::strerror( errno ); - - LOGGER_ASSERTION( "invalid move file from '%s' to '%s' error '%s' [%u]" - , _oldFilePath - , _newFilePath - , msg - , errno - ); - - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// -#if defined(MENGINE_PLATFORM_WINDOWS) && !defined(MENGINE_PLATFORM_UWP) - ////////////////////////////////////////////////////////////////////////// - namespace Detail - { - ////////////////////////////////////////////////////////////////////////// - static bool listDirectoryContents( const WChar * _dir, const WChar * _mask, const WChar * _path, const LambdaFilePath & _lambda, bool * const _stop ) - { - WChar sDir[MENGINE_MAX_PATH + 1] = {L'\0'}; - ::PathCanonicalizeW( sDir, _dir ); - - { - WChar sPath[MENGINE_MAX_PATH + 1] = {L'\0'}; - StdString::wcscpy( sPath, sDir ); - StdString::wcscat( sPath, _path ); - StdString::wcscat( sPath, _mask ); - - WIN32_FIND_DATA fdFile; - HANDLE hFind = ::FindFirstFileEx( sPath, FindExInfoStandard, &fdFile, FindExSearchNameMatch, NULL, 0 ); - - if( hFind != INVALID_HANDLE_VALUE ) - { - do - { - if( StdString::wcscmp( fdFile.cFileName, L"." ) == 0 || - StdString::wcscmp( fdFile.cFileName, L".." ) == 0 ) - { - continue; - } - - if( fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) - { - continue; - } - - WChar sPath2[MENGINE_MAX_PATH + 1] = {L'\0'}; - StdString::wcscpy( sPath2, sPath ); - StdString::wcscat( sPath2, L"\0" ); - - Helper::pathCorrectForwardslashW( sPath2 ); - - ::PathRemoveFileSpec( sPath2 ); - - WChar unicode_filepath[MENGINE_MAX_PATH + 1] = {L'\0'}; - ::PathCombine( unicode_filepath, sPath2, fdFile.cFileName ); - - WChar unicode_out[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( StdString::wcslen( sDir ) != 0 ) - { - ::PathRelativePathTo( unicode_out - , sDir - , FILE_ATTRIBUTE_DIRECTORY - , unicode_filepath - , FILE_ATTRIBUTE_NORMAL ); - } - else - { - StdString::wcscpy( unicode_out, unicode_filepath ); - } - - Char utf8_filepath[MENGINE_MAX_PATH + 1] = {'\0'}; - if( Helper::unicodeToUtf8( unicode_out, utf8_filepath, MENGINE_MAX_PATH ) == false ) - { - ::FindClose( hFind ); - - return false; - } - - FilePath fp = Helper::stringizeFilePath( utf8_filepath ); - - if( _lambda( fp ) == false ) - { - ::FindClose( hFind ); - - *_stop = true; - - return true; - } - - } while( ::FindNextFile( hFind, &fdFile ) != FALSE ); - } - - ::FindClose( hFind ); - } - - { - WChar sPath[MENGINE_MAX_PATH + 1] = {L'\0'}; - StdString::wcscpy( sPath, sDir ); - StdString::wcscat( sPath, _path ); - StdString::wcscat( sPath, L"*.*" ); - - WIN32_FIND_DATA fdFile; - HANDLE hFind = ::FindFirstFileEx( sPath, FindExInfoStandard, &fdFile, FindExSearchNameMatch, NULL, 0 ); - - if( hFind == INVALID_HANDLE_VALUE ) - { - return true; - } - - do - { - if( StdString::wcscmp( fdFile.cFileName, L"." ) == 0 || - StdString::wcscmp( fdFile.cFileName, L".." ) == 0 ) - { - continue; - } - - if( (fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) - { - continue; - } - - WChar currentPath[MENGINE_MAX_PATH + 1] = {L'\0'}; - StdString::wcscpy( currentPath, sPath ); - StdString::wcscat( currentPath, L"\0" ); - - ::PathRemoveFileSpec( currentPath ); - - WChar nextPath[MENGINE_MAX_PATH + 1] = {L'\0'}; - ::PathCombine( nextPath, currentPath, fdFile.cFileName ); - - StdString::wcscat( nextPath, L"\\" ); - - bool stop; - if( Detail::listDirectoryContents( sDir, _mask, nextPath, _lambda, &stop ) == false ) - { - ::FindClose( hFind ); - - return false; - } - - if( stop == true ) - { - ::FindClose( hFind ); - - *_stop = true; - - return true; - } - - } while( ::FindNextFile( hFind, &fdFile ) != FALSE ); - - ::FindClose( hFind ); - } - - return true; - } - } - ////////////////////////////////////////////////////////////////////////// -#endif - ////////////////////////////////////////////////////////////////////////// - bool SDLPlatformService::findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const - { - MENGINE_UNUSED( _base ); - MENGINE_UNUSED( _path ); - MENGINE_UNUSED( _mask ); - MENGINE_UNUSED( _lambda ); - -#if defined(MENGINE_PLATFORM_WINDOWS) && !defined(MENGINE_PLATFORM_UWP) - WChar unicode_base[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _base, unicode_base, MENGINE_MAX_PATH - 1 ) == false ) - { - return false; - } - - WChar unicode_mask[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _mask, unicode_mask, MENGINE_MAX_PATH - 1 ) == false ) - { - return false; - } - - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH - 1 ) == false ) - { - return false; - } - - WChar unicode_fullbase[MENGINE_MAX_PATH + 1] = {L'\0'}; - ::GetFullPathName( unicode_base, MENGINE_MAX_PATH, unicode_fullbase, NULL ); - - Helper::LambdaListDirectoryFilePath lambda_listdirectory = [_lambda]( const WChar * _filePath ) - { - Char utf8_filepath[MENGINE_MAX_PATH + 1] = {'\0'}; - if( Helper::unicodeToUtf8( _filePath, utf8_filepath, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - FilePath fp = Helper::stringizeFilePath( utf8_filepath ); - - bool result = _lambda( fp ); - - return result; - }; - - bool stop; - if( Helper::Win32ListDirectory( unicode_fullbase, unicode_mask, unicode_path, lambda_listdirectory, &stop ) == false ) - { - return false; - } - - MENGINE_UNUSED( stop ); - - return true; -#else - LOGGER_WARNING("SDLPlatformService::findFiles not support"); - - return false; -#endif - } - ////////////////////////////////////////////////////////////////////////// - uint64_t SDLPlatformService::getFileTime( const Char * _filePath ) const - { - MENGINE_UNUSED( _filePath ); - -#if defined(MENGINE_PLATFORM_WINDOWS) && !defined(MENGINE_PLATFORM_UWP) - WChar unicode_filePath[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _filePath, unicode_filePath, MENGINE_MAX_PATH - 1 ) == false ) - { - return 0U; - } - - HANDLE handle = ::CreateFile( unicode_filePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - - FILETIME creation; - FILETIME access; - FILETIME write; - - if( ::GetFileTime( handle, &creation, &access, &write ) == FALSE ) - { - ::CloseHandle( handle ); - - return 0U; - } - - ::CloseHandle( handle ); - - time_t time = Helper::Win32FileTimeToUnixTime( &write ); - - return time; -#else - return 0U; -#endif - } - ////////////////////////////////////////////////////////////////////////// bool SDLPlatformService::updateDesktopWallpaper( const Char * _directoryPath, const Char * _filePath ) { MENGINE_UNUSED( _directoryPath ); diff --git a/src/Platforms/SDLPlatform/SDLPlatformService.h b/src/Platforms/SDLPlatform/SDLPlatformService.h index da7407b625..915639488f 100644 --- a/src/Platforms/SDLPlatform/SDLPlatformService.h +++ b/src/Platforms/SDLPlatform/SDLPlatformService.h @@ -136,21 +136,6 @@ namespace Mengine bool openMail( const Char * _email, const Char * _subject, const Char * _body ) override; bool openDeleteAccount() override; - public: - bool existDirectory( const Char * _path, const Char * _directory ) const override; - bool createDirectory( const Char * _path, const Char * _directory ) override; - - public: - bool existFile( const Char * _filePath ) override; - bool removeFile( const Char * _filePath ) override; - bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) override; - - public: - bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const override; - - public: - uint64_t getFileTime( const Char * _filePath ) const override; - public: bool updateDesktopWallpaper( const Char * _directoryPath, const Char * _filePath ) override; diff --git a/src/Platforms/Win32Platform/Win32PlatformService.cpp b/src/Platforms/Win32Platform/Win32PlatformService.cpp index 7a72273da5..d3bc1686ac 100644 --- a/src/Platforms/Win32Platform/Win32PlatformService.cpp +++ b/src/Platforms/Win32Platform/Win32PlatformService.cpp @@ -2728,449 +2728,6 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::existDirectory( const Char * _path, const Char * _directory ) const - { - MENGINE_ASSERTION_FATAL( StdString::strlen( _path ) == 0 - || (StdString::strrchr( _path, '.' ) > StdString::strrchr( _path, MENGINE_PATH_DELIM ) - || _path[StdString::strlen( _path ) - 1] == MENGINE_PATH_DELIM - || _path[StdString::strlen( _path ) - 1] == MENGINE_WIN32_PATH_DELIM) - , "invalid path '%s'", _path - ); - - MENGINE_ASSERTION_FATAL( StdString::strlen( _directory ) == 0 - || (StdString::strrchr( _directory, '.' ) > StdString::strrchr( _directory, MENGINE_PATH_DELIM ) - || _directory[StdString::strlen( _directory ) - 1] == MENGINE_PATH_DELIM - || _directory[StdString::strlen( _directory ) - 1] == MENGINE_WIN32_PATH_DELIM) - , "invalid directory '%s'", _directory - ); - - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar unicode_directory[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _directory, unicode_directory, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar pathDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::pathCorrectBackslashToW( pathDirectory, unicode_directory ); - - Helper::pathRemoveFileSpecW( pathDirectory ); - - size_t len = StdString::wcslen( pathDirectory ); - - if( len == 0 ) - { - return true; - } - - WChar pathFull[MENGINE_MAX_PATH + 1] = {'\0'}; - MENGINE_SWPRINTF( pathFull, MENGINE_MAX_PATH, L"%ls%ls" - , unicode_path - , pathDirectory - ); - - if( pathFull[len - 1] == L':' ) - { - return true; - } - - DWORD attributes = ::GetFileAttributes( pathFull ); - - if( attributes == INVALID_FILE_ATTRIBUTES ) - { - return false; - } - - if( (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) - { - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::createDirectory( const Char * _path, const Char * _directory ) - { - LOGGER_INFO( "platform", "create directory path '%s' directory '%s'" - , _path - , _directory - ); - - MENGINE_ASSERTION_FATAL( StdString::strlen( _path ) == 0 - || (StdString::strrchr( _path, '.' ) > StdString::strrchr( _path, MENGINE_PATH_DELIM ) - || _path[StdString::strlen( _path ) - 1] == MENGINE_PATH_DELIM - || _path[StdString::strlen( _path ) - 1] == MENGINE_WIN32_PATH_DELIM) - , "invalid path '%s'", _path - ); - - MENGINE_ASSERTION_FATAL( StdString::strlen( _directory ) == 0 - || (StdString::strrchr( _directory, '.' ) > StdString::strrchr( _directory, MENGINE_PATH_DELIM ) - || _directory[StdString::strlen( _directory ) - 1] == MENGINE_PATH_DELIM - || _directory[StdString::strlen( _directory ) - 1] == MENGINE_WIN32_PATH_DELIM) - , "invalid directory '%s'", _directory - ); - - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar unicode_directory[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _directory, unicode_directory, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - bool result = this->createDirectory_( unicode_path, unicode_directory ); - - return result; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::createDirectory_( const WChar * _path, const WChar * _directory ) - { - size_t unicode_directorySize = StdString::wcslen( _directory ); - - if( unicode_directorySize == 0 ) - { - return true; - } - - WChar pathDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::pathCorrectBackslashToW( pathDirectory, _directory ); - - Helper::pathRemoveFileSpecW( pathDirectory ); - - if( StdString::wcslen( pathDirectory ) == 0 ) - { - return true; - } - - WChar pathTestDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; - MENGINE_SWPRINTF( pathTestDirectory, MENGINE_MAX_PATH, L"%ls%ls", _path, pathDirectory ); - - if( ::PathIsDirectoryW( pathTestDirectory ) == FILE_ATTRIBUTE_DIRECTORY ) - { - return true; - } - - Helper::pathRemoveBackslashW( pathDirectory ); - - VectorWString paths; - - for( ;; ) - { - paths.emplace_back( pathDirectory ); - - if( Helper::pathRemoveFileSpecW( pathDirectory ) == false ) - { - break; - } - - Helper::pathRemoveBackslashW( pathDirectory ); - - MENGINE_SWPRINTF( pathTestDirectory, MENGINE_MAX_PATH, L"%ls%ls", _path, pathDirectory ); - - if( ::PathIsDirectoryW( pathTestDirectory ) == FILE_ATTRIBUTE_DIRECTORY ) - { - break; - } - } - - for( VectorWString::const_reverse_iterator - it = paths.rbegin(), - it_end = paths.rend(); - it != it_end; - ++it ) - { - const WString & path = *it; - - const WChar * path_str = path.c_str(); - - WChar pathCreateDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; - MENGINE_SWPRINTF( pathCreateDirectory, MENGINE_MAX_PATH, L"%ls%ls", _path, path_str ); - - BOOL successful = ::CreateDirectory( pathCreateDirectory, NULL ); - - if( successful == FALSE ) - { - DWORD error = ::GetLastError(); - - switch( error ) - { - case ERROR_ALREADY_EXISTS: - { - continue; - }break; - case ERROR_PATH_NOT_FOUND: - { - LOGGER_ERROR( "directory '%ls' not found" - , pathCreateDirectory - ); - - return false; - }break; - default: - { - LOGGER_ERROR( "directory '%ls' unknown %ls" - , pathCreateDirectory - , Helper::Win32GetLastErrorMessageW() - ); - - return false; - }break; - } - } - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::existFile( const Char * _filePath ) - { - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _filePath, unicode_path, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - bool result = this->existFile_( unicode_path ); - - return result; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::existFile_( const WChar * _filePath ) - { - WChar pathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::pathCorrectBackslashToW( pathCorrect, _filePath ); - - size_t len = StdString::wcslen( pathCorrect ); - - if( len == 0 ) - { - return true; - } - - if( pathCorrect[len - 1] == L':' ) - { - return true; - } - - DWORD attributes = ::GetFileAttributes( pathCorrect ); - - if( attributes == INVALID_FILE_ATTRIBUTES ) - { - return false; - } - - if( (attributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) - { - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::removeFile( const Char * _filePath ) - { - LOGGER_INFO( "platform", "remove file '%s'" - , _filePath - ); - - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _filePath, unicode_path, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar pathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::pathCorrectBackslashToW( pathCorrect, unicode_path ); - - if( ::DeleteFile( pathCorrect ) == FALSE ) - { - LOGGER_ERROR( "invalid DeleteFile '%ls' %ls" - , pathCorrect - , Helper::Win32GetLastErrorMessageW() - ); - - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::moveFile( const Char * _oldFilePath, const Char * _newFilePath ) - { - LOGGER_INFO( "platform", "move file from '%s' to '%s'" - , _oldFilePath - , _newFilePath - ); - - WChar unicode_oldFilePath[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _oldFilePath, unicode_oldFilePath, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar oldFilePathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::pathCorrectBackslashToW( oldFilePathCorrect, unicode_oldFilePath ); - - WChar unicode_newFilePath[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _newFilePath, unicode_newFilePath, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar newFilePathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::pathCorrectBackslashToW( newFilePathCorrect, unicode_newFilePath ); - -#if defined(MENGINE_DEBUG) - DWORD oldFileAttributes = ::GetFileAttributes( oldFilePathCorrect ); - - if( oldFileAttributes != INVALID_FILE_ATTRIBUTES && (oldFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) - { - LOGGER_WARNING( "invalid move old file '%ls' it's directory" - , newFilePathCorrect - ); - - return false; - } -#endif - - DWORD newFileAttributes = ::GetFileAttributes( newFilePathCorrect ); - - if( newFileAttributes != INVALID_FILE_ATTRIBUTES ) - { -#if defined(MENGINE_DEBUG) - if( (newFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) - { - LOGGER_WARNING( "invalid move file '%ls' it's directory" - , newFilePathCorrect - ); - - return false; - } -#endif - - if( ::DeleteFile( newFilePathCorrect ) == FALSE ) - { - LOGGER_ERROR( "invalid move file '%ls' %ls" - , newFilePathCorrect - , Helper::Win32GetLastErrorMessageW() - ); - } - } - - if( ::MoveFile( oldFilePathCorrect, newFilePathCorrect ) == FALSE ) - { - LOGGER_ERROR( "file '%ls' move to '%ls' %ls" - , oldFilePathCorrect - , newFilePathCorrect - , Helper::Win32GetLastErrorMessageW() - ); - - return false; - } - - return true; - } - ////////////////////////////////////////////////////////////////////////// - bool Win32PlatformService::findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const - { - WChar unicode_base[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _base, unicode_base, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar unicode_mask[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _mask, unicode_mask, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - WChar unicode_fullbase[MENGINE_MAX_PATH + 1] = {L'\0'}; - ::GetFullPathName( unicode_base, MENGINE_MAX_PATH, unicode_fullbase, NULL ); - - Helper::LambdaListDirectoryFilePath lambda_listdirectory = [_lambda]( const WChar * _filePath ) - { - Char utf8_filepath[MENGINE_MAX_PATH + 1] = {'\0'}; - if( Helper::unicodeToUtf8( _filePath, utf8_filepath, MENGINE_MAX_PATH ) == false ) - { - return false; - } - - FilePath fp = Helper::stringizeFilePath( utf8_filepath ); - - bool result = _lambda( fp ); - - return result; - }; - - bool stop; - if( Helper::Win32ListDirectory( unicode_fullbase, unicode_mask, unicode_path, lambda_listdirectory, &stop ) == false ) - { - return false; - } - - MENGINE_UNUSED( stop ); - - return true; - } - ////////////////////////////////////////////////////////////////////////// - uint64_t Win32PlatformService::getFileTime( const Char * _filePath ) const - { - WChar unicode_filePath[MENGINE_MAX_PATH + 1] = {L'\0'}; - Helper::utf8ToUnicode( _filePath, unicode_filePath, MENGINE_MAX_PATH ); - - HANDLE handle = ::CreateFile( unicode_filePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - - if( handle == INVALID_HANDLE_VALUE ) - { - LOGGER_ERROR( "get file time '%ls' invalid CreateFile %ls" - , unicode_filePath - , Helper::Win32GetLastErrorMessageW() - ); - - return 0U; - } - - FILETIME creation; - FILETIME access; - FILETIME write; - - BOOL result = ::GetFileTime( handle, &creation, &access, &write ); - - if( result == FALSE ) - { - ::CloseHandle( handle ); - - LOGGER_ERROR( "get file time '%ls' invalid GetFileTime %ls" - , unicode_filePath - , Helper::Win32GetLastErrorMessageW() - ); - - return 0U; - } - - ::CloseHandle( handle ); - - time_t time = Helper::Win32FileTimeToUnixTime( &write ); - - return time; - } - ////////////////////////////////////////////////////////////////////////// bool Win32PlatformService::createDirectoryUser_( const WChar * _userPath, const WChar * _directoryPath, const WChar * _file, const void * _data, size_t _size ) { WChar szPath[MENGINE_MAX_PATH + 1] = {L'\0'}; @@ -3184,9 +2741,9 @@ namespace Mengine StdString::wcscat( szPath, pathCorrect ); - if( this->existFile_( szPath ) == false ) + if( Helper::Win32ExistFile( szPath ) == false ) { - if( this->createDirectory_( _userPath, _directoryPath ) == false ) + if( Helper::Win32CreateDirectory( _userPath, _directoryPath ) == false ) { LOGGER_ERROR( "directory '%ls:%ls' invalid createDirectory '%ls'" , pathCorrect @@ -3294,7 +2851,7 @@ namespace Mengine StdString::wcscat( szPath, unicode_filePath_correct ); - if( this->existFile_( szPath ) == false ) + if( Helper::Win32ExistFile( szPath ) == false ) { return false; } @@ -3319,14 +2876,14 @@ namespace Mengine , _filePath ); - WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _directoryPath, unicode_path, MENGINE_MAX_PATH ) == false ) + WChar unicode_directoryPath[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _directoryPath, unicode_directoryPath, MENGINE_MAX_PATH ) == false ) { return false; } - WChar unicode_file[MENGINE_MAX_PATH + 1] = {L'\0'}; - if( Helper::utf8ToUnicode( _filePath, unicode_file, MENGINE_MAX_PATH ) == false ) + WChar unicode_filePath[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _filePath, unicode_filePath, MENGINE_MAX_PATH ) == false ) { return false; } @@ -3342,7 +2899,7 @@ namespace Mengine return false; } - if( this->createDirectoryUser_( szPath, unicode_path, unicode_file, _data, _size ) == false ) + if( this->createDirectoryUser_( szPath, unicode_directoryPath, unicode_filePath, _data, _size ) == false ) { LOGGER_ERROR( "'%s:%s' invalid createDirectoryUser_ '%ls'" , _directoryPath diff --git a/src/Platforms/Win32Platform/Win32PlatformService.h b/src/Platforms/Win32Platform/Win32PlatformService.h index f23c114b15..a0cd9074b2 100644 --- a/src/Platforms/Win32Platform/Win32PlatformService.h +++ b/src/Platforms/Win32Platform/Win32PlatformService.h @@ -122,25 +122,6 @@ namespace Mengine bool openMail( const Char * _email, const Char * _subject, const Char * _body ) override; bool openDeleteAccount() override; - public: - bool existDirectory( const Char * _path, const Char * _directory ) const override; - bool createDirectory( const Char * _path, const Char * _directory ) override; - - public: - bool existFile( const Char * _utf8Path ) override; - bool removeFile( const Char * _filePath ) override; - bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) override; - - public: - bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const override; - - public: - uint64_t getFileTime( const Char * _filePath ) const override; - - protected: - bool existFile_( const WChar * _filePath ); - bool createDirectory_( const WChar * _path, const WChar * _directory ); - protected: bool getSpecialFolderPath_( DWORD _flag, WChar * const _path ) const; diff --git a/src/Platforms/iOSPlatform/iOSPlatformService.mm b/src/Platforms/iOSPlatform/iOSPlatformService.mm index d87bf40040..ffb4730578 100644 --- a/src/Platforms/iOSPlatform/iOSPlatformService.mm +++ b/src/Platforms/iOSPlatform/iOSPlatformService.mm @@ -1522,7 +1522,7 @@ static void SDL_LogOutputFunction( void * userdata, int category, SDL_LogPriorit namespace Detail { ////////////////////////////////////////////////////////////////////////// - static bool s_createDirectoryFullpath( const Char * _fullpath ) + static bool createDirectoryFullpath(const Char * _fullpath ) { int status = ::mkdir( _fullpath, S_IRWXU ); @@ -1538,7 +1538,7 @@ static bool s_createDirectoryFullpath( const Char * _fullpath ) return true; } ////////////////////////////////////////////////////////////////////////// - static bool s_isDirectoryFullpath( const Char * _fullpath ) + static bool isDirectoryFullpath(const Char * _fullpath ) { struct stat sb; int err = ::stat( _fullpath, &sb ); @@ -1580,7 +1580,7 @@ static bool s_isDirectoryFullpath( const Char * _fullpath ) return true; // let it be } - bool exist = Detail::s_isDirectoryFullpath( pathFull ); + bool exist = Detail::isDirectoryFullpath(pathFull); return exist; } @@ -1607,7 +1607,7 @@ static bool s_isDirectoryFullpath( const Char * _fullpath ) Char pathTestDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; MENGINE_SNPRINTF( pathTestDirectory, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - if( Detail::s_isDirectoryFullpath( pathTestDirectory ) == true ) + if(Detail::isDirectoryFullpath(pathTestDirectory) == true ) { return true; } @@ -1634,7 +1634,7 @@ static bool s_isDirectoryFullpath( const Char * _fullpath ) MENGINE_SNPRINTF( pathTestDirectory, MENGINE_MAX_PATH, "%s%s", _path, pathDirectory ); - if( Detail::s_isDirectoryFullpath( pathTestDirectory ) == true ) + if(Detail::isDirectoryFullpath( pathTestDirectory ) == true ) { break; } @@ -1653,7 +1653,7 @@ static bool s_isDirectoryFullpath( const Char * _fullpath ) Char pathCreateDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; MENGINE_SNPRINTF( pathCreateDirectory, MENGINE_MAX_PATH, "%s%s", _path, path_str ); - if( Detail::s_createDirectoryFullpath( pathCreateDirectory ) == false ) + if(Detail::createDirectoryFullpath(pathCreateDirectory) == false ) { return false; } diff --git a/src/Plugins/AppleAdjustPlugin/AppleAdjustScriptEmbedding.mm b/src/Plugins/AppleAdjustPlugin/AppleAdjustScriptEmbedding.mm index 89e52c4a0b..33995e1b25 100644 --- a/src/Plugins/AppleAdjustPlugin/AppleAdjustScriptEmbedding.mm +++ b/src/Plugins/AppleAdjustPlugin/AppleAdjustScriptEmbedding.mm @@ -17,13 +17,13 @@ namespace Detail { ////////////////////////////////////////////////////////////////////////// - static bool s_AppleAdjust_eventTraking( const ConstString & _token ) + static bool AppleAdjust_eventTraking(const ConstString & _token ) { APPLE_ADJUST_SERVICE() ->eventTraking( _token ); } ////////////////////////////////////////////////////////////////////////// - static bool s_AppleAdjust_revenueTracking( const ConstString & _token, double _amount, const ConstString & _currency ) + static bool AppleAdjust_revenueTracking(const ConstString & _token, double _amount, const ConstString & _currency ) { APPLE_ADJUST_SERVICE() ->revenueTracking( _token, _amount, _currency ); @@ -44,8 +44,9 @@ static bool s_AppleAdjust_revenueTracking( const ConstString & _token, double _a SCRIPT_SERVICE() ->setAvailablePlugin( "AppleAdjust", true ); - pybind::def_function( _kernel, "appleAdjustEventTraking", &Detail::s_AppleAdjust_eventTraking ); - pybind::def_function( _kernel, "appleAdjustRevenueTracking", &Detail::s_AppleAdjust_revenueTracking ); + pybind::def_function( _kernel, "appleAdjustEventTraking", &Detail::AppleAdjust_eventTraking ); + pybind::def_function( _kernel, "appleAdjustRevenueTracking", + &Detail::AppleAdjust_revenueTracking ); return true; } diff --git a/src/Plugins/AppleAppLovinPlugin/AppleAppLovinScriptEmbedding.mm b/src/Plugins/AppleAppLovinPlugin/AppleAppLovinScriptEmbedding.mm index 046f0d2c47..8d42df9412 100644 --- a/src/Plugins/AppleAppLovinPlugin/AppleAppLovinScriptEmbedding.mm +++ b/src/Plugins/AppleAppLovinPlugin/AppleAppLovinScriptEmbedding.mm @@ -80,7 +80,7 @@ void onAppleAppLovinBannerDidPayRevenueForAd(const Params & _params) override } }; ////////////////////////////////////////////////////////////////////////// - static bool s_appleAppLovin_initBanner( const ConstString & _adUnitId, const ConstString & _placement, const pybind::dict & _cbs, const pybind::args & _args ) + static bool appleAppLovin_initBanner(const ConstString & _adUnitId, const ConstString & _placement, const pybind::dict & _cbs, const pybind::args & _args ) { AppleAppLovinBannerProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -90,7 +90,7 @@ static bool s_appleAppLovin_initBanner( const ConstString & _adUnitId, const Con return result; } ////////////////////////////////////////////////////////////////////////// - PyObject * s_appleAppLovin_getBannerViewport( pybind::kernel_interface * _kernel, const ConstString & _adUnitId ) + PyObject * appleAppLovin_getBannerViewport(pybind::kernel_interface * _kernel, const ConstString & _adUnitId ) { Viewport viewport; bool result = APPLE_APPLOVIN_SERVICE() @@ -157,7 +157,7 @@ void onAppleAppLovinInterstitialDidPayRevenueForAd( const Params & _params ) ove } }; ////////////////////////////////////////////////////////////////////////// - static bool s_appleAppLovin_initInterstitial( const ConstString & _adUnitId, const pybind::dict & _cbs, const pybind::args & _args ) + static bool appleAppLovin_initInterstitial(const ConstString & _adUnitId, const pybind::dict & _cbs, const pybind::args & _args ) { AppleAppLovinInterstitialProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -233,7 +233,7 @@ void onAppleAppLovinRewardedDidPayRevenueForAd( const Params & _params ) overrid } }; ////////////////////////////////////////////////////////////////////////// - static bool s_appleAppLovin_initRewarded( const ConstString & _adUnitId, const pybind::dict & _cbs, const pybind::args & _args ) + static bool appleAppLovin_initRewarded(const ConstString & _adUnitId, const pybind::dict & _cbs, const pybind::args & _args ) { AppleAppLovinRewardedProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -268,7 +268,7 @@ void onAppleAppLovinConsentFlowShowFailed() override } }; ////////////////////////////////////////////////////////////////////////// - static void s_appleAppLovin_loadAndShowCMPFlow( const pybind::dict & _cbs, const pybind::args & _args ) + static void appleAppLovin_loadAndShowCMPFlow(const pybind::dict & _cbs, const pybind::args & _args ) { AppleAppLovinConsentFlowProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -293,23 +293,23 @@ static void s_appleAppLovin_loadAndShowCMPFlow( const pybind::dict & _cbs, const AppleAppLovinServiceInterface * service = APPLE_APPLOVIN_SERVICE(); - pybind::def_function_args( _kernel, "appleAppLovinInitBanner", &Detail::s_appleAppLovin_initBanner ); + pybind::def_function_args( _kernel, "appleAppLovinInitBanner", &Detail::appleAppLovin_initBanner ); pybind::def_functor( _kernel, "appleAppLovinShowBanner", service, &AppleAppLovinServiceInterface::showBanner ); pybind::def_functor( _kernel, "appleAppLovinHideBanner", service, &AppleAppLovinServiceInterface::hideBanner ); - pybind::def_function_kernel( _kernel, "appleAppLovinGetBannerViewport", &Detail::s_appleAppLovin_getBannerViewport ); + pybind::def_function_kernel( _kernel, "appleAppLovinGetBannerViewport", &Detail::appleAppLovin_getBannerViewport ); - pybind::def_function_args( _kernel, "appleAppLovinInitInterstitial", &Detail::s_appleAppLovin_initInterstitial ); + pybind::def_function_args( _kernel, "appleAppLovinInitInterstitial", &Detail::appleAppLovin_initInterstitial ); pybind::def_functor( _kernel, "appleAppLovinCanYouShowInterstitial", service, &AppleAppLovinServiceInterface::canYouShowInterstitial ); pybind::def_functor( _kernel, "appleAppLovinShowInterstitial", service, &AppleAppLovinServiceInterface::showInterstitial ); - pybind::def_function_args( _kernel, "appleAppLovinInitRewarded", &Detail::s_appleAppLovin_initRewarded ); + pybind::def_function_args( _kernel, "appleAppLovinInitRewarded", &Detail::appleAppLovin_initRewarded ); pybind::def_functor( _kernel, "appleAppLovinCanOfferRewarded", service, &AppleAppLovinServiceInterface::canOfferRewarded ); pybind::def_functor( _kernel, "appleAppLovinCanYouShowRewarded", service, &AppleAppLovinServiceInterface::canYouShowRewarded ); pybind::def_functor( _kernel, "appleAppLovinShowRewarded", service, &AppleAppLovinServiceInterface::showRewarded ); pybind::def_functor( _kernel, "appleAppLovinHasSupportedCMP", service, &AppleAppLovinServiceInterface::hasSupportedCMP ); pybind::def_functor( _kernel, "appleAppLovinIsConsentFlowUserGeographyGDPR", service, &AppleAppLovinServiceInterface::isConsentFlowUserGeographyGDPR ); - pybind::def_function_args( _kernel, "appleAppLovinLoadAndShowCMPFlow", &Detail::s_appleAppLovin_loadAndShowCMPFlow ); + pybind::def_function_args( _kernel, "appleAppLovinLoadAndShowCMPFlow", &Detail::appleAppLovin_loadAndShowCMPFlow ); pybind::def_functor( _kernel, "appleAppLovinShowMediationDebugger", service, &AppleAppLovinServiceInterface::showMediationDebugger ); return true; diff --git a/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingScriptEmbedding.mm b/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingScriptEmbedding.mm index bfda84d180..3b2f37e779 100644 --- a/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingScriptEmbedding.mm +++ b/src/Plugins/AppleAppTrackingPlugin/AppleAppTrackingScriptEmbedding.mm @@ -17,7 +17,7 @@ namespace Detail { ////////////////////////////////////////////////////////////////////////// - static void s_AppleAppTracking_authorization( const pybind::object & _cb, const pybind::args & _args ) + static void AppleAppTracking_authorization(const pybind::object & _cb, const pybind::args & _args ) { APPLE_APPTRACKING_SERVICE() ->authorization( [_cb, _args]( EAppleAppTrackingAuthorization _status, const Char * _idfa ) @@ -49,7 +49,7 @@ static void s_AppleAppTracking_authorization( const pybind::object & _cb, const .def( "EAATA_NOT_DETERMINED", EAATA_NOT_DETERMINED ) ; - pybind::def_function_args( _kernel, "appleAppTrackingAuthorization", &Detail::s_AppleAppTracking_authorization ); + pybind::def_function_args( _kernel, "appleAppTrackingAuthorization", &Detail::AppleAppTracking_authorization ); return true; } diff --git a/src/Plugins/AppleFacebookPlugin/AppleFacebookScriptEmbedding.mm b/src/Plugins/AppleFacebookPlugin/AppleFacebookScriptEmbedding.mm index a1ff025c10..d8fa0cb984 100644 --- a/src/Plugins/AppleFacebookPlugin/AppleFacebookScriptEmbedding.mm +++ b/src/Plugins/AppleFacebookPlugin/AppleFacebookScriptEmbedding.mm @@ -69,7 +69,7 @@ void onFacebookProfilePictureLinkGetError( int32_t _code, const Char * _errorMes } }; ////////////////////////////////////////////////////////////////////////// - static void s_AppleFacebook_setProvider( const pybind::dict & _cbs, const pybind::args & _args ) + static void AppleFacebook_setProvider(const pybind::dict & _cbs, const pybind::args & _args ) { AppleFacebookProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -77,7 +77,7 @@ static void s_AppleFacebook_setProvider( const pybind::dict & _cbs, const pybind ->setProvider( provider ); } ////////////////////////////////////////////////////////////////////////// - static PyObject * s_AppleFacebook_getAccessToken( pybind::kernel_interface * _kernel ) + static PyObject * AppleFacebook_getAccessToken(pybind::kernel_interface * _kernel ) { Char token[256 + 1] = {'\0'}; if( APPLE_FACEBOOK_SERVICE() @@ -91,7 +91,7 @@ static void s_AppleFacebook_setProvider( const pybind::dict & _cbs, const pybind return token_py; } ////////////////////////////////////////////////////////////////////////// - static PyObject * s_AppleFacebook_getUserId( pybind::kernel_interface * _kernel ) + static PyObject * AppleFacebook_getUserId(pybind::kernel_interface * _kernel ) { Char userId[256 + 1] = {'\0'}; if( APPLE_FACEBOOK_SERVICE() @@ -122,13 +122,13 @@ static void s_AppleFacebook_setProvider( const pybind::dict & _cbs, const pybind AppleFacebookServiceInterface * service = APPLE_FACEBOOK_SERVICE(); - pybind::def_function_args( _kernel, "appleFacebookSetProvider", &Detail::s_AppleFacebook_setProvider ); + pybind::def_function_args( _kernel, "appleFacebookSetProvider", &Detail::AppleFacebook_setProvider ); pybind::def_functor( _kernel, "appleFacebookLogin", service, &AppleFacebookServiceInterface::login ); pybind::def_functor( _kernel, "appleFacebookLogout", service, &AppleFacebookServiceInterface::logout ); pybind::def_functor( _kernel, "appleFacebookIsLoggedIn", service, &AppleFacebookServiceInterface::isLoggedIn ); - pybind::def_function_kernel( _kernel, "appleFacebookGetAccessToken", &Detail::s_AppleFacebook_getAccessToken ); - pybind::def_function_kernel( _kernel, "appleFacebookGetUserId", &Detail::s_AppleFacebook_getUserId ); + pybind::def_function_kernel( _kernel, "appleFacebookGetAccessToken", &Detail::AppleFacebook_getAccessToken ); + pybind::def_function_kernel( _kernel, "appleFacebookGetUserId", &Detail::AppleFacebook_getUserId ); pybind::def_functor( _kernel, "appleFacebookShareLink", service, &AppleFacebookServiceInterface::shareLink ); pybind::def_functor( _kernel, "appleFacebookGetProfilePictureLink", service, &AppleFacebookServiceInterface::getProfilePictureLink ); diff --git a/src/Plugins/AppleGameCenterPlugin/AppleGameCenterScriptEmbedding.mm b/src/Plugins/AppleGameCenterPlugin/AppleGameCenterScriptEmbedding.mm index f4a2214ba8..e92effb214 100644 --- a/src/Plugins/AppleGameCenterPlugin/AppleGameCenterScriptEmbedding.mm +++ b/src/Plugins/AppleGameCenterPlugin/AppleGameCenterScriptEmbedding.mm @@ -39,7 +39,7 @@ void onAppleGameCenterSynchronizate( bool _successful ) override } }; ////////////////////////////////////////////////////////////////////////// - static void s_AppleGameCenter_setProvider( const pybind::dict & _cbs, const pybind::args & _args ) + static void AppleGameCenter_setProvider(const pybind::dict & _cbs, const pybind::args & _args ) { AppleGameCenterProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -47,13 +47,13 @@ static void s_AppleGameCenter_setProvider( const pybind::dict & _cbs, const pybi ->setProvider( provider ); } ////////////////////////////////////////////////////////////////////////// - static void s_AppleGameCenter_removeProvider() + static void AppleGameCenter_removeProvider() { APPLE_GAMECENTER_SERVICE() ->setProvider( nullptr ); } ////////////////////////////////////////////////////////////////////////// - static bool s_AppleGameCenter_reportAchievement( const ConstString & _achievementName, double _percentComplete, const pybind::object & _cb, const pybind::args & _args ) + static bool AppleGameCenter_reportAchievement(const ConstString & _achievementName, double _percentComplete, const pybind::object & _cb, const pybind::args & _args ) { bool result = APPLE_GAMECENTER_SERVICE() ->reportAchievement( _achievementName, _percentComplete, [_cb, _args]( bool _successful ) @@ -64,7 +64,7 @@ static bool s_AppleGameCenter_reportAchievement( const ConstString & _achievemen return result; } ////////////////////////////////////////////////////////////////////////// - static bool s_AppleGameCenter_reportScore( const ConstString & _key, int64_t _score, const pybind::object & _cb, const pybind::args & _args ) + static bool AppleGameCenter_reportScore( const ConstString & _key, int64_t _score, const pybind::object & _cb, const pybind::args & _args ) { bool result = APPLE_GAMECENTER_SERVICE() ->reportScore( _key, _score, [_cb, _args]( bool _successful ) @@ -92,14 +92,14 @@ static bool s_AppleGameCenter_reportScore( const ConstString & _key, int64_t _sc AppleGameCenterServiceInterface * service = APPLE_GAMECENTER_SERVICE(); - pybind::def_function_args( _kernel, "appleGameCenterSetProvider", &Detail::s_AppleGameCenter_setProvider ); - pybind::def_function( _kernel, "appleGameCenterRemoveProvider", &Detail::s_AppleGameCenter_removeProvider ); + pybind::def_function_args( _kernel, "appleGameCenterSetProvider", &Detail::AppleGameCenter_setProvider ); + pybind::def_function( _kernel, "appleGameCenterRemoveProvider", &Detail::AppleGameCenter_removeProvider ); pybind::def_functor( _kernel, "appleGameCenterConnect", service, &AppleGameCenterServiceInterface::connect ); pybind::def_functor( _kernel, "appleGameCenterIsConnect", service, &AppleGameCenterServiceInterface::isConnect ); - pybind::def_function_args( _kernel, "appleGameCenterReportAchievement", &Detail::s_AppleGameCenter_reportAchievement ); + pybind::def_function_args( _kernel, "appleGameCenterReportAchievement", &Detail::AppleGameCenter_reportAchievement ); pybind::def_functor( _kernel, "appleGameCenterCheckAchievement", service, &AppleGameCenterServiceInterface::checkAchievement ); pybind::def_functor( _kernel, "appleGameCenterResetAchievements", service, &AppleGameCenterServiceInterface::resetAchievements ); - pybind::def_function_args( _kernel, "appleGameCenterReportScore", &Detail::s_AppleGameCenter_reportScore ); + pybind::def_function_args( _kernel, "appleGameCenterReportScore", &Detail::AppleGameCenter_reportScore ); return true; } diff --git a/src/Plugins/AppleMARSDKPlugin/AppleMARSDKScriptEmbedding.mm b/src/Plugins/AppleMARSDKPlugin/AppleMARSDKScriptEmbedding.mm index 3ed4c4de38..0b76d24473 100644 --- a/src/Plugins/AppleMARSDKPlugin/AppleMARSDKScriptEmbedding.mm +++ b/src/Plugins/AppleMARSDKPlugin/AppleMARSDKScriptEmbedding.mm @@ -128,7 +128,7 @@ void onAdRewardedDidFinished( const Char * _itemName, uint32_t _itemNum ) overri ////////////////////////////////////////////////////////////////////////// typedef IntrusivePtr PythonAppleMARSDKProviderPtr; ////////////////////////////////////////////////////////////////////////// - static void s_AppleMARSDK_setProvider( pybind::kernel_interface * _kernel, const pybind::dict & _cbs, const pybind::args & _args ) + static void AppleMARSDK_setProvider(pybind::kernel_interface * _kernel, const pybind::dict & _cbs, const pybind::args & _args ) { AppleMARSDKProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -136,7 +136,7 @@ static void s_AppleMARSDK_setProvider( pybind::kernel_interface * _kernel, const ->setProvider( provider ); } ////////////////////////////////////////////////////////////////////////// - static bool s_AppleMARSDK_login() + static bool AppleMARSDK_login() { bool result = APPLE_MARSDK_SERVICE() ->login(); @@ -144,7 +144,7 @@ static bool s_AppleMARSDK_login() return result; } ////////////////////////////////////////////////////////////////////////// - static bool s_AppleMARSDK_logout() + static bool AppleMARSDK_logout() { bool result = APPLE_MARSDK_SERVICE() ->logout(); @@ -152,7 +152,7 @@ static bool s_AppleMARSDK_logout() return result; } ////////////////////////////////////////////////////////////////////////// - static bool s_AppleMARSDK_switchAccount() + static bool AppleMARSDK_switchAccount() { bool result = APPLE_MARSDK_SERVICE() ->switchAccount(); @@ -160,37 +160,37 @@ static bool s_AppleMARSDK_switchAccount() return result; } ////////////////////////////////////////////////////////////////////////// - static void s_AppleMARSDK_requestNonConsumablePurchased() + static void AppleMARSDK_requestNonConsumablePurchased() { APPLE_MARSDK_SERVICE() ->requestNonConsumablePurchased(); } ////////////////////////////////////////////////////////////////////////// - static void s_AppleMARSDK_submitExtendedData( const Char * _data ) + static void AppleMARSDK_submitExtendedData(const Char * _data ) { APPLE_MARSDK_SERVICE() ->submitExtendedData( _data ); } ////////////////////////////////////////////////////////////////////////// - static void s_AppleMARSDK_submitPaymentData( const Char * _data ) + static void AppleMARSDK_submitPaymentData(const Char * _data ) { APPLE_MARSDK_SERVICE() ->submitPaymentData( _data ); } ////////////////////////////////////////////////////////////////////////// - static void s_AppleMARSDK_propComplete( const ConstString & _orderId ) + static void AppleMARSDK_propComplete(const ConstString & _orderId ) { APPLE_MARSDK_SERVICE() ->propComplete( _orderId ); } ////////////////////////////////////////////////////////////////////////// - static void s_AppleMARSDK_showRewardVideoAd( const ConstString & _itemName, uint32_t _itemNum ) + static void AppleMARSDK_showRewardVideoAd(const ConstString & _itemName, uint32_t _itemNum ) { APPLE_MARSDK_SERVICE() ->showRewardVideoAd( _itemName, _itemNum ); } ////////////////////////////////////////////////////////////////////////// - static int64_t s_AppleMARSDK_getInternetDate() + static int64_t AppleMARSDK_getInternetDate() { int64_t date = APPLE_MARSDK_SERVICE() ->getInternetDate(); @@ -213,16 +213,16 @@ static int64_t s_AppleMARSDK_getInternetDate() SCRIPT_SERVICE() ->setAvailablePlugin( "AppleMARSDK", true ); - pybind::def_function_kernel_args( _kernel, "appleMARSDKSetProvider", &Detail::s_AppleMARSDK_setProvider ); - pybind::def_function( _kernel, "appleMARSDKLogin", &Detail::s_AppleMARSDK_login ); - pybind::def_function( _kernel, "appleMARSDKLogout", &Detail::s_AppleMARSDK_logout ); - pybind::def_function( _kernel, "appleMARSDKSwitchAccount", &Detail::s_AppleMARSDK_switchAccount ); - pybind::def_function( _kernel, "appleMARSDKRequestNonConsumablePurchased", &Detail::s_AppleMARSDK_requestNonConsumablePurchased ); - pybind::def_function( _kernel, "appleMARSDKSubmitExtendedData", &Detail::s_AppleMARSDK_submitExtendedData ); - pybind::def_function( _kernel, "appleMARSDKSubmitPaymentData", &Detail::s_AppleMARSDK_submitPaymentData ); - pybind::def_function( _kernel, "appleMARSDKPropComplete", &Detail::s_AppleMARSDK_propComplete ); - pybind::def_function( _kernel, "appleMARSDKShowRewardVideoAd", &Detail::s_AppleMARSDK_showRewardVideoAd ); - pybind::def_function( _kernel, "appleMARSDKGetInternetDate", &Detail::s_AppleMARSDK_getInternetDate ); + pybind::def_function_kernel_args( _kernel, "appleMARSDKSetProvider", &Detail::AppleMARSDK_setProvider ); + pybind::def_function( _kernel, "appleMARSDKLogin", &Detail::AppleMARSDK_login ); + pybind::def_function( _kernel, "appleMARSDKLogout", &Detail::AppleMARSDK_logout ); + pybind::def_function( _kernel, "appleMARSDKSwitchAccount", &Detail::AppleMARSDK_switchAccount ); + pybind::def_function( _kernel, "appleMARSDKRequestNonConsumablePurchased", &Detail::AppleMARSDK_requestNonConsumablePurchased ); + pybind::def_function( _kernel, "appleMARSDKSubmitExtendedData", &Detail::AppleMARSDK_submitExtendedData ); + pybind::def_function( _kernel, "appleMARSDKSubmitPaymentData", &Detail::AppleMARSDK_submitPaymentData ); + pybind::def_function( _kernel, "appleMARSDKPropComplete", &Detail::AppleMARSDK_propComplete ); + pybind::def_function( _kernel, "appleMARSDKShowRewardVideoAd", &Detail::AppleMARSDK_showRewardVideoAd ); + pybind::def_function( _kernel, "appleMARSDKGetInternetDate", &Detail::AppleMARSDK_getInternetDate ); return true; } diff --git a/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseScriptEmbedding.mm b/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseScriptEmbedding.mm index 90a48e30dd..87b69132f6 100644 --- a/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseScriptEmbedding.mm +++ b/src/Plugins/AppleStoreInAppPurchasePlugin/AppleStoreInAppPurchaseScriptEmbedding.mm @@ -89,7 +89,7 @@ void onPaymentQueueUpdatedTransactionDeferred( const AppleStoreInAppPurchasePaym } }; ////////////////////////////////////////////////////////////////////////// - static void s_AppleStoreInAppPurchase_setPaymentTransactionProvider( const pybind::dict & _cbs, const pybind::args & _args ) + static void AppleStoreInAppPurchase_setPaymentTransactionProvider(const pybind::dict & _cbs, const pybind::args & _args ) { AppleStoreInAppPurchasePaymentTransactionProviderInterfacePtr provider = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -97,7 +97,7 @@ static void s_AppleStoreInAppPurchase_setPaymentTransactionProvider( const pybin ->setPaymentTransactionProvider( provider ); } ////////////////////////////////////////////////////////////////////////// - static void s_AppleStoreInAppPurchase_removePaymentTransactionProvider() + static void AppleStoreInAppPurchase_removePaymentTransactionProvider() { APPLE_STOREINAPPPURCHASE_SERVICE() ->setPaymentTransactionProvider( nullptr ); @@ -137,7 +137,7 @@ void onProductFail( const AppleStoreInAppPurchaseProductsRequestInterfacePtr & _ } }; ////////////////////////////////////////////////////////////////////////// - static AppleStoreInAppPurchaseProductsRequestInterfacePtr s_AppleStoreInAppPurchase_requestProducts( const VectorConstString & _productIdentifiers, const pybind::dict & _cbs, const pybind::args & _args ) + static AppleStoreInAppPurchaseProductsRequestInterfacePtr AppleStoreInAppPurchase_requestProducts(const VectorConstString & _productIdentifiers, const pybind::dict & _cbs, const pybind::args & _args ) { AppleStoreInAppPurchaseProductsResponseInterfacePtr response = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, _cbs, _args ); @@ -178,11 +178,11 @@ static void s_AppleStoreInAppPurchase_restoreCompletedTransactions() AppleStoreInAppPurchaseServiceInterface * service = APPLE_STOREINAPPPURCHASE_SERVICE(); - pybind::def_function_args( _kernel, "appleStoreInAppPurchaseSetPaymentTransactionProvider", &Detail::s_AppleStoreInAppPurchase_setPaymentTransactionProvider ); - pybind::def_function( _kernel, "appleStoreInAppPurchaseRemovePaymentTransactionProvider", &Detail::s_AppleStoreInAppPurchase_removePaymentTransactionProvider ); + pybind::def_function_args( _kernel, "appleStoreInAppPurchaseSetPaymentTransactionProvider", &Detail::AppleStoreInAppPurchase_setPaymentTransactionProvider ); + pybind::def_function( _kernel, "appleStoreInAppPurchaseRemovePaymentTransactionProvider", &Detail::AppleStoreInAppPurchase_removePaymentTransactionProvider ); pybind::def_functor( _kernel, "appleStoreInAppPurchaseCanMakePayments", service, &AppleStoreInAppPurchaseServiceInterface::canMakePayments ); - pybind::def_function_args( _kernel, "appleStoreInAppPurchaseRequestProducts", &Detail::s_AppleStoreInAppPurchase_requestProducts ); + pybind::def_function_args( _kernel, "appleStoreInAppPurchaseRequestProducts", &Detail::AppleStoreInAppPurchase_requestProducts ); pybind::def_functor( _kernel, "appleStoreInAppPurchasePurchaseProduct", service, &AppleStoreInAppPurchaseServiceInterface::purchaseProduct ); pybind::def_functor( _kernel, "appleStoreInAppPurchaseRestoreCompletedTransactions", service, &AppleStoreInAppPurchaseServiceInterface::restoreCompletedTransactions ); diff --git a/src/Plugins/AreaOfInterestPlugin/AreaOfInterestScriptEmbedding.cpp b/src/Plugins/AreaOfInterestPlugin/AreaOfInterestScriptEmbedding.cpp index 81934336c2..a3e98b1fbc 100644 --- a/src/Plugins/AreaOfInterestPlugin/AreaOfInterestScriptEmbedding.cpp +++ b/src/Plugins/AreaOfInterestPlugin/AreaOfInterestScriptEmbedding.cpp @@ -51,7 +51,7 @@ namespace Mengine } }; ////////////////////////////////////////////////////////////////////////// - static PyObject * s_NodeAOITrigger_setEventListener( pybind::kernel_interface * _kernel, NodeAreaOfInterestTrigger * _node, PyObject * _args, PyObject * _kwds ) + static PyObject * NodeAOITrigger_setEventListener(pybind::kernel_interface * _kernel, NodeAreaOfInterestTrigger * _node, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -67,7 +67,7 @@ namespace Mengine return _kernel->ret_none(); } ////////////////////////////////////////////////////////////////////////// - static AreaOfInterestZoneInterfacePtr s_createAreaOfInterestZone() + static AreaOfInterestZoneInterfacePtr createAreaOfInterestZone() { AreaOfInterestZoneInterfacePtr zone = AREAOFINTEREST_SERVICE() ->createZone( MENGINE_DOCUMENT_PYBIND ); @@ -107,7 +107,7 @@ namespace Mengine .def( "getAreaOfInterestZone", &NodeAreaOfInterestTrigger::getAreaOfInterestZone ) .def( "setTriggerUserData", &NodeAreaOfInterestTrigger::setTriggerUserData ) .def( "getTriggerUserData", &NodeAreaOfInterestTrigger::getTriggerUserData ) - .def_static_native_kernel( "setEventListener", &Detail::s_NodeAOITrigger_setEventListener ) + .def_static_native_kernel( "setEventListener", &Detail::NodeAOITrigger_setEventListener ) ; pybind::interface_>( _kernel, "NodeAOIActor", false ) @@ -121,7 +121,7 @@ namespace Mengine .def( "getActorUserData", &NodeAreaOfInterestActor::getActorUserData ) ; - pybind::def_function( _kernel, "createAreaOfInterestZone", &Detail::s_createAreaOfInterestZone ); + pybind::def_function( _kernel, "createAreaOfInterestZone", &Detail::createAreaOfInterestZone ); Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); diff --git a/src/Plugins/AstralaxPlugin/AstralaxScriptEmbedding.cpp b/src/Plugins/AstralaxPlugin/AstralaxScriptEmbedding.cpp index da13afcb00..bb9f7f54eb 100644 --- a/src/Plugins/AstralaxPlugin/AstralaxScriptEmbedding.cpp +++ b/src/Plugins/AstralaxPlugin/AstralaxScriptEmbedding.cpp @@ -20,7 +20,7 @@ namespace Mengine namespace Detail { //////////////////////////////////////////////////////////////////////////// - static PyObject * s_AstralaxEmitter_setEventListener( pybind::kernel_interface * _kernel, AstralaxEmitter * _node, PyObject * _args, PyObject * _kwds ) + static PyObject * AstralaxEmitter_setEventListener( pybind::kernel_interface * _kernel, AstralaxEmitter * _node, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -34,7 +34,7 @@ namespace Mengine return _kernel->ret_none(); } ////////////////////////////////////////////////////////////////////////// - static void s_AstralaxEmitter_changeEmitterImage( pybind::kernel_interface * _kernel, AstralaxEmitter * _emitter, const ConstString & _emitterImageName ) + static void AstralaxEmitter_changeEmitterImage( pybind::kernel_interface * _kernel, AstralaxEmitter * _emitter, const ConstString & _emitterImageName ) { MENGINE_UNUSED( _kernel ); @@ -80,14 +80,14 @@ namespace Mengine .def( "setEmitterCameraRelative", &AstralaxEmitter::setEmitterCameraRelative ) .def( "setEmitterPositionProviderOriginOffset", &AstralaxEmitter::setEmitterPositionProviderOriginOffset ) - .def_static_kernel( "changeEmitterImage", &Detail::s_AstralaxEmitter_changeEmitterImage ) + .def_static_kernel( "changeEmitterImage", &Detail::AstralaxEmitter_changeEmitterImage ) .def( "removeEmitterImage", &AstralaxEmitter::removeEmitterImage ) .def( "changeEmitterPolygon", &AstralaxEmitter::changeEmitterPolygon ) .def( "removeEmitterPolygon", &AstralaxEmitter::removeEmitterPolygon ) .def( "setEmitterRandomMode", &AstralaxEmitter::setEmitterRandomMode ) .def( "getEmitterRandomMode", &AstralaxEmitter::getEmitterRandomMode ) - .def_static_native_kernel( "setEventListener", &Detail::s_AstralaxEmitter_setEventListener ) + .def_static_native_kernel( "setEventListener", &Detail::AstralaxEmitter_setEventListener ) ; Helper::registerScriptWrappingEx( _kernel, STRINGIZE_STRING_LOCAL( "ParticleEmitter2" ), MENGINE_DOCUMENT_FACTORABLE ); diff --git a/src/Plugins/DazzlePlugin/DazzlePlugin.cpp b/src/Plugins/DazzlePlugin/DazzlePlugin.cpp index 3e5c5ee0b5..83f92f87ec 100644 --- a/src/Plugins/DazzlePlugin/DazzlePlugin.cpp +++ b/src/Plugins/DazzlePlugin/DazzlePlugin.cpp @@ -35,7 +35,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static void * s_dz_malloc( dz_size_t _size, dz_userdata_t _ud ) + static void * dz_malloc(dz_size_t _size, dz_userdata_t _ud ) { DZ_UNUSED( _ud ); @@ -44,7 +44,7 @@ namespace Mengine return p; } ////////////////////////////////////////////////////////////////////////// - static void * s_dz_realloc( void * _ptr, dz_size_t _size, dz_userdata_t _ud ) + static void * dz_realloc(void * _ptr, dz_size_t _size, dz_userdata_t _ud ) { DZ_UNUSED( _ud ); @@ -53,14 +53,14 @@ namespace Mengine return p; } ////////////////////////////////////////////////////////////////////////// - static void s_dz_free( const void * _ptr, dz_userdata_t _ud ) + static void dz_free(const void * _ptr, dz_userdata_t _ud ) { DZ_UNUSED( _ud ); Helper::deallocateMemory( (void *)_ptr, "dazzle" ); } ////////////////////////////////////////////////////////////////////////// - static float s_dz_sqrtf( float _a, dz_userdata_t _ud ) + static float dz_sqrtf(float _a, dz_userdata_t _ud ) { DZ_UNUSED( _ud ); @@ -69,7 +69,7 @@ namespace Mengine return value; } ////////////////////////////////////////////////////////////////////////// - static float s_dz_cosf( float _a, dz_userdata_t _ud ) + static float dz_cosf(float _a, dz_userdata_t _ud ) { DZ_UNUSED( _ud ); @@ -78,7 +78,7 @@ namespace Mengine return value; } ////////////////////////////////////////////////////////////////////////// - static float s_dz_sinf( float _a, dz_userdata_t _ud ) + static float dz_sinf(float _a, dz_userdata_t _ud ) { DZ_UNUSED( _ud ); @@ -101,12 +101,12 @@ namespace Mengine bool DazzlePlugin::_initializePlugin() { dz_service_providers_t providers; - providers.f_malloc = &Detail::s_dz_malloc; - providers.f_realloc = &Detail::s_dz_realloc; - providers.f_free = &Detail::s_dz_free; - providers.f_sqrtf = &Detail::s_dz_sqrtf; - providers.f_cosf = &Detail::s_dz_cosf; - providers.f_sinf = &Detail::s_dz_sinf; + providers.f_malloc = &Detail::dz_malloc; + providers.f_realloc = &Detail::dz_realloc; + providers.f_free = &Detail::dz_free; + providers.f_sqrtf = &Detail::dz_sqrtf; + providers.f_cosf = &Detail::dz_cosf; + providers.f_sinf = &Detail::dz_sinf; dz_service_t * service; if( dz_service_create( &service, &providers, DZ_NULLPTR ) == DZ_FAILURE ) diff --git a/src/Plugins/DevToDebugPlugin/DevToDebugScriptEmbedding.cpp b/src/Plugins/DevToDebugPlugin/DevToDebugScriptEmbedding.cpp index a10c1a48be..479bf80fc4 100644 --- a/src/Plugins/DevToDebugPlugin/DevToDebugScriptEmbedding.cpp +++ b/src/Plugins/DevToDebugPlugin/DevToDebugScriptEmbedding.cpp @@ -37,7 +37,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static DevToDebugTabPtr s_addDevToDebugTab( const ConstString & _name ) + static DevToDebugTabPtr addDevToDebugTab( const ConstString & _name ) { DevToDebugTabInterfacePtr tab = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugTab" ), MENGINE_DOCUMENT_PYBIND ); @@ -52,7 +52,7 @@ namespace Mengine return DevToDebugTabPtr::dynamic_from( tab ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugTabPtr s_getDevToDebugTab( const ConstString & _name ) + static DevToDebugTabPtr getDevToDebugTab( const ConstString & _name ) { const DevToDebugTabInterfacePtr & tab = DEVTODEBUG_SERVICE() ->getTab( _name ); @@ -60,7 +60,7 @@ namespace Mengine return DevToDebugTabPtr::dynamic_from( tab ); } ////////////////////////////////////////////////////////////////////////// - static bool s_hasDevToDebugTab( const ConstString & _name ) + static bool hasDevToDebugTab(const ConstString & _name ) { bool result = DEVTODEBUG_SERVICE() ->hasTab( _name ); @@ -68,13 +68,13 @@ namespace Mengine return result; } ////////////////////////////////////////////////////////////////////////// - static void s_removeDevToDebugTab( const ConstString & _name ) + static void removeDevToDebugTab( const ConstString & _name ) { DEVTODEBUG_SERVICE() ->removeTab( _name ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugTab_addWidget( DevToDebugTab * _tab, const DevToDebugWidgetPtr & _widget ) + static void DevToDebugTab_addWidget( DevToDebugTab * _tab, const DevToDebugWidgetPtr & _widget ) { if( _widget == nullptr ) { @@ -86,14 +86,14 @@ namespace Mengine _tab->addWidget( _widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetPtr s_DevToDebugTab_findWidget( DevToDebugTab * _tab, const ConstString & _id ) + static DevToDebugWidgetPtr DevToDebugTab_findWidget( DevToDebugTab * _tab, const ConstString & _id ) { const DevToDebugWidgetInterfacePtr & widget = _tab->findWidget( _id ); return DevToDebugWidgetPtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetTextPtr s_createDevToDebugWidgetText( const ConstString & _id ) + static DevToDebugWidgetTextPtr createDevToDebugWidgetText( const ConstString & _id ) { DevToDebugWidgetInterfacePtr widget = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugWidgetText" ), MENGINE_DOCUMENT_PYBIND ); @@ -102,7 +102,7 @@ namespace Mengine return DevToDebugWidgetTextPtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetButtonPtr s_createDevToDebugWidgetButton( const ConstString & _id ) + static DevToDebugWidgetButtonPtr createDevToDebugWidgetButton( const ConstString & _id ) { DevToDebugWidgetInterfacePtr widget = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugWidgetButton" ), MENGINE_DOCUMENT_PYBIND ); @@ -111,7 +111,7 @@ namespace Mengine return DevToDebugWidgetButtonPtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetCheckboxPtr s_createDevToDebugWidgetCheckbox( const ConstString & _id ) + static DevToDebugWidgetCheckboxPtr createDevToDebugWidgetCheckbox( const ConstString & _id ) { DevToDebugWidgetInterfacePtr widget = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugWidgetCheckbox" ), MENGINE_DOCUMENT_PYBIND ); @@ -120,7 +120,7 @@ namespace Mengine return DevToDebugWidgetCheckboxPtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetCommandLinePtr s_createDevToDebugWidgetCommandLine( const ConstString & _id ) + static DevToDebugWidgetCommandLinePtr createDevToDebugWidgetCommandLine( const ConstString & _id ) { DevToDebugWidgetInterfacePtr widget = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugWidgetCommandLine" ), MENGINE_DOCUMENT_PYBIND ); @@ -129,7 +129,7 @@ namespace Mengine return DevToDebugWidgetCommandLinePtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetRadioButtonPtr s_createDevToDebugWidgetRadioButton( const ConstString & _id ) + static DevToDebugWidgetRadioButtonPtr createDevToDebugWidgetRadioButton( const ConstString & _id ) { DevToDebugWidgetInterfacePtr widget = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugWidgetRadioButton" ), MENGINE_DOCUMENT_PYBIND ); @@ -142,7 +142,7 @@ namespace Mengine return DevToDebugWidgetRadioButtonPtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugWidgetSelectorPtr s_createDevToDebugWidgetSelector( const ConstString & _id ) + static DevToDebugWidgetSelectorPtr createDevToDebugWidgetSelector( const ConstString & _id ) { DevToDebugWidgetInterfacePtr widget = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "DevToDebug" ), STRINGIZE_STRING_LOCAL( "DevToDebugWidgetSelector" ), MENGINE_DOCUMENT_PYBIND ); @@ -155,7 +155,7 @@ namespace Mengine return DevToDebugWidgetSelectorPtr::dynamic_from( widget ); } ////////////////////////////////////////////////////////////////////////// - static DevToDebugPropertyInterfacePtr s_createDevToDebugPropertyBoolean( const pybind::object & _cb, const pybind::args & _args ) + static DevToDebugPropertyInterfacePtr createDevToDebugPropertyBoolean( const pybind::object & _cb, const pybind::args & _args ) { DevToDebugPropertyInterfacePtr property; @@ -191,7 +191,7 @@ namespace Mengine return property; } ////////////////////////////////////////////////////////////////////////// - static DevToDebugPropertyInterfacePtr s_createDevToDebugPropertyString( const pybind::object & _cb, const pybind::args & _args ) + static DevToDebugPropertyInterfacePtr createDevToDebugPropertyString( const pybind::object & _cb, const pybind::args & _args ) { DevToDebugPropertyInterfacePtr property; @@ -227,7 +227,7 @@ namespace Mengine return property; } ////////////////////////////////////////////////////////////////////////// - static DevToDebugPropertyInterfacePtr s_createDevToDebugPropertyColor( const pybind::object & _cb, const pybind::args & _args ) + static DevToDebugPropertyInterfacePtr createDevToDebugPropertyColor( const pybind::object & _cb, const pybind::args & _args ) { DevToDebugPropertyInterfacePtr property; @@ -263,35 +263,35 @@ namespace Mengine return property; } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidget_setHide( DevToDebugWidget * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidget_setHide( DevToDebugWidget * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyBoolean( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyBoolean( _cb, _args ); _widget->setBaseProperty( STRINGIZE_STRING_LOCAL( "hide" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetText_setColor( DevToDebugWidgetText * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetText_setColor( DevToDebugWidgetText * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyColor( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyColor( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "color" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetText_setText( DevToDebugWidgetText * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetText_setText( DevToDebugWidgetText * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "content" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetButton_setTitle( DevToDebugWidgetButton * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetButton_setTitle( DevToDebugWidgetButton * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "title" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetButton_setClickEvent( DevToDebugWidgetButton * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetButton_setClickEvent( DevToDebugWidgetButton * _widget, const pybind::object & _cb, const pybind::args & _args ) { _widget->setClickEvent( [_cb, _args]() { @@ -299,21 +299,21 @@ namespace Mengine } ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetCheckbox_setTitle( DevToDebugWidgetCheckbox * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetCheckbox_setTitle( DevToDebugWidgetCheckbox * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "text" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetCheckbox_setValue( DevToDebugWidgetCheckbox * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetCheckbox_setValue( DevToDebugWidgetCheckbox * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyBoolean( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyBoolean( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "value" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetCheckbox_setChangeEvent( DevToDebugWidgetCheckbox * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetCheckbox_setChangeEvent( DevToDebugWidgetCheckbox * _widget, const pybind::object & _cb, const pybind::args & _args ) { _widget->setChangeEvent( [_cb, _args]( bool _value ) { @@ -321,21 +321,21 @@ namespace Mengine } ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetCommandLine_setTitle( DevToDebugWidgetCommandLine * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetCommandLine_setTitle( DevToDebugWidgetCommandLine * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "title" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetCommandLine_setPlaceholder( DevToDebugWidgetCommandLine * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetCommandLine_setPlaceholder( DevToDebugWidgetCommandLine * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "placeholder" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetCommandLine_setCommandEvent( DevToDebugWidgetCommandLine * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetCommandLine_setCommandEvent( DevToDebugWidgetCommandLine * _widget, const pybind::object & _cb, const pybind::args & _args ) { _widget->setCommandEvent( [_cb, _args]( const String & _value ) { @@ -343,14 +343,14 @@ namespace Mengine } ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetRadioButton_setTitle( DevToDebugWidgetRadioButton * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetRadioButton_setTitle( DevToDebugWidgetRadioButton * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "title" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetRadioButton_addState( DevToDebugWidgetRadioButton * _widget, const ConstString & _id, const String & _value ) + static void DevToDebugWidgetRadioButton_addState( DevToDebugWidgetRadioButton * _widget, const ConstString & _id, const String & _value ) { const DevToDebugPropertyInterfacePtr & property = _widget->getDataProperty( STRINGIZE_STRING_LOCAL( "content" ) ); @@ -359,7 +359,7 @@ namespace Mengine content->addState( _id, _value ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetRadioButton_setChangeEvent( DevToDebugWidgetRadioButton * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetRadioButton_setChangeEvent( DevToDebugWidgetRadioButton * _widget, const pybind::object & _cb, const pybind::args & _args ) { _widget->setChangeEvent( [_cb, _args]( const ConstString & _value ) { @@ -367,14 +367,14 @@ namespace Mengine } ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetSelector_setTitle( DevToDebugWidgetSelector * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetSelector_setTitle( DevToDebugWidgetSelector * _widget, const pybind::object & _cb, const pybind::args & _args ) { - DevToDebugPropertyInterfacePtr property = Detail::s_createDevToDebugPropertyString( _cb, _args ); + DevToDebugPropertyInterfacePtr property = Detail::createDevToDebugPropertyString( _cb, _args ); _widget->setDataProperty( STRINGIZE_STRING_LOCAL( "title" ), property ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetSelector_addState( DevToDebugWidgetSelector * _widget, const ConstString & _id, const String & _value ) + static void DevToDebugWidgetSelector_addState( DevToDebugWidgetSelector * _widget, const ConstString & _id, const String & _value ) { const DevToDebugPropertyInterfacePtr & property = _widget->getDataProperty( STRINGIZE_STRING_LOCAL( "content" ) ); @@ -383,7 +383,7 @@ namespace Mengine content->addState( _id, _value ); } ////////////////////////////////////////////////////////////////////////// - static void s_DevToDebugWidgetSelector_setChangeEvent( DevToDebugWidgetSelector * _widget, const pybind::object & _cb, const pybind::args & _args ) + static void DevToDebugWidgetSelector_setChangeEvent( DevToDebugWidgetSelector * _widget, const pybind::object & _cb, const pybind::args & _args ) { _widget->setChangeEvent( [_cb, _args]( const ConstString & _value ) { @@ -406,60 +406,60 @@ namespace Mengine SCRIPT_SERVICE() ->setAvailablePlugin( "DevToDebug", true ); - pybind::def_function( _kernel, "addDevToDebugTab", &Detail::s_addDevToDebugTab ); - pybind::def_function( _kernel, "getDevToDebugTab", &Detail::s_getDevToDebugTab ); - pybind::def_function( _kernel, "hasDevToDebugTab", &Detail::s_hasDevToDebugTab ); - pybind::def_function( _kernel, "removeDevToDebugTab", &Detail::s_removeDevToDebugTab ); + pybind::def_function( _kernel, "addDevToDebugTab", &Detail::addDevToDebugTab ); + pybind::def_function( _kernel, "getDevToDebugTab", &Detail::getDevToDebugTab ); + pybind::def_function( _kernel, "hasDevToDebugTab", &Detail::hasDevToDebugTab ); + pybind::def_function( _kernel, "removeDevToDebugTab", &Detail::removeDevToDebugTab ); - pybind::def_function( _kernel, "createDevToDebugWidgetText", &Detail::s_createDevToDebugWidgetText ); - pybind::def_function( _kernel, "createDevToDebugWidgetButton", &Detail::s_createDevToDebugWidgetButton ); - pybind::def_function( _kernel, "createDevToDebugWidgetCheckbox", &Detail::s_createDevToDebugWidgetCheckbox ); - pybind::def_function( _kernel, "createDevToDebugWidgetCommandLine", &Detail::s_createDevToDebugWidgetCommandLine ); - pybind::def_function( _kernel, "createDevToDebugWidgetRadioButton", &Detail::s_createDevToDebugWidgetRadioButton ); - pybind::def_function( _kernel, "createDevToDebugWidgetSelector", &Detail::s_createDevToDebugWidgetSelector ); + pybind::def_function( _kernel, "createDevToDebugWidgetText", &Detail::createDevToDebugWidgetText ); + pybind::def_function( _kernel, "createDevToDebugWidgetButton", &Detail::createDevToDebugWidgetButton ); + pybind::def_function( _kernel, "createDevToDebugWidgetCheckbox", &Detail::createDevToDebugWidgetCheckbox ); + pybind::def_function( _kernel, "createDevToDebugWidgetCommandLine", &Detail::createDevToDebugWidgetCommandLine ); + pybind::def_function( _kernel, "createDevToDebugWidgetRadioButton", &Detail::createDevToDebugWidgetRadioButton ); + pybind::def_function( _kernel, "createDevToDebugWidgetSelector", &Detail::createDevToDebugWidgetSelector ); pybind::interface_>( _kernel, "DevToDebugTab" ) - .def_static( "addWidget", &Detail::s_DevToDebugTab_addWidget ) - .def_static( "findWidget", &Detail::s_DevToDebugTab_findWidget ) + .def_static( "addWidget", &Detail::DevToDebugTab_addWidget ) + .def_static( "findWidget", &Detail::DevToDebugTab_findWidget ) ; pybind::interface_>( _kernel, "DevToDebugWidget" ) .def( "getId", &DevToDebugWidget::getId ) - .def_static_args( "setHide", &Detail::s_DevToDebugWidget_setHide ) + .def_static_args( "setHide", &Detail::DevToDebugWidget_setHide ) ; pybind::interface_>( _kernel, "DevToDebugWidgetText" ) - .def_static_args( "setColor", &Detail::s_DevToDebugWidgetText_setColor ) - .def_static_args( "setText", &Detail::s_DevToDebugWidgetText_setText ) + .def_static_args( "setColor", &Detail::DevToDebugWidgetText_setColor ) + .def_static_args( "setText", &Detail::DevToDebugWidgetText_setText ) ; pybind::interface_>( _kernel, "DevToDebugWidgetButton" ) - .def_static_args( "setTitle", &Detail::s_DevToDebugWidgetButton_setTitle ) - .def_static_args( "setClickEvent", &Detail::s_DevToDebugWidgetButton_setClickEvent ) + .def_static_args( "setTitle", &Detail::DevToDebugWidgetButton_setTitle ) + .def_static_args( "setClickEvent", &Detail::DevToDebugWidgetButton_setClickEvent ) ; pybind::interface_>( _kernel, "DevToDebugWidgetCheckbox" ) - .def_static_args( "setTitle", &Detail::s_DevToDebugWidgetCheckbox_setTitle ) - .def_static_args( "setValue", &Detail::s_DevToDebugWidgetCheckbox_setValue ) - .def_static_args( "setChangeEvent", &Detail::s_DevToDebugWidgetCheckbox_setChangeEvent ) + .def_static_args( "setTitle", &Detail::DevToDebugWidgetCheckbox_setTitle ) + .def_static_args( "setValue", &Detail::DevToDebugWidgetCheckbox_setValue ) + .def_static_args( "setChangeEvent", &Detail::DevToDebugWidgetCheckbox_setChangeEvent ) ; pybind::interface_>( _kernel, "DevToDebugWidgetCommandLine" ) - .def_static_args( "setTitle", &Detail::s_DevToDebugWidgetCommandLine_setTitle ) - .def_static_args( "setPlaceholder", &Detail::s_DevToDebugWidgetCommandLine_setPlaceholder ) - .def_static_args( "setCommandEvent", &Detail::s_DevToDebugWidgetCommandLine_setCommandEvent ) + .def_static_args( "setTitle", &Detail::DevToDebugWidgetCommandLine_setTitle ) + .def_static_args( "setPlaceholder", &Detail::DevToDebugWidgetCommandLine_setPlaceholder ) + .def_static_args( "setCommandEvent", &Detail::DevToDebugWidgetCommandLine_setCommandEvent ) ; pybind::interface_>( _kernel, "DevToDebugWidgetRadioButton" ) - .def_static_args( "setTitle", &Detail::s_DevToDebugWidgetRadioButton_setTitle ) - .def_static( "addState", &Detail::s_DevToDebugWidgetRadioButton_addState ) - .def_static_args( "setChangeEvent", &Detail::s_DevToDebugWidgetRadioButton_setChangeEvent ) + .def_static_args( "setTitle", &Detail::DevToDebugWidgetRadioButton_setTitle ) + .def_static( "addState", &Detail::DevToDebugWidgetRadioButton_addState ) + .def_static_args( "setChangeEvent", &Detail::DevToDebugWidgetRadioButton_setChangeEvent ) ; pybind::interface_>( _kernel, "DevToDebugWidgetSelector" ) - .def_static_args( "setTitle", &Detail::s_DevToDebugWidgetSelector_setTitle ) - .def_static( "addState", &Detail::s_DevToDebugWidgetSelector_addState ) - .def_static_args( "setChangeEvent", &Detail::s_DevToDebugWidgetSelector_setChangeEvent ) + .def_static_args( "setTitle", &Detail::DevToDebugWidgetSelector_setTitle ) + .def_static( "addState", &Detail::DevToDebugWidgetSelector_addState ) + .def_static_args( "setChangeEvent", &Detail::DevToDebugWidgetSelector_setChangeEvent ) ; Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); diff --git a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp index fca7960280..b49362577c 100644 --- a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp +++ b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO.cpp @@ -1,7 +1,6 @@ #include "ShaderConverterTextToPSO.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Environment/Windows/Win32Register.h" #include "Environment/Windows/Win32CreateProcess.h" @@ -53,7 +52,7 @@ namespace Mengine } bool successful = false; - PLATFORM_SERVICE() + FILE_SYSTEM() ->findFiles( "", WindowsKitsInstallationFolder, "x64\\fxc.exe", [&fxcPath, &successful]( const FilePath & _fp ) { fxcPath = _fp; diff --git a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO11.cpp b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO11.cpp index a4cf4cd7f1..3b283a874b 100644 --- a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO11.cpp +++ b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToPSO11.cpp @@ -1,7 +1,6 @@ #include "ShaderConverterTextToPSO11.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Environment/Windows/Win32Register.h" #include "Environment/Windows/Win32CreateProcess.h" @@ -53,7 +52,7 @@ namespace Mengine } bool successful = false; - PLATFORM_SERVICE() + FILE_SYSTEM() ->findFiles( "", WindowsKitsInstallationFolder, "x64\\fxc.exe", [&fxcPath, &successful]( const FilePath & _fp ) { fxcPath = _fp; diff --git a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO.cpp b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO.cpp index 338f41aa23..464f56d29d 100644 --- a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO.cpp +++ b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO.cpp @@ -1,7 +1,6 @@ #include "ShaderConverterTextToVSO.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Environment/Windows/Win32Register.h" #include "Environment/Windows/Win32CreateProcess.h" @@ -52,7 +51,7 @@ namespace Mengine } bool successful = false; - PLATFORM_SERVICE() + FILE_SYSTEM() ->findFiles( "", WindowsKitsInstallationFolder, "x64\\fxc.exe", [&fxcPath, &successful]( const FilePath & _fp ) { fxcPath = _fp; diff --git a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO11.cpp b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO11.cpp index ecd652cf9e..7911200eab 100644 --- a/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO11.cpp +++ b/src/Plugins/DevelopmentConverterPlugin/ShaderConverterTextToVSO11.cpp @@ -1,7 +1,6 @@ #include "ShaderConverterTextToVSO11.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Environment/Windows/Win32Register.h" #include "Environment/Windows/Win32CreateProcess.h" @@ -52,7 +51,7 @@ namespace Mengine } bool successful = false; - PLATFORM_SERVICE() + FILE_SYSTEM() ->findFiles( "", WindowsKitsInstallationFolder, "x64\\fxc.exe", [&fxcPath, &successful]( const FilePath & _fp ) { fxcPath = _fp; diff --git a/src/Plugins/FileModifyHookPlugin/FileModifyHookService.cpp b/src/Plugins/FileModifyHookPlugin/FileModifyHookService.cpp index 6b71544042..fdd2b6ffb9 100644 --- a/src/Plugins/FileModifyHookPlugin/FileModifyHookService.cpp +++ b/src/Plugins/FileModifyHookPlugin/FileModifyHookService.cpp @@ -1,8 +1,8 @@ #include "FileModifyHookService.h" -#include "Interface/PlatformServiceInterface.h" #include "Interface/ThreadServiceInterface.h" #include "Interface/TimerServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Kernel/ThreadHelper.h" #include "Kernel/AssertionContainer.h" @@ -99,7 +99,7 @@ namespace Mengine desc.lambda = _lambda; - desc.time = PLATFORM_SERVICE() + desc.time = FILE_SYSTEM() ->getFileTime( desc.fullPath ); desc.modify = false; @@ -162,7 +162,7 @@ namespace Mengine for( const FileModifyDesc & desc : m_fileModifies ) { - uint64_t time = PLATFORM_SERVICE() + uint64_t time = FILE_SYSTEM() ->getFileTime( desc.fullPath ); if( desc.time == time ) diff --git a/src/Plugins/MoviePlugin/Movie2ScriptEmbedding.cpp b/src/Plugins/MoviePlugin/Movie2ScriptEmbedding.cpp index baaa60a88d..ec4f59066f 100644 --- a/src/Plugins/MoviePlugin/Movie2ScriptEmbedding.cpp +++ b/src/Plugins/MoviePlugin/Movie2ScriptEmbedding.cpp @@ -34,7 +34,7 @@ namespace Mengine } }; ////////////////////////////////////////////////////////////////////////// - static PyObject * s_Movie2_setEventListener( pybind::kernel_interface * _kernel, Movie2 * _node, PyObject * _args, PyObject * _kwds ) + static PyObject * Movie2_setEventListener( pybind::kernel_interface * _kernel, Movie2 * _node, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -48,7 +48,7 @@ namespace Mengine return _kernel->ret_none(); } ////////////////////////////////////////////////////////////////////////// - static mt::box2f s_Movie2_getCompositionBoundsWM( Movie2 * _movie ) + static mt::box2f Movie2_getCompositionBoundsWM( Movie2 * _movie ) { const mt::box2f & bounds = _movie->getCompositionBounds(); @@ -62,7 +62,7 @@ namespace Mengine return boundsWM; } ////////////////////////////////////////////////////////////////////////// - static pybind::list s_Movie2_getSockets( pybind::kernel_interface * _kernel, Movie2 * _movie ) + static pybind::list Movie2_getSockets( pybind::kernel_interface * _kernel, Movie2 * _movie ) { pybind::list py_list( _kernel ); @@ -85,7 +85,7 @@ namespace Mengine return py_list; } ////////////////////////////////////////////////////////////////////////// - static pybind::list s_Movie2_getSlots( pybind::kernel_interface * _kernel, Movie2 * _movie ) + static pybind::list Movie2_getSlots( pybind::kernel_interface * _kernel, Movie2 * _movie ) { pybind::list py_list( _kernel ); @@ -121,7 +121,7 @@ namespace Mengine } }; ////////////////////////////////////////////////////////////////////////// - static PyObject * s_Movie2SubComposition_setEventListener( pybind::kernel_interface * _kernel, Movie2SubComposition * _node, PyObject * _args, PyObject * _kwds ) + static PyObject * Movie2SubComposition_setEventListener( pybind::kernel_interface * _kernel, Movie2SubComposition * _node, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -135,7 +135,7 @@ namespace Mengine return _kernel->ret_none(); } ////////////////////////////////////////////////////////////////////////// - static pybind::list s_ResourceMovie2_getCompositionResources( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2, const ConstString & _compositionName ) + static pybind::list ResourceMovie2_getCompositionResources( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2, const ConstString & _compositionName ) { const Movie2DataInterfacePtr & data = _resourceMovie2->getData(); @@ -167,7 +167,7 @@ namespace Mengine return l; } ////////////////////////////////////////////////////////////////////////// - static pybind::list s_ResourceMovie2_getCompositionLayers( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2, const ConstString & _compositionName ) + static pybind::list ResourceMovie2_getCompositionLayers( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2, const ConstString & _compositionName ) { pybind::list l = pybind::make_list_t( _kernel ); @@ -221,7 +221,7 @@ namespace Mengine return l; } ////////////////////////////////////////////////////////////////////////// - static pybind::list s_ResourceMovie2_getCompositions( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2 ) + static pybind::list ResourceMovie2_getCompositions( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2 ) { pybind::list l = pybind::make_list_t( _kernel ); @@ -321,7 +321,7 @@ namespace Mengine return AE_TRUE; } ////////////////////////////////////////////////////////////////////////// - static pybind::dict s_getNullObjectsFromResourceMovie2( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2, const ConstString & _compositionName ) + static pybind::dict getNullObjectsFromResourceMovie2( pybind::kernel_interface * _kernel, ResourceMovie2 * _resourceMovie2, const ConstString & _compositionName ) { MENGINE_ASSERTION_MEMORY_PANIC( _resourceMovie2, "resource is nullptr" ); @@ -368,10 +368,10 @@ namespace Mengine .def( "getSubComposition", &Movie2::getSubComposition ) .def( "hasCompositionBounds", &Movie2::hasCompositionBounds ) .def( "getCompositionBounds", &Movie2::getCompositionBounds ) - .def_static( "getCompositionBoundsWM", &Detail::s_Movie2_getCompositionBoundsWM ) - .def_static_native_kernel( "setEventListener", &Detail::s_Movie2_setEventListener ) - .def_static_kernel( "getSockets", &Detail::s_Movie2_getSockets ) - .def_static_kernel( "getSlots", &Detail::s_Movie2_getSlots ) + .def_static( "getCompositionBoundsWM", &Detail::Movie2_getCompositionBoundsWM ) + .def_static_native_kernel( "setEventListener", &Detail::Movie2_setEventListener ) + .def_static_kernel( "getSockets", &Detail::Movie2_getSockets ) + .def_static_kernel( "getSlots", &Detail::Movie2_getSlots ) .def( "findSprite", &Movie2::findSprite ) .def( "hasSprite", &Movie2::hasSprite ) .def( "findParticle", &Movie2::findParticle ) @@ -398,7 +398,7 @@ namespace Mengine pybind::interface_>( _kernel, "Movie2SubComposition", false ) .def( "setEnable", &Movie2SubComposition::setSubCompositionEnable ) .def( "getEnable", &Movie2SubComposition::getSubCompositionEnable ) - .def_static_native_kernel( "setEventListener", &Detail::s_Movie2SubComposition_setEventListener ) + .def_static_native_kernel( "setEventListener", &Detail::Movie2SubComposition_setEventListener ) ; pybind::interface_>( _kernel, "ResourceMovie2", false ) @@ -406,12 +406,12 @@ namespace Mengine .def( "hasCompositionLayer", &ResourceMovie2::hasCompositionLayer ) .def( "getCompositionDuration", &ResourceMovie2::getCompositionDuration ) .def( "getCompositionFrameDuration", &ResourceMovie2::getCompositionFrameDuration ) - .def_static_kernel( "getCompositionResources", &Detail::s_ResourceMovie2_getCompositionResources ) - .def_static_kernel( "getCompositionLayers", &Detail::s_ResourceMovie2_getCompositionLayers ) - .def_static_kernel( "getCompositions", &Detail::s_ResourceMovie2_getCompositions ) + .def_static_kernel( "getCompositionResources", &Detail::ResourceMovie2_getCompositionResources ) + .def_static_kernel( "getCompositionLayers", &Detail::ResourceMovie2_getCompositionLayers ) + .def_static_kernel( "getCompositions", &Detail::ResourceMovie2_getCompositions ) ; - pybind::def_function_kernel( _kernel, "getNullObjectsFromResourceMovie2", &Detail::s_getNullObjectsFromResourceMovie2 ); + pybind::def_function_kernel( _kernel, "getNullObjectsFromResourceMovie2", &Detail::getNullObjectsFromResourceMovie2 ); Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); diff --git a/src/Plugins/OzzAnimationPlugin/OzzScriptEmbedding.cpp b/src/Plugins/OzzAnimationPlugin/OzzScriptEmbedding.cpp index 365eedd823..05607d0748 100644 --- a/src/Plugins/OzzAnimationPlugin/OzzScriptEmbedding.cpp +++ b/src/Plugins/OzzAnimationPlugin/OzzScriptEmbedding.cpp @@ -27,7 +27,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static SamplerOzzAnimationPtr s_createOzzSampler() + static SamplerOzzAnimationPtr createOzzSampler() { SamplerOzzAnimationPtr sampler = Helper::generatePrototype( STRINGIZE_STRING_LOCAL( "Sampler" ), STRINGIZE_STRING_LOCAL( "SamplerOzzAnimation" ), MENGINE_DOCUMENT_PYBIND ); @@ -36,7 +36,7 @@ namespace Mengine return sampler; } ////////////////////////////////////////////////////////////////////////// - static PyObject * s_SamplerOzzAnimationInterface_setEventListener( pybind::kernel_interface * _kernel, SamplerOzzAnimationInterface * _sampler, PyObject * _args, PyObject * _kwds ) + static PyObject * SamplerOzzAnimationInterface_setEventListener(pybind::kernel_interface * _kernel, SamplerOzzAnimationInterface * _sampler, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -64,7 +64,7 @@ namespace Mengine SCRIPT_SERVICE() ->setAvailablePlugin( "Ozz", true ); - pybind::def_function( _kernel, "createOzzSampler", &Detail::s_createOzzSampler ); + pybind::def_function( _kernel, "createOzzSampler", &Detail::createOzzSampler ); pybind::interface_>( _kernel, "ResourceOzzAnimation", false ) ; @@ -82,7 +82,7 @@ namespace Mengine .def( "getResourceOzzSkeleton", &SamplerOzzAnimationInterface::getResourceOzzSkeleton ) .def( "setWeight", &SamplerOzzAnimationInterface::setWeight ) .def( "getWeight", &SamplerOzzAnimationInterface::getWeight ) - .def_static_native_kernel( "setEventListener", &Detail::s_SamplerOzzAnimationInterface_setEventListener ) + .def_static_native_kernel( "setEventListener", &Detail::SamplerOzzAnimationInterface_setEventListener ) ; pybind::interface_>( _kernel, "SamplerOzzAnimation", false ) diff --git a/src/Plugins/ResourcePrefetcherPlugin/ResourcePrefetcherScriptEmbedding.cpp b/src/Plugins/ResourcePrefetcherPlugin/ResourcePrefetcherScriptEmbedding.cpp index 57d01503a0..786bab46b2 100644 --- a/src/Plugins/ResourcePrefetcherPlugin/ResourcePrefetcherScriptEmbedding.cpp +++ b/src/Plugins/ResourcePrefetcherPlugin/ResourcePrefetcherScriptEmbedding.cpp @@ -107,7 +107,7 @@ namespace Mengine ////////////////////////////////////////////////////////////////////////// typedef IntrusivePtr PyPrefetcherObserverPtr; ////////////////////////////////////////////////////////////////////////// - static bool s_prefetchResources( const ConstString & _groupName, const pybind::object & _cb, const pybind::args & _args ) + static bool prefetchResources( const ConstString & _groupName, const pybind::object & _cb, const pybind::args & _args ) { LOGGER_STATISTIC( "prefetch resources group '%s'" , _groupName.c_str() @@ -127,7 +127,7 @@ namespace Mengine return count != 0; } ////////////////////////////////////////////////////////////////////////// - static void s_unfetchResources( const ConstString & _groupName ) + static void unfetchResources( const ConstString & _groupName ) { LOGGER_STATISTIC( "unfetch resources category group '%s'" , _groupName.c_str() @@ -141,7 +141,7 @@ namespace Mengine } ); } ////////////////////////////////////////////////////////////////////////// - static bool s_prefetchFonts( const pybind::object & _cb, const pybind::args & _args ) + static bool prefetchFonts( const pybind::object & _cb, const pybind::args & _args ) { PyPrefetcherObserverPtr observer = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, ConstString::none(), _cb, _args ); @@ -162,7 +162,7 @@ namespace Mengine return count != 0; } ////////////////////////////////////////////////////////////////////////// - static bool s_prefetchScripts( const pybind::object & _cb, const pybind::args & _args ) + static bool prefetchScripts( const pybind::object & _cb, const pybind::args & _args ) { PyPrefetcherObserverPtr observer = Helper::makeFactorableUnique( MENGINE_DOCUMENT_PYBIND, ConstString::none(), _cb, _args ); @@ -174,7 +174,7 @@ namespace Mengine return count != 0; } ////////////////////////////////////////////////////////////////////////// - static void s_unfetchFonts() + static void unfetchFonts() { FONT_SERVICE() ->foreachGlyphs( []( const FontGlyphInterfacePtr & _glyph ) @@ -203,11 +203,11 @@ namespace Mengine SCRIPT_SERVICE() ->setAvailablePlugin( "ResourcePrefetcher", true ); - pybind::def_function_args( _kernel, "prefetchResources", &Detail::s_prefetchResources ); - pybind::def_function( _kernel, "unfetchResources", &Detail::s_unfetchResources ); - pybind::def_function_args( _kernel, "prefetchFonts", &Detail::s_prefetchFonts ); - pybind::def_function_args( _kernel, "prefetchScripts", &Detail::s_prefetchScripts ); - pybind::def_function( _kernel, "unfetchFonts", &Detail::s_unfetchFonts ); + pybind::def_function_args( _kernel, "prefetchResources", &Detail::prefetchResources ); + pybind::def_function( _kernel, "unfetchResources", &Detail::unfetchResources ); + pybind::def_function_args( _kernel, "prefetchFonts", &Detail::prefetchFonts ); + pybind::def_function_args( _kernel, "prefetchScripts", &Detail::prefetchScripts ); + pybind::def_function( _kernel, "unfetchFonts", &Detail::unfetchFonts ); return true; } diff --git a/src/Plugins/ResourceValidatePlugin/ResourceImageDefaultValidator.cpp b/src/Plugins/ResourceValidatePlugin/ResourceImageDefaultValidator.cpp index a8da5ddafa..1cb800bf68 100644 --- a/src/Plugins/ResourceValidatePlugin/ResourceImageDefaultValidator.cpp +++ b/src/Plugins/ResourceValidatePlugin/ResourceImageDefaultValidator.cpp @@ -19,7 +19,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static bool s_allPixelsTransparency( const void * _buffer, uint32_t _size ) + static bool allPixelsTransparency( const void * _buffer, uint32_t _size ) { const uint8_t * pixel_memory = static_cast(_buffer); @@ -34,7 +34,7 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// - static bool s_checkColumnTransparency( const void * _buffer, uint32_t _width, uint32_t _height, uint32_t _column ) + static bool checkColumnTransparency( const void * _buffer, uint32_t _width, uint32_t _height, uint32_t _column ) { const uint8_t * pixel_memory = static_cast(_buffer); @@ -49,7 +49,7 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// - static bool s_checkRowTransparency( const void * _buffer, uint32_t _width, uint32_t _height, uint32_t _row ) + static bool checkRowTransparency( const void * _buffer, uint32_t _width, uint32_t _height, uint32_t _row ) { MENGINE_UNUSED( _height ); @@ -66,11 +66,11 @@ namespace Mengine return true; } ////////////////////////////////////////////////////////////////////////// - static bool s_checkRowColumnTransparency( const void * _buffer, uint32_t _width, uint32_t _height ) + static bool checkRowColumnTransparency( const void * _buffer, uint32_t _width, uint32_t _height ) { for( uint32_t i = 0; i != _width; ++i ) { - if( Detail::s_checkColumnTransparency( _buffer, _width, _height, i ) == true ) + if( Detail::checkColumnTransparency( _buffer, _width, _height, i ) == true ) { return true; } @@ -78,7 +78,7 @@ namespace Mengine for( uint32_t j = 0; j != _height; ++j ) { - if( Detail::s_checkRowTransparency( _buffer, _width, _height, j ) == true ) + if( Detail::checkRowTransparency( _buffer, _width, _height, j ) == true ) { return true; } @@ -265,7 +265,7 @@ namespace Mengine return false; } - if( Detail::s_allPixelsTransparency( buffer_memory, texture_size ) == true ) + if( Detail::allPixelsTransparency( buffer_memory, texture_size ) == true ) { LOGGER_MESSAGE_RELEASE_ERROR( "resource '%s' group '%s' file '%s' codec '%s' all pixels transparency!" , _resource->getName().c_str() @@ -281,7 +281,7 @@ namespace Mengine if( Check_ImageRowColumnTransparency == true ) { - if( Detail::s_checkRowColumnTransparency( buffer_memory, dataInfo->width, dataInfo->height ) == true ) + if( Detail::checkRowColumnTransparency( buffer_memory, dataInfo->width, dataInfo->height ) == true ) { LOGGER_MESSAGE_RELEASE_ERROR( "resource '%s' group '%s' file '%s' codec '%s' row or column pixels transparency!" , _resource->getName().c_str() diff --git a/src/Plugins/SpinePlugin/SamplerSpineAnimation.cpp b/src/Plugins/SpinePlugin/SamplerSpineAnimation.cpp index 61073fb536..9853e87083 100644 --- a/src/Plugins/SpinePlugin/SamplerSpineAnimation.cpp +++ b/src/Plugins/SpinePlugin/SamplerSpineAnimation.cpp @@ -84,7 +84,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static void s_spAnimationStateListener( spAnimationState * _state, spEventType _type, spTrackEntry * _entry, spEvent * _event ) + static void spAnimationStateListener(spAnimationState * _state, spEventType _type, spTrackEntry * _entry, spEvent * _event ) { SamplerSpineAnimation * sampler = static_cast(_state->rendererObject); @@ -128,7 +128,7 @@ namespace Mengine spAnimationState * animationState = spAnimationState_create( m_animationStateData ); animationState->rendererObject = this; - animationState->listener = &Detail::s_spAnimationStateListener; + animationState->listener = &Detail::spAnimationStateListener; m_animationState = animationState; diff --git a/src/Plugins/SpinePlugin/SpineScriptEmbedding.cpp b/src/Plugins/SpinePlugin/SpineScriptEmbedding.cpp index 1c443ba5ee..ce32377096 100644 --- a/src/Plugins/SpinePlugin/SpineScriptEmbedding.cpp +++ b/src/Plugins/SpinePlugin/SpineScriptEmbedding.cpp @@ -39,7 +39,7 @@ namespace Mengine } }; ////////////////////////////////////////////////////////////////////////// - static PyObject * s_SamplerSpineAnimationInterface_setEventListener( pybind::kernel_interface * _kernel, SamplerSpineAnimationInterface * _sampler, PyObject * _args, PyObject * _kwds ) + static PyObject * SamplerSpineAnimationInterface_setEventListener(pybind::kernel_interface * _kernel, SamplerSpineAnimationInterface * _sampler, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -88,7 +88,8 @@ namespace Mengine .def( "getAnimationName", &SamplerSpineAnimationInterface::getAnimationName ) .def( "setAnimationEnable", &SamplerSpineAnimationInterface::setAnimationEnable ) .def( "getAnimationEnable", &SamplerSpineAnimationInterface::getAnimationEnable ) - .def_static_native_kernel( "setEventListener", &Detail::s_SamplerSpineAnimationInterface_setEventListener ) + .def_static_native_kernel( "setEventListener", + &Detail::SamplerSpineAnimationInterface_setEventListener ) ; pybind::interface_>( _kernel, "SamplerSpineAnimation", false ) diff --git a/src/Plugins/SteamPlugin/SteamScriptEmbedding.cpp b/src/Plugins/SteamPlugin/SteamScriptEmbedding.cpp index 2c761f7fcf..b565d90da4 100644 --- a/src/Plugins/SteamPlugin/SteamScriptEmbedding.cpp +++ b/src/Plugins/SteamPlugin/SteamScriptEmbedding.cpp @@ -19,7 +19,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static bool s_steamSetAchievement( const ConstString & _name ) + static bool steamSetAchievement( const ConstString & _name ) { if( SERVICE_IS_INITIALIZE( SteamServiceInterface ) == false ) { @@ -32,7 +32,7 @@ namespace Mengine return result; } ////////////////////////////////////////////////////////////////////////// - static bool s_steamGetAchievement( pybind::kernel_interface * _kernel, const ConstString & _name ) + static bool steamGetAchievement( pybind::kernel_interface * _kernel, const ConstString & _name ) { if( SERVICE_IS_INITIALIZE( SteamServiceInterface ) == false ) { @@ -51,7 +51,7 @@ namespace Mengine return _kernel->ret_bool( achieved ); } ////////////////////////////////////////////////////////////////////////// - static bool s_steamSetStateInteger( const ConstString & _name, int32_t _value ) + static bool steamSetStateInteger( const ConstString & _name, int32_t _value ) { if( SERVICE_IS_INITIALIZE( SteamServiceInterface ) == false ) { @@ -64,7 +64,7 @@ namespace Mengine return result; } ////////////////////////////////////////////////////////////////////////// - static bool s_steamSetStateFloat( const ConstString & _name, float _value ) + static bool steamSetStateFloat( const ConstString & _name, float _value ) { if( SERVICE_IS_INITIALIZE( SteamServiceInterface ) == false ) { @@ -92,10 +92,10 @@ namespace Mengine SCRIPT_SERVICE() ->setAvailablePlugin( "Steam", true ); - pybind::def_function( _kernel, "steamSetAchievement", &Detail::s_steamSetAchievement ); - pybind::def_function_kernel( _kernel, "steamGetAchievement", &Detail::s_steamGetAchievement ); - pybind::def_function( _kernel, "steamSetStateInteger", &Detail::s_steamSetStateInteger ); - pybind::def_function( _kernel, "steamSetStateFloat", &Detail::s_steamSetStateFloat ); + pybind::def_function( _kernel, "steamSetAchievement", &Detail::steamSetAchievement ); + pybind::def_function_kernel( _kernel, "steamGetAchievement", &Detail::steamGetAchievement ); + pybind::def_function( _kernel, "steamSetStateInteger", &Detail::steamSetStateInteger ); + pybind::def_function( _kernel, "steamSetStateFloat", &Detail::steamSetStateFloat ); return true; } diff --git a/src/Plugins/VideoPlugin/VideoScriptEmbedding.cpp b/src/Plugins/VideoPlugin/VideoScriptEmbedding.cpp index 54495bc2fb..94ec3ac712 100644 --- a/src/Plugins/VideoPlugin/VideoScriptEmbedding.cpp +++ b/src/Plugins/VideoPlugin/VideoScriptEmbedding.cpp @@ -23,7 +23,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static PyObject * s_SurfaceVideo_setEventListener( pybind::kernel_interface * _kernel, SurfaceVideo * _surface, PyObject * _args, PyObject * _kwds ) + static PyObject * SurfaceVideo_setEventListener( pybind::kernel_interface * _kernel, SurfaceVideo * _surface, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -37,7 +37,7 @@ namespace Mengine return _kernel->ret_none(); } ////////////////////////////////////////////////////////////////////////// - static PyObject * s_SurfaceMockupVideo_setEventListener( pybind::kernel_interface * _kernel, SurfaceMockupVideo * _surface, PyObject * _args, PyObject * _kwds ) + static PyObject * SurfaceMockupVideo_setEventListener( pybind::kernel_interface * _kernel, SurfaceMockupVideo * _surface, PyObject * _args, PyObject * _kwds ) { MENGINE_UNUSED( _args ); @@ -51,7 +51,7 @@ namespace Mengine return _kernel->ret_none(); } ////////////////////////////////////////////////////////////////////////// - ShapePtr s_createVideo( const ConstString & _name, const ConstString & _shapeType, const ResourceVideoPtr & _resource ) + ShapePtr createVideo( const ConstString & _name, const ConstString & _shapeType, const ResourceVideoPtr & _resource ) { MENGINE_ASSERTION_MEMORY_PANIC( _resource, "create video '%s' resource is nullptr" , _name.c_str() @@ -114,7 +114,7 @@ namespace Mengine .def( "getResourceVideo", &SurfaceVideo::getResourceVideo ) .def( "getWidth", &SurfaceVideo::getWidth ) .def( "getHeight", &SurfaceVideo::getHeight ) - .def_static_native_kernel( "setEventListener", &Detail::s_SurfaceVideo_setEventListener ) + .def_static_native_kernel( "setEventListener", &Detail::SurfaceVideo_setEventListener ) ; pybind::interface_>( _kernel, "SurfaceMockupVideo", false ) @@ -122,10 +122,10 @@ namespace Mengine .def( "getResourceVideo", &SurfaceMockupVideo::getResourceVideo ) .def( "getWidth", &SurfaceMockupVideo::getWidth ) .def( "getHeight", &SurfaceMockupVideo::getHeight ) - .def_static_native_kernel( "setEventListener", &Detail::s_SurfaceMockupVideo_setEventListener ) + .def_static_native_kernel( "setEventListener", &Detail::SurfaceMockupVideo_setEventListener ) ; - pybind::def_function( _kernel, "createVideo", &Detail::s_createVideo ); + pybind::def_function( _kernel, "createVideo", &Detail::createVideo ); Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); Helper::registerScriptWrapping( _kernel, MENGINE_DOCUMENT_FACTORABLE ); diff --git a/src/Services/FileService/FileService.cpp b/src/Services/FileService/FileService.cpp index 1c385717a6..3dba9c6cb9 100644 --- a/src/Services/FileService/FileService.cpp +++ b/src/Services/FileService/FileService.cpp @@ -3,7 +3,7 @@ #include "Interface/ServiceInterface.h" #include "Interface/MemoryInterface.h" #include "Interface/ThreadServiceInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Interface/PrototypeServiceInterface.h" #include "Kernel/FileStreamHelper.h" @@ -131,7 +131,7 @@ namespace Mengine basePath.append( relationPath ); basePath.append( folderPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->createDirectory( "", basePath.c_str() ) == false ) { LOGGER_ERROR( "invalid create fileGroup '%s' directory '%s'" diff --git a/src/Systems/AndroidFileSystem/AndroidFileGroupDirectory.cpp b/src/Systems/AndroidFileSystem/AndroidFileGroupDirectory.cpp index dcb32b8705..ef21406a20 100644 --- a/src/Systems/AndroidFileSystem/AndroidFileGroupDirectory.cpp +++ b/src/Systems/AndroidFileSystem/AndroidFileGroupDirectory.cpp @@ -1,7 +1,6 @@ #include "AndroidFileGroupDirectory.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Environment/Android/AndroidEnv.h" #include "Environment/Android/AndroidActivityHelper.h" @@ -141,13 +140,13 @@ namespace Mengine basePath.append( relationPath ); basePath.append( folderPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->existDirectory( basePath.c_str(), _folderName.c_str() ) == true ) { return true; } - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->createDirectory( basePath.c_str(), _folderName.c_str() ) == false ) { return false; @@ -171,7 +170,7 @@ namespace Mengine newFilePathString.append( folderPath ); newFilePathString.append( _newFilePath ); - bool successful = PLATFORM_SERVICE() + bool successful = FILE_SYSTEM() ->moveFile( oldFilePathString.c_str(), newFilePathString.c_str() ); return successful; @@ -192,7 +191,7 @@ namespace Mengine Helper::pathCorrectForwardslashA( utf8_base ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->findFiles( utf8_base, _filePath.c_str(), _mask, _lambda ) == false ) { return false; diff --git a/src/Systems/AndroidFileSystem/AndroidFileSystem.cpp b/src/Systems/AndroidFileSystem/AndroidFileSystem.cpp index 3ca8f23213..81537e3940 100644 --- a/src/Systems/AndroidFileSystem/AndroidFileSystem.cpp +++ b/src/Systems/AndroidFileSystem/AndroidFileSystem.cpp @@ -7,12 +7,76 @@ #include "Kernel/FactoryDefault.h" #include "Kernel/FilePathHelper.h" #include "Kernel/VocabularyHelper.h" +#include "Kernel/PathHelper.h" +#include "Kernel/Logger.h" + +#include "Config/StdString.h" + +#include +#include ////////////////////////////////////////////////////////////////////////// SERVICE_FACTORY( FileSystem, Mengine::AndroidFileSystem ); ////////////////////////////////////////////////////////////////////////// namespace Mengine { + ////////////////////////////////////////////////////////////////////////// + namespace Detail + { + ////////////////////////////////////////////////////////////////////////// + static bool createDirectoryFullpath( const Char * _fullpath ) + { + int status = ::mkdir( _fullpath, S_IRWXU ); + + if( status != 0 ) + { + LOGGER_WARNING( "'%s' already exists" + , _fullpath + ); + + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + static bool isDirectoryFullpath(const Char * _fullpath ) + { + struct stat sb; + int err = ::stat( _fullpath, &sb ); + + if( err != 0 ) + { + return false; + } + + if( (sb.st_mode & S_IFMT) != S_IFDIR ) + { + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + static bool isFileFullpath(const Char * _fullpath ) + { + struct stat sb; + int err = ::stat( _fullpath, &sb ); + + if( err != 0 ) + { + return false; + } + + if( (sb.st_mode & S_IFMT) == S_IFDIR ) + { + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + } ////////////////////////////////////////////////////////////////////////// AndroidFileSystem::AndroidFileSystem() { @@ -39,4 +103,195 @@ namespace Mengine VOCABULARY_REMOVE( STRINGIZE_STRING_LOCAL( "FileGroupFactory" ), STRINGIZE_STRING_LOCAL( "dir" ) ); } ////////////////////////////////////////////////////////////////////////// + bool AndroidFileSystem::existDirectory( const Char * _basePath, const Char * _directory ) const + { + Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathDirectory, _directory ); + + Helper::pathRemoveFileSpecA( pathDirectory ); + + size_t len = StdString::strlen( pathDirectory ); + + if( len == 0 ) // current dir + { + return true; + } + + Char pathFull[MENGINE_MAX_PATH + 1] = {'\0'}; + MENGINE_SNPRINTF( pathFull, MENGINE_MAX_PATH, "%s%s", _basePath, pathDirectory ); + + if( pathFull[len - 1] == ':' ) // root dir + { + return true; // let it be + } + + bool exist = Detail::isDirectoryFullpath(pathFull); + + return exist; + } + ////////////////////////////////////////////////////////////////////////// + bool AndroidFileSystem::createDirectory( const Char * _basePath, const Char * _directory ) + { + size_t directorySize = StdString::strlen( _directory ); + + if( directorySize == 0 ) + { + return true; + } + + Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathDirectory, _directory ); + + Helper::pathRemoveFileSpecA( pathDirectory ); + + if( StdString::strlen( pathDirectory ) == 0 ) + { + return true; + } + + Char pathTestDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + StdString::strncpy( pathTestDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::strncat( pathTestDirectory, pathDirectory, MENGINE_MAX_PATH ); + + if( Detail::isDirectoryFullpath(pathTestDirectory) == true ) + { + return true; + } + + Helper::pathRemoveBackslashA( pathDirectory ); + + uint32_t paths_count = 0; + Char paths[MENGINE_MAX_PATH + 1][16]; + + for( ;; ) + { + StdString::strncpy( paths[paths_count++], pathDirectory, MENGINE_MAX_PATH ); + + if( Helper::pathRemoveFileSpecA( pathDirectory ) == false ) + { + break; + } + + if( StdString::strlen( _basePath ) == 0 ) + { + break; + } + + Helper::pathRemoveBackslashA( pathDirectory ); + + StdString::strncpy( pathTestDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::strncat( pathTestDirectory, pathDirectory, MENGINE_MAX_PATH ); + + if( Detail::isDirectoryFullpath(pathTestDirectory) == true ) + { + break; + } + } + + for( uint32_t index = paths_count; index != 0; --index ) + { + const Char * path = paths[index - 1]; + + Char pathCreateDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + StdString::strncpy( pathCreateDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::strncat( pathCreateDirectory, path, MENGINE_MAX_PATH ); + + if( Detail::createDirectoryFullpath(pathCreateDirectory) == false ) + { + return false; + } + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool AndroidFileSystem::existFile( const Char * _filePath ) + { + Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); + + bool exist = Detail::isFileFullpath(pathCorrect); + + return exist; + } + ////////////////////////////////////////////////////////////////////////// + bool AndroidFileSystem::removeFile( const Char * _filePath ) + { + Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); + + int result = ::remove( pathCorrect ); + + if( result != 0 ) + { + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool AndroidFileSystem::moveFile( const Char * _oldFilePath, const Char * _newFilePath ) + { + Char oldPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( oldPathCorrect, _oldFilePath ); + + Char newPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( newPathCorrect, _newFilePath ); + + struct stat sb; + if( stat( newPathCorrect, &sb ) == 0 && ((sb.st_mode) & S_IFMT) != S_IFDIR ) + { + int result_remove = ::remove( newPathCorrect ); + + if( result_remove != 0 ) + { + const char * msg = ::strerror( errno ); + + LOGGER_ASSERTION( "invalid remove new move file from '%s' to '%s' error '%s' [%u]" + , _oldFilePath + , _newFilePath + , msg + , errno + ); + } + } + + int result_rename = ::rename( oldPathCorrect, newPathCorrect ); + + if( result_rename != 0 ) + { + const char * msg = ::strerror( errno ); + + LOGGER_ASSERTION( "invalid move file from '%s' to '%s' error '%s' [%u]" + , _oldFilePath + , _newFilePath + , msg + , errno + ); + + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool AndroidFileSystem::findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const + { + MENGINE_UNUSED( _base ); + MENGINE_UNUSED( _path ); + MENGINE_UNUSED( _mask ); + MENGINE_UNUSED( _lambda ); + + LOGGER_WARNING("AndroidPlatformService::findFiles not support"); + + return false; + } + ////////////////////////////////////////////////////////////////////////// + uint64_t AndroidFileSystem::getFileTime( const Char * _filePath ) const + { + MENGINE_UNUSED( _filePath ); + + return 0U; + } + ////////////////////////////////////////////////////////////////////////// } diff --git a/src/Systems/AndroidFileSystem/AndroidFileSystem.h b/src/Systems/AndroidFileSystem/AndroidFileSystem.h index ad2eaf19fc..930684c2f1 100644 --- a/src/Systems/AndroidFileSystem/AndroidFileSystem.h +++ b/src/Systems/AndroidFileSystem/AndroidFileSystem.h @@ -13,8 +13,23 @@ namespace Mengine AndroidFileSystem(); ~AndroidFileSystem() override; - protected: + public: bool _initializeService() override; void _finalizeService() override; + + public: + bool existDirectory( const Char * _basePath, const Char * _directory ) const override; + bool createDirectory( const Char * _basePath, const Char * _directory ) override; + + public: + bool existFile( const Char * _filePath ) override; + bool removeFile( const Char * _filePath ) override; + bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) override; + + public: + bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const override; + + public: + uint64_t getFileTime( const Char * _filePath ) const override; }; } diff --git a/src/Systems/OpenGLRenderSystem/OpenGLRenderExtension.cpp b/src/Systems/OpenGLRenderSystem/OpenGLRenderExtension.cpp index ea6f1293d7..ef521b269b 100644 --- a/src/Systems/OpenGLRenderSystem/OpenGLRenderExtension.cpp +++ b/src/Systems/OpenGLRenderSystem/OpenGLRenderExtension.cpp @@ -2,7 +2,7 @@ #if defined(MENGINE_RENDER_OPENGL_NORMAL) -# include "SDL_video.h" +#include "Environment/SDL/SDLIncluder.h" // textures PFNGLACTIVETEXTUREPROC glActiveTexture_ = nullptr; diff --git a/src/Systems/POSIXThreadSystem/POSIXThreadIdentity.cpp b/src/Systems/POSIXThreadSystem/POSIXThreadIdentity.cpp index 23f68ebe28..c474a08469 100644 --- a/src/Systems/POSIXThreadSystem/POSIXThreadIdentity.cpp +++ b/src/Systems/POSIXThreadSystem/POSIXThreadIdentity.cpp @@ -22,7 +22,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static void * s_treadJob( void * _userData ) + static void * treadJob(void * _userData ) { POSIXThreadIdentity * thread = reinterpret_cast(_userData); @@ -113,7 +113,7 @@ namespace Mengine m_runner = Helper::makeFactorableUnique( _doc, _lambda, _sleep ); pthread_t threadId; - int status = ::pthread_create( &threadId, nullptr, &Detail::s_treadJob, reinterpret_cast(this) ); + int status = ::pthread_create(&threadId, nullptr, &Detail::treadJob, reinterpret_cast(this) ); if( status != 0 ) { diff --git a/src/Systems/POSIXThreadSystem/POSIXThreadProcessor.cpp b/src/Systems/POSIXThreadSystem/POSIXThreadProcessor.cpp index 7c601e0b4a..609422a42d 100644 --- a/src/Systems/POSIXThreadSystem/POSIXThreadProcessor.cpp +++ b/src/Systems/POSIXThreadSystem/POSIXThreadProcessor.cpp @@ -160,7 +160,7 @@ namespace Mengine if( m_exit == false ) { m_mutex->lock(); - m_task->main(); + m_task->process(); m_mutex->unlock(); } diff --git a/src/Systems/SDLFileSystem/SDLFileGroupDirectory.cpp b/src/Systems/SDLFileSystem/SDLFileGroupDirectory.cpp index b159ba3a9f..27ac4d2edd 100644 --- a/src/Systems/SDLFileSystem/SDLFileGroupDirectory.cpp +++ b/src/Systems/SDLFileSystem/SDLFileGroupDirectory.cpp @@ -1,7 +1,8 @@ #include "SDLFileGroupDirectory.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" + +#include "Environment/SDL/SDLIncluder.h" #include "SDLFileInputStream.h" #include "SDLMutexFileInputStream.h" @@ -18,8 +19,6 @@ #include "Kernel/PathString.h" #include "Kernel/DocumentHelper.h" -#include "SDL_rwops.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// @@ -74,7 +73,7 @@ namespace Mengine Char fullPath[MENGINE_MAX_PATH + 1] = {'\0'}; this->getFullPath( _filePath, fullPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->existFile( fullPath ) == true ) { return true; @@ -100,7 +99,7 @@ namespace Mengine filePathString.append( folderPath ); filePathString.append( _filePath ); - bool successful = PLATFORM_SERVICE() + bool successful = FILE_SYSTEM() ->removeFile( filePathString.c_str() ); return successful; @@ -115,7 +114,7 @@ namespace Mengine basePath.append( relationPath ); basePath.append( folderPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->existDirectory( basePath.c_str(), _folderName.c_str() ) == true ) { return true; @@ -141,13 +140,13 @@ namespace Mengine basePath.append( relationPath ); basePath.append( folderPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->existDirectory( basePath.c_str(), _folderName.c_str() ) == true ) { return true; } - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->createDirectory( basePath.c_str(), _folderName.c_str() ) == false ) { return false; @@ -171,7 +170,7 @@ namespace Mengine newFilePathString.append( folderPath ); newFilePathString.append( _newFilePath ); - bool successful = PLATFORM_SERVICE() + bool successful = FILE_SYSTEM() ->moveFile( oldFilePathString.c_str(), newFilePathString.c_str() ); return successful; @@ -192,7 +191,7 @@ namespace Mengine Helper::pathCorrectForwardslashA( utf8_base ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->findFiles( utf8_base, _filePath.c_str(), _mask, _lambda ) == false ) { return false; diff --git a/src/Systems/SDLFileSystem/SDLFileInputStream.cpp b/src/Systems/SDLFileSystem/SDLFileInputStream.cpp index 2d6dc07db3..45c4cce9f7 100644 --- a/src/Systems/SDLFileSystem/SDLFileInputStream.cpp +++ b/src/Systems/SDLFileSystem/SDLFileInputStream.cpp @@ -1,7 +1,6 @@ #include "SDLFileInputStream.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Kernel/Logger.h" #include "Kernel/ThreadGuardScope.h" @@ -389,7 +388,7 @@ namespace Mengine return false; } - uint64_t ft = PLATFORM_SERVICE() + uint64_t ft = FILE_SYSTEM() ->getFileTime( fullPath ); *_time = ft; diff --git a/src/Systems/SDLFileSystem/SDLFileInputStream.h b/src/Systems/SDLFileSystem/SDLFileInputStream.h index 538cb7dd9f..395a400fb3 100644 --- a/src/Systems/SDLFileSystem/SDLFileInputStream.h +++ b/src/Systems/SDLFileSystem/SDLFileInputStream.h @@ -2,6 +2,8 @@ #include "Interface/FileInputStreamInterface.h" +#include "Environment/SDL/SDLIncluder.h" + #include "Kernel/Factorable.h" #include "Kernel/ThreadGuard.h" @@ -9,8 +11,6 @@ # include "Kernel/BaseDebugFile.h" #endif -#include "SDL_rwops.h" - #ifndef MENGINE_FILE_STREAM_BUFFER_SIZE #define MENGINE_FILE_STREAM_BUFFER_SIZE 4096 #endif diff --git a/src/Systems/SDLFileSystem/SDLFileOutputStream.cpp b/src/Systems/SDLFileSystem/SDLFileOutputStream.cpp index ce191c7815..71aa5e5d6d 100644 --- a/src/Systems/SDLFileSystem/SDLFileOutputStream.cpp +++ b/src/Systems/SDLFileSystem/SDLFileOutputStream.cpp @@ -1,6 +1,6 @@ #include "SDLFileOutputStream.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Kernel/Logger.h" #include "Kernel/PathHelper.h" @@ -142,7 +142,7 @@ namespace Mengine return false; } - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->moveFile( fullPathTemp, fullPath ) == false ) { return false; diff --git a/src/Systems/SDLFileSystem/SDLFileOutputStream.h b/src/Systems/SDLFileSystem/SDLFileOutputStream.h index 8372c91671..13a6c0dfb6 100644 --- a/src/Systems/SDLFileSystem/SDLFileOutputStream.h +++ b/src/Systems/SDLFileSystem/SDLFileOutputStream.h @@ -2,14 +2,14 @@ #include "Interface/FileOutputStreamInterface.h" +#include "Environment/SDL/SDLIncluder.h" + #include "Kernel/Factorable.h" #if defined(MENGINE_DEBUG) # include "Kernel/BaseDebugFile.h" #endif -#include "SDL_rwops.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/SDLFileSystem/SDLFileSystem.cpp b/src/Systems/SDLFileSystem/SDLFileSystem.cpp index b54a541855..a88201264b 100644 --- a/src/Systems/SDLFileSystem/SDLFileSystem.cpp +++ b/src/Systems/SDLFileSystem/SDLFileSystem.cpp @@ -2,6 +2,17 @@ #include "Interface/PlatformServiceInterface.h" +#include "Environment/SDL/SDLIncluder.h" + +#if defined(MENGINE_PLATFORM_WINDOWS) +# include "Environment/Windows/WindowsIncluder.h" +# include "Environment/Windows/Win32FileHelper.h" +#elif defined(MENGINE_PLATFORM_APPLE) +# if defined(MENGINE_PLATFORM_MACOS) +# include "Environment/MacOS/MacOSUtils.h" +# endif +#endif + #include "SDLFileGroupDirectory.h" #include "SDLFileGroupDirectoryFactory.h" @@ -10,6 +21,9 @@ #include "Kernel/FilePathHelper.h" #include "Kernel/VocabularyHelper.h" #include "Kernel/PluginHelper.h" +#include "Kernel/PathHelper.h" +#include "Kernel/UnicodeHelper.h" +#include "Kernel/Logger.h" #include "Config/StdString.h" @@ -18,6 +32,95 @@ SERVICE_FACTORY( FileSystem, Mengine::SDLFileSystem ); ////////////////////////////////////////////////////////////////////////// namespace Mengine { + ////////////////////////////////////////////////////////////////////////// + namespace Detail + { + ////////////////////////////////////////////////////////////////////////// + static bool createDirectoryFullpath( const Char * _fullpath ) + { +#if defined(MENGINE_PLATFORM_MACOS) + int status = ::mkdir( _fullpath, S_IRWXU ); + + if( status != 0 ) + { + LOGGER_WARNING( "'%s' already exists" + , _fullpath + ); + + return false; + } + +#elif defined(MENGINE_PLATFORM_LINUX) + int status = ::mkdir( _fullpath, S_IRWXU ); + + if( status != 0 ) + { + LOGGER_WARNING( "'%s' already exists" + , _fullpath + ); + + return false; + } + +#elif defined(MENGINE_PLATFORM_WINDOWS) + WChar unicode_fullpath[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::utf8ToUnicode( _fullpath, unicode_fullpath, MENGINE_MAX_PATH - 1 ); + + BOOL successful = ::CreateDirectoryW( unicode_fullpath, NULL ); + + if( successful == FALSE ) + { + DWORD err = GetLastError(); + + switch( err ) + { + case ERROR_ALREADY_EXISTS: + { + return true; + }break; + case ERROR_PATH_NOT_FOUND: + { + LOGGER_WARNING( "'%s' not found" + , _fullpath + ); + + return false; + }break; + default: + { + LOGGER_WARNING( "'%s' unknown error %d" + , _fullpath + , err + ); + }break; + } + + return false; + } +#endif + + return true; + } + ////////////////////////////////////////////////////////////////////////// + static bool isDirectoryFullpath( const Char * _fullpath ) + { + struct stat sb; + int err = ::stat( _fullpath, &sb ); + + if( err != 0 ) + { + return false; + } + + if( (sb.st_mode & S_IFMT) == S_IFDIR ) + { + return true; + } + + return false; + } + ////////////////////////////////////////////////////////////////////////// + } ////////////////////////////////////////////////////////////////////////// SDLFileSystem::SDLFileSystem() { @@ -60,4 +163,446 @@ namespace Mengine VOCABULARY_REMOVE( STRINGIZE_STRING_LOCAL( "FileGroupFactory" ), STRINGIZE_STRING_LOCAL( "dir" ) ); } ////////////////////////////////////////////////////////////////////////// + bool SDLFileSystem::existDirectory( const Char * _basePath, const Char * _directory ) const + { + Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathDirectory, _directory ); + + Helper::pathRemoveFileSpecA( pathDirectory ); + + size_t len = StdString::strlen( pathDirectory ); + + if( len == 0 ) // current dir + { + return true; + } + + Char pathFull[MENGINE_MAX_PATH + 1] = {'\0'}; + MENGINE_SNPRINTF( pathFull, MENGINE_MAX_PATH, "%s%s", _basePath, pathDirectory ); + + if( pathFull[len - 1] == ':' ) // root dir + { + return true; // let it be + } +#if defined(MENGINE_PLATFORM_MACOS) + else if( pathFull[len - 1] == '~' ) // root dir + { + return true; // let it be + } +#endif + + bool exist = Detail::isDirectoryFullpath( pathFull ); + + return exist; + } + ////////////////////////////////////////////////////////////////////////// + bool SDLFileSystem::createDirectory( const Char * _basePath, const Char * _directory ) + { + size_t directorySize = StdString::strlen( _directory ); + + if( directorySize == 0 ) + { + return true; + } + + Char pathDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathDirectory, _directory ); + + Helper::pathRemoveFileSpecA( pathDirectory ); + + if( StdString::strlen( pathDirectory ) == 0 ) + { + return true; + } + + Char pathTestDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + StdString::strncpy( pathTestDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::strncat( pathTestDirectory, pathDirectory, MENGINE_MAX_PATH ); + + if( Detail::isDirectoryFullpath( pathTestDirectory ) == true ) + { + return true; + } + + Helper::pathRemoveBackslashA( pathDirectory ); + + uint32_t paths_count = 0; + Char paths[MENGINE_MAX_PATH + 1][16]; + + for( ;; ) + { + StdString::strncpy( paths[paths_count++], pathDirectory, MENGINE_MAX_PATH ); + + if( Helper::pathRemoveFileSpecA( pathDirectory ) == false ) + { + break; + } + + if( StdString::strlen( _basePath ) == 0 ) + { + break; + } + + Helper::pathRemoveBackslashA( pathDirectory ); + + StdString::strncpy( pathTestDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::strncat( pathTestDirectory, pathDirectory, MENGINE_MAX_PATH ); + + if( Detail::isDirectoryFullpath( pathTestDirectory ) == true ) + { + break; + } + } + + for( uint32_t index = paths_count; index != 0; --index ) + { + const Char * path = paths[index - 1]; + + Char pathCreateDirectory[MENGINE_MAX_PATH + 1] = {'\0'}; + StdString::strncpy( pathCreateDirectory, _basePath, MENGINE_MAX_PATH ); + StdString::strncat( pathCreateDirectory, path, MENGINE_MAX_PATH ); + + if( Detail::createDirectoryFullpath( pathCreateDirectory ) == false ) + { + return false; + } + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool SDLFileSystem::existFile( const Char * _filePath ) + { + Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); + + SDL_SuppressError( SDL_TRUE ); + + SDL_RWops * rwops = SDL_RWFromFile( pathCorrect, "rb" ); + + SDL_SuppressError( SDL_FALSE ); + + if( rwops == nullptr ) + { + return false; + } + + if( SDL_RWclose( rwops ) != 0 ) + { + LOGGER_ERROR( "invalid close '%s' get error: %s" + , pathCorrect + , SDL_GetError() + ); + + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool SDLFileSystem::removeFile( const Char * _filePath ) + { + Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( pathCorrect, _filePath ); + + int result = ::remove( pathCorrect ); + + if( result != 0 ) + { + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool SDLFileSystem::moveFile( const Char * _oldFilePath, const Char * _newFilePath ) + { + Char oldPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( oldPathCorrect, _oldFilePath ); + + Char newPathCorrect[MENGINE_MAX_PATH + 1] = {'\0'}; + Helper::pathCorrectBackslashToA( newPathCorrect, _newFilePath ); + + struct stat sb; + if( stat( newPathCorrect, &sb ) == 0 && ((sb.st_mode) & S_IFMT) != S_IFDIR ) + { + int result_remove = ::remove( newPathCorrect ); + + if( result_remove != 0 ) + { + const char * msg = ::strerror( errno ); + + LOGGER_ASSERTION( "invalid remove new move file from '%s' to '%s' error '%s' [%u]" + , _oldFilePath + , _newFilePath + , msg + , errno + ); + } + } + + int result_rename = ::rename( oldPathCorrect, newPathCorrect ); + + if( result_rename != 0 ) + { + const char * msg = ::strerror( errno ); + + LOGGER_ASSERTION( "invalid move file from '%s' to '%s' error '%s' [%u]" + , _oldFilePath + , _newFilePath + , msg + , errno + ); + + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// +#if defined(MENGINE_PLATFORM_WINDOWS) && !defined(MENGINE_PLATFORM_UWP) + ////////////////////////////////////////////////////////////////////////// + namespace Detail + { + ////////////////////////////////////////////////////////////////////////// + static bool listDirectoryContents( const WChar * _dir, const WChar * _mask, const WChar * _path, const LambdaFilePath & _lambda, bool * const _stop ) + { + WChar sDir[MENGINE_MAX_PATH + 1] = {L'\0'}; + ::PathCanonicalizeW( sDir, _dir ); + + { + WChar sPath[MENGINE_MAX_PATH + 1] = {L'\0'}; + StdString::wcscpy( sPath, sDir ); + StdString::wcscat( sPath, _path ); + StdString::wcscat( sPath, _mask ); + + WIN32_FIND_DATA fdFile; + HANDLE hFind = ::FindFirstFileEx( sPath, FindExInfoStandard, &fdFile, FindExSearchNameMatch, NULL, 0 ); + + if( hFind != INVALID_HANDLE_VALUE ) + { + do + { + if( StdString::wcscmp( fdFile.cFileName, L"." ) == 0 || + StdString::wcscmp( fdFile.cFileName, L".." ) == 0 ) + { + continue; + } + + if( fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) + { + continue; + } + + WChar sPath2[MENGINE_MAX_PATH + 1] = {L'\0'}; + StdString::wcscpy( sPath2, sPath ); + StdString::wcscat( sPath2, L"\0" ); + + Helper::pathCorrectForwardslashW( sPath2 ); + + ::PathRemoveFileSpec( sPath2 ); + + WChar unicode_filepath[MENGINE_MAX_PATH + 1] = {L'\0'}; + ::PathCombine( unicode_filepath, sPath2, fdFile.cFileName ); + + WChar unicode_out[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( StdString::wcslen( sDir ) != 0 ) + { + ::PathRelativePathTo( unicode_out + , sDir + , FILE_ATTRIBUTE_DIRECTORY + , unicode_filepath + , FILE_ATTRIBUTE_NORMAL ); + } + else + { + StdString::wcscpy( unicode_out, unicode_filepath ); + } + + Char utf8_filepath[MENGINE_MAX_PATH + 1] = {'\0'}; + if( Helper::unicodeToUtf8( unicode_out, utf8_filepath, MENGINE_MAX_PATH ) == false ) + { + ::FindClose( hFind ); + + return false; + } + + FilePath fp = Helper::stringizeFilePath( utf8_filepath ); + + if( _lambda( fp ) == false ) + { + ::FindClose( hFind ); + + *_stop = true; + + return true; + } + + } while( ::FindNextFile( hFind, &fdFile ) != FALSE ); + } + + ::FindClose( hFind ); + } + + { + WChar sPath[MENGINE_MAX_PATH + 1] = {L'\0'}; + StdString::wcscpy( sPath, sDir ); + StdString::wcscat( sPath, _path ); + StdString::wcscat( sPath, L"*.*" ); + + WIN32_FIND_DATA fdFile; + HANDLE hFind = ::FindFirstFileEx( sPath, FindExInfoStandard, &fdFile, FindExSearchNameMatch, NULL, 0 ); + + if( hFind == INVALID_HANDLE_VALUE ) + { + return true; + } + + do + { + if( StdString::wcscmp( fdFile.cFileName, L"." ) == 0 || + StdString::wcscmp( fdFile.cFileName, L".." ) == 0 ) + { + continue; + } + + if( (fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) + { + continue; + } + + WChar currentPath[MENGINE_MAX_PATH + 1] = {L'\0'}; + StdString::wcscpy( currentPath, sPath ); + StdString::wcscat( currentPath, L"\0" ); + + ::PathRemoveFileSpec( currentPath ); + + WChar nextPath[MENGINE_MAX_PATH + 1] = {L'\0'}; + ::PathCombine( nextPath, currentPath, fdFile.cFileName ); + + StdString::wcscat( nextPath, L"\\" ); + + bool stop; + if( Detail::listDirectoryContents( sDir, _mask, nextPath, _lambda, &stop ) == false ) + { + ::FindClose( hFind ); + + return false; + } + + if( stop == true ) + { + ::FindClose( hFind ); + + *_stop = true; + + return true; + } + + } while( ::FindNextFile( hFind, &fdFile ) != FALSE ); + + ::FindClose( hFind ); + } + + return true; + } + } + ////////////////////////////////////////////////////////////////////////// +#endif + ////////////////////////////////////////////////////////////////////////// + bool SDLFileSystem::findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const + { + MENGINE_UNUSED( _base ); + MENGINE_UNUSED( _path ); + MENGINE_UNUSED( _mask ); + MENGINE_UNUSED( _lambda ); + +#if defined(MENGINE_PLATFORM_WINDOWS) && !defined(MENGINE_PLATFORM_UWP) + WChar unicode_base[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _base, unicode_base, MENGINE_MAX_PATH - 1 ) == false ) + { + return false; + } + + WChar unicode_mask[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _mask, unicode_mask, MENGINE_MAX_PATH - 1 ) == false ) + { + return false; + } + + WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH - 1 ) == false ) + { + return false; + } + + WChar unicode_fullbase[MENGINE_MAX_PATH + 1] = {L'\0'}; + ::GetFullPathName( unicode_base, MENGINE_MAX_PATH, unicode_fullbase, NULL ); + + Helper::LambdaListDirectoryFilePath lambda_listdirectory = [_lambda]( const WChar * _filePath ) + { + Char utf8_filepath[MENGINE_MAX_PATH + 1] = {'\0'}; + if( Helper::unicodeToUtf8( _filePath, utf8_filepath, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + FilePath fp = Helper::stringizeFilePath( utf8_filepath ); + + bool result = _lambda( fp ); + + return result; + }; + + bool stop; + if( Helper::Win32ListDirectory( unicode_fullbase, unicode_mask, unicode_path, lambda_listdirectory, &stop ) == false ) + { + return false; + } + + MENGINE_UNUSED( stop ); + + return true; +#else + LOGGER_WARNING( "SDLPlatformService::findFiles not support" ); + + return false; +#endif + } + ////////////////////////////////////////////////////////////////////////// + uint64_t SDLFileSystem::getFileTime( const Char * _filePath ) const + { + MENGINE_UNUSED( _filePath ); + +#if defined(MENGINE_PLATFORM_WINDOWS) && !defined(MENGINE_PLATFORM_UWP) + WChar unicode_filePath[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _filePath, unicode_filePath, MENGINE_MAX_PATH - 1 ) == false ) + { + return 0U; + } + + HANDLE handle = ::CreateFile( unicode_filePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + + FILETIME creation; + FILETIME access; + FILETIME write; + + if( ::GetFileTime( handle, &creation, &access, &write ) == FALSE ) + { + ::CloseHandle( handle ); + + return 0U; + } + + ::CloseHandle( handle ); + + time_t time = Helper::Win32FileTimeToUnixTime( &write ); + + return time; +#else + return 0U; +#endif + } + ////////////////////////////////////////////////////////////////////////// } diff --git a/src/Systems/SDLFileSystem/SDLFileSystem.h b/src/Systems/SDLFileSystem/SDLFileSystem.h index 00497a76b5..e3a7a9032b 100644 --- a/src/Systems/SDLFileSystem/SDLFileSystem.h +++ b/src/Systems/SDLFileSystem/SDLFileSystem.h @@ -13,8 +13,23 @@ namespace Mengine SDLFileSystem(); ~SDLFileSystem() override; - protected: + public: bool _initializeService() override; void _finalizeService() override; + + public: + bool existDirectory( const Char * _basePath, const Char * _directory ) const override; + bool createDirectory( const Char * _basePath, const Char * _directory ) override; + + public: + bool existFile( const Char * _filePath ) override; + bool removeFile( const Char * _filePath ) override; + bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) override; + + public: + bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const override; + + public: + uint64_t getFileTime( const Char * _filePath ) const override; }; } diff --git a/src/Systems/SDLFileSystem/SDLMutexFileInputStream.cpp b/src/Systems/SDLFileSystem/SDLMutexFileInputStream.cpp index 67c23499cf..f0de24f0b6 100644 --- a/src/Systems/SDLFileSystem/SDLMutexFileInputStream.cpp +++ b/src/Systems/SDLFileSystem/SDLMutexFileInputStream.cpp @@ -1,7 +1,6 @@ #include "SDLMutexFileInputStream.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/ThreadServiceInterface.h" +#include "Interface/FileSystemInterface.h" #if defined(MENGINE_DEBUG) # include "Interface/PlatformServiceInterface.h" @@ -291,7 +290,7 @@ namespace Mengine return false; } - uint64_t ft = PLATFORM_SERVICE() + uint64_t ft = FILE_SYSTEM() ->getFileTime( fullPath ); *_time = ft; diff --git a/src/Systems/SDLFileSystem/SDLMutexFileInputStream.h b/src/Systems/SDLFileSystem/SDLMutexFileInputStream.h index 93187cbe09..881ef62ee6 100644 --- a/src/Systems/SDLFileSystem/SDLMutexFileInputStream.h +++ b/src/Systems/SDLFileSystem/SDLMutexFileInputStream.h @@ -3,6 +3,8 @@ #include "Interface/FileInputStreamInterface.h" #include "Interface/ThreadMutexInterface.h" +#include "Environment/SDL/SDLIncluder.h" + #include "SDLFileInputStream.h" #include "Kernel/Factorable.h" @@ -11,8 +13,6 @@ # include "Kernel/BaseDebugFile.h" #endif -#include "SDL_rwops.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/SDLThreadSystem/SDLThreadConditionVariable.h b/src/Systems/SDLThreadSystem/SDLThreadConditionVariable.h index 2788784312..1855f22788 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadConditionVariable.h +++ b/src/Systems/SDLThreadSystem/SDLThreadConditionVariable.h @@ -2,9 +2,9 @@ #include "Interface/ThreadConditionVariableInterface.h" -#include "Kernel/Factorable.h" +#include "Environment/SDL/SDLIncluder.h" -#include "SDL_thread.h" +#include "Kernel/Factorable.h" namespace Mengine { diff --git a/src/Systems/SDLThreadSystem/SDLThreadIdentity.cpp b/src/Systems/SDLThreadSystem/SDLThreadIdentity.cpp index 1a98287fd1..4162515b8e 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadIdentity.cpp +++ b/src/Systems/SDLThreadSystem/SDLThreadIdentity.cpp @@ -16,7 +16,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static int s_treadJob( void * _userData ) + static int treadJob( void * _userData ) { SDLThreadIdentity * thread = reinterpret_cast(_userData); @@ -88,7 +88,7 @@ namespace Mengine { m_runner = Helper::makeFactorableUnique( _doc, _lambda, _sleep ); - SDL_Thread * thread = SDL_CreateThread( &Detail::s_treadJob, m_description.nameA, reinterpret_cast(this) ); + SDL_Thread * thread = SDL_CreateThread( &Detail::treadJob, m_description.nameA, reinterpret_cast(this) ); if( thread == nullptr ) { diff --git a/src/Systems/SDLThreadSystem/SDLThreadIdentity.h b/src/Systems/SDLThreadSystem/SDLThreadIdentity.h index 25af406cb4..3fa1049017 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadIdentity.h +++ b/src/Systems/SDLThreadSystem/SDLThreadIdentity.h @@ -2,15 +2,14 @@ #include "Interface/ThreadIdentityInterface.h" +#include "Environment/SDL/SDLIncluder.h" + #include "Kernel/Factorable.h" #include "Kernel/ConstString.h" #include "Kernel/String.h" #include "Config/Atomic.h" -#include "SDL_thread.h" -#include "SDL_timer.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/SDLThreadSystem/SDLThreadMutex.h b/src/Systems/SDLThreadSystem/SDLThreadMutex.h index baf4a89099..43ecdb23e9 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadMutex.h +++ b/src/Systems/SDLThreadSystem/SDLThreadMutex.h @@ -2,9 +2,9 @@ #include "Interface/ThreadMutexInterface.h" -#include "Kernel/Factorable.h" +#include "Environment/SDL/SDLIncluder.h" -#include "SDL_thread.h" +#include "Kernel/Factorable.h" namespace Mengine { diff --git a/src/Systems/SDLThreadSystem/SDLThreadProcessor.cpp b/src/Systems/SDLThreadSystem/SDLThreadProcessor.cpp index 934e6fde00..d656254462 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadProcessor.cpp +++ b/src/Systems/SDLThreadSystem/SDLThreadProcessor.cpp @@ -11,7 +11,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static int s_treadJob( void * _userData ) + static int treadJob( void * _userData ) { SDLThreadProcessor * thread = reinterpret_cast(_userData); @@ -133,7 +133,7 @@ namespace Mengine m_conditionLock = conditionLock; m_conditionVariable = conditionVariable; - SDL_Thread * thread = SDL_CreateThread( &Detail::s_treadJob, m_description.nameA, reinterpret_cast(this) ); + SDL_Thread * thread = SDL_CreateThread( &Detail::treadJob, m_description.nameA, reinterpret_cast(this) ); if( thread == nullptr ) { @@ -223,7 +223,7 @@ namespace Mengine if( m_exit == false ) { m_mutex->lock(); - m_task->main(); + m_task->process(); m_mutex->unlock(); } diff --git a/src/Systems/SDLThreadSystem/SDLThreadProcessor.h b/src/Systems/SDLThreadSystem/SDLThreadProcessor.h index 6d4b6f0806..c766d7e708 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadProcessor.h +++ b/src/Systems/SDLThreadSystem/SDLThreadProcessor.h @@ -2,15 +2,14 @@ #include "Interface/ThreadProcessorInterface.h" +#include "Environment/SDL/SDLIncluder.h" + #include "Kernel/Factorable.h" #include "Kernel/ConstString.h" #include "Kernel/String.h" #include "Config/Atomic.h" -#include "SDL_thread.h" -#include "SDL_timer.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/SDLThreadSystem/SDLThreadSharedMutex.h b/src/Systems/SDLThreadSystem/SDLThreadSharedMutex.h index 231e66affc..d55a8aca51 100644 --- a/src/Systems/SDLThreadSystem/SDLThreadSharedMutex.h +++ b/src/Systems/SDLThreadSystem/SDLThreadSharedMutex.h @@ -2,11 +2,11 @@ #include "Interface/ThreadSharedMutexInterface.h" +#include "Environment/SDL/SDLIncluder.h" + #include "Kernel/Factorable.h" #include "Kernel/String.h" -#include "SDL_thread.h" - namespace Mengine { ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/Win32FileSystem/Win32FileGroupDirectory.cpp b/src/Systems/Win32FileSystem/Win32FileGroupDirectory.cpp index 41af1e01e5..ee79a6da79 100644 --- a/src/Systems/Win32FileSystem/Win32FileGroupDirectory.cpp +++ b/src/Systems/Win32FileSystem/Win32FileGroupDirectory.cpp @@ -1,7 +1,7 @@ #include "Win32FileGroupDirectory.h" #include "Interface/MemoryInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Win32ConcatenateFileHelper.h" #include "Win32FileInputStream.h" @@ -76,7 +76,7 @@ namespace Mengine Char utf8_filePath[MENGINE_MAX_PATH + 1] = {'\0'}; this->getFullPath( _filePath, utf8_filePath ); - bool result = PLATFORM_SERVICE() + bool result = FILE_SYSTEM() ->existFile( utf8_filePath ); if( _recursive == true && result == false && m_parentFileGroup != nullptr ) @@ -97,7 +97,7 @@ namespace Mengine filePathString.append( folderPath ); filePathString.append( _filePath ); - bool successful = PLATFORM_SERVICE() + bool successful = FILE_SYSTEM() ->removeFile( filePathString.c_str() ); return successful; @@ -112,7 +112,7 @@ namespace Mengine basePath.append( relationPath ); basePath.append( folderPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->existDirectory( basePath.c_str(), _folderPath.c_str() ) == true ) { return true; @@ -138,13 +138,13 @@ namespace Mengine basePath.append( relationPath ); basePath.append( folderPath ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->existDirectory( basePath.c_str(), _folderName.c_str() ) == true ) { return true; } - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->createDirectory( basePath.c_str(), _folderName.c_str() ) == false ) { return false; @@ -168,7 +168,7 @@ namespace Mengine newFilePathString.append( folderPath ); newFilePathString.append( _newFilePath ); - bool successful = PLATFORM_SERVICE() + bool successful = FILE_SYSTEM() ->moveFile( oldFilePathString.c_str(), newFilePathString.c_str() ); return successful; @@ -181,7 +181,7 @@ namespace Mengine Helper::pathCorrectForwardslashA( fullPathBase ); - PLATFORM_SERVICE() + FILE_SYSTEM() ->findFiles( fullPathBase, _filePath.c_str(), _mask, _lambda ); return true; diff --git a/src/Systems/Win32FileSystem/Win32FileOutputStream.cpp b/src/Systems/Win32FileSystem/Win32FileOutputStream.cpp index e6740a2367..20e43684e0 100644 --- a/src/Systems/Win32FileSystem/Win32FileOutputStream.cpp +++ b/src/Systems/Win32FileSystem/Win32FileOutputStream.cpp @@ -1,7 +1,6 @@ #include "Win32FileOutputStream.h" -#include "Interface/UnicodeSystemInterface.h" -#include "Interface/PlatformServiceInterface.h" +#include "Interface/FileSystemInterface.h" #include "Environment/Windows/Win32FileHelper.h" #include "Environment/Windows/Win32Helper.h" @@ -144,7 +143,7 @@ namespace Mengine , m_filePath.c_str() ); - if( PLATFORM_SERVICE() + if( FILE_SYSTEM() ->moveFile( fullPathTemp, fullPath ) == false ) { LOGGER_ERROR( "invalid move close file from '%s' to '%s'" diff --git a/src/Systems/Win32FileSystem/Win32FileSystem.cpp b/src/Systems/Win32FileSystem/Win32FileSystem.cpp index 889153c81e..02519ddd08 100644 --- a/src/Systems/Win32FileSystem/Win32FileSystem.cpp +++ b/src/Systems/Win32FileSystem/Win32FileSystem.cpp @@ -3,6 +3,10 @@ #include "Interface/FileServiceInterface.h" #include "Interface/PlatformServiceInterface.h" +#include "Environment/Windows/WindowsIncluder.h" +#include "Environment/Windows/Win32Helper.h" +#include "Environment/Windows/Win32FileHelper.h" + #include "Win32FileGroupDirectoryFactory.h" #include "Win32FileGroupDirectory.h" @@ -10,7 +14,12 @@ #include "Kernel/FilePath.h" #include "Kernel/ConstStringHelper.h" #include "Kernel/FilePathHelper.h" +#include "Kernel/PathHelper.h" #include "Kernel/VocabularyHelper.h" +#include "Kernel/UnicodeHelper.h" +#include "Kernel/Logger.h" + +#include "Config/StdString.h" ////////////////////////////////////////////////////////////////////////// SERVICE_FACTORY( FileSystem, Mengine::Win32FileSystem ); @@ -51,4 +60,316 @@ namespace Mengine VOCABULARY_REMOVE( STRINGIZE_STRING_LOCAL( "FileGroupFactory" ), STRINGIZE_STRING_LOCAL( "dir" ) ); } ////////////////////////////////////////////////////////////////////////// + bool Win32FileSystem::existDirectory( const Char * _path, const Char * _directory ) const + { + MENGINE_ASSERTION_FATAL( StdString::strlen( _path ) == 0 + || (StdString::strrchr( _path, '.' ) > StdString::strrchr( _path, MENGINE_PATH_DELIM ) + || _path[StdString::strlen( _path ) - 1] == MENGINE_PATH_DELIM + || _path[StdString::strlen( _path ) - 1] == MENGINE_WIN32_PATH_DELIM) + , "invalid path '%s'", _path + ); + + MENGINE_ASSERTION_FATAL( StdString::strlen( _directory ) == 0 + || (StdString::strrchr( _directory, '.' ) > StdString::strrchr( _directory, MENGINE_PATH_DELIM ) + || _directory[StdString::strlen( _directory ) - 1] == MENGINE_PATH_DELIM + || _directory[StdString::strlen( _directory ) - 1] == MENGINE_WIN32_PATH_DELIM) + , "invalid directory '%s'", _directory + ); + + WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar unicode_directory[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _directory, unicode_directory, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar pathDirectory[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( pathDirectory, unicode_directory ); + + Helper::pathRemoveFileSpecW( pathDirectory ); + + size_t len = StdString::wcslen( pathDirectory ); + + if( len == 0 ) + { + return true; + } + + WChar pathFull[MENGINE_MAX_PATH + 1] = {'\0'}; + MENGINE_SWPRINTF( pathFull, MENGINE_MAX_PATH, L"%ls%ls" + , unicode_path + , pathDirectory + ); + + if( pathFull[len - 1] == L':' ) + { + return true; + } + + DWORD attributes = ::GetFileAttributes( pathFull ); + + if( attributes == INVALID_FILE_ATTRIBUTES ) + { + return false; + } + + if( (attributes & FILE_ATTRIBUTE_DIRECTORY) == 0 ) + { + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool Win32FileSystem::createDirectory( const Char * _path, const Char * _directory ) + { + LOGGER_INFO( "file", "create directory path '%s' directory '%s'" + , _path + , _directory + ); + + MENGINE_ASSERTION_FATAL( StdString::strlen( _path ) == 0 + || (StdString::strrchr( _path, '.' ) > StdString::strrchr( _path, MENGINE_PATH_DELIM ) + || _path[StdString::strlen( _path ) - 1] == MENGINE_PATH_DELIM + || _path[StdString::strlen( _path ) - 1] == MENGINE_WIN32_PATH_DELIM) + , "invalid path '%s'", _path + ); + + MENGINE_ASSERTION_FATAL( StdString::strlen( _directory ) == 0 + || (StdString::strrchr( _directory, '.' ) > StdString::strrchr( _directory, MENGINE_PATH_DELIM ) + || _directory[StdString::strlen( _directory ) - 1] == MENGINE_PATH_DELIM + || _directory[StdString::strlen( _directory ) - 1] == MENGINE_WIN32_PATH_DELIM) + , "invalid directory '%s'", _directory + ); + + WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar unicode_directory[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _directory, unicode_directory, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + bool result = Helper::Win32CreateDirectory( unicode_path, unicode_directory ); + + return result; + } + ////////////////////////////////////////////////////////////////////////// + bool Win32FileSystem::existFile( const Char * _filePath ) + { + WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _filePath, unicode_path, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + bool result = Helper::Win32ExistFile( unicode_path ); + + return result; + } + ////////////////////////////////////////////////////////////////////////// + bool Win32FileSystem::removeFile( const Char * _filePath ) + { + LOGGER_INFO( "file", "remove file '%s'" + , _filePath + ); + + WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _filePath, unicode_path, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar pathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( pathCorrect, unicode_path ); + + if( ::DeleteFileW( pathCorrect ) == FALSE ) + { + LOGGER_ERROR( "invalid DeleteFile '%ls' %ls" + , pathCorrect + , Helper::Win32GetLastErrorMessageW() + ); + + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool Win32FileSystem::moveFile( const Char * _oldFilePath, const Char * _newFilePath ) + { + LOGGER_INFO( "file", "move file from '%s' to '%s'" + , _oldFilePath + , _newFilePath + ); + + WChar unicode_oldFilePath[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _oldFilePath, unicode_oldFilePath, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar oldFilePathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( oldFilePathCorrect, unicode_oldFilePath ); + + WChar unicode_newFilePath[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _newFilePath, unicode_newFilePath, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar newFilePathCorrect[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::pathCorrectBackslashToW( newFilePathCorrect, unicode_newFilePath ); + +#if defined(MENGINE_DEBUG) + DWORD oldFileAttributes = ::GetFileAttributesW( oldFilePathCorrect ); + + if( oldFileAttributes != INVALID_FILE_ATTRIBUTES && (oldFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) + { + LOGGER_WARNING( "invalid move old file '%ls' it's directory" + , newFilePathCorrect + ); + + return false; + } +#endif + + DWORD newFileAttributes = ::GetFileAttributesW( newFilePathCorrect ); + + if( newFileAttributes != INVALID_FILE_ATTRIBUTES ) + { +#if defined(MENGINE_DEBUG) + if( (newFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) + { + LOGGER_WARNING( "invalid move file '%ls' it's directory" + , newFilePathCorrect + ); + + return false; + } +#endif + + if( ::DeleteFileW( newFilePathCorrect ) == FALSE ) + { + LOGGER_ERROR( "invalid move file '%ls' %ls" + , newFilePathCorrect + , Helper::Win32GetLastErrorMessageW() + ); + } + } + + if( ::MoveFileW( oldFilePathCorrect, newFilePathCorrect ) == FALSE ) + { + LOGGER_ERROR( "file '%ls' move to '%ls' %ls" + , oldFilePathCorrect + , newFilePathCorrect + , Helper::Win32GetLastErrorMessageW() + ); + + return false; + } + + return true; + } + ////////////////////////////////////////////////////////////////////////// + bool Win32FileSystem::findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const + { + WChar unicode_base[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _base, unicode_base, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar unicode_mask[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _mask, unicode_mask, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar unicode_path[MENGINE_MAX_PATH + 1] = {L'\0'}; + if( Helper::utf8ToUnicode( _path, unicode_path, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + WChar unicode_fullbase[MENGINE_MAX_PATH + 1] = {L'\0'}; + ::GetFullPathNameW( unicode_base, MENGINE_MAX_PATH, unicode_fullbase, NULL ); + + Helper::LambdaListDirectoryFilePath lambda_listdirectory = [_lambda]( const WChar * _filePath ) + { + Char utf8_filepath[MENGINE_MAX_PATH + 1] = {'\0'}; + if( Helper::unicodeToUtf8( _filePath, utf8_filepath, MENGINE_MAX_PATH ) == false ) + { + return false; + } + + FilePath fp = Helper::stringizeFilePath( utf8_filepath ); + + bool result = _lambda( fp ); + + return result; + }; + + bool stop; + if( Helper::Win32ListDirectory( unicode_fullbase, unicode_mask, unicode_path, lambda_listdirectory, &stop ) == false ) + { + return false; + } + + MENGINE_UNUSED( stop ); + + return true; + } + ////////////////////////////////////////////////////////////////////////// + uint64_t Win32FileSystem::getFileTime( const Char * _filePath ) const + { + WChar unicode_filePath[MENGINE_MAX_PATH + 1] = {L'\0'}; + Helper::utf8ToUnicode( _filePath, unicode_filePath, MENGINE_MAX_PATH ); + + HANDLE handle = ::CreateFileW( unicode_filePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + + if( handle == INVALID_HANDLE_VALUE ) + { + LOGGER_ERROR( "get file time '%ls' invalid CreateFile %ls" + , unicode_filePath + , Helper::Win32GetLastErrorMessageW() + ); + + return 0U; + } + + FILETIME creation; + FILETIME access; + FILETIME write; + + BOOL result = ::GetFileTime( handle, &creation, &access, &write ); + + if( result == FALSE ) + { + ::CloseHandle( handle ); + + LOGGER_ERROR( "get file time '%ls' invalid GetFileTime %ls" + , unicode_filePath + , Helper::Win32GetLastErrorMessageW() + ); + + return 0U; + } + + ::CloseHandle( handle ); + + time_t time = Helper::Win32FileTimeToUnixTime( &write ); + + return time; + } + ////////////////////////////////////////////////////////////////////////// } \ No newline at end of file diff --git a/src/Systems/Win32FileSystem/Win32FileSystem.h b/src/Systems/Win32FileSystem/Win32FileSystem.h index 46c50a16b9..2ff0eed984 100644 --- a/src/Systems/Win32FileSystem/Win32FileSystem.h +++ b/src/Systems/Win32FileSystem/Win32FileSystem.h @@ -13,8 +13,23 @@ namespace Mengine Win32FileSystem(); ~Win32FileSystem() override; - protected: + public: bool _initializeService() override; void _finalizeService() override; + + public: + bool existDirectory( const Char * _directoryPath, const Char * _directory ) const override; + bool createDirectory( const Char * _directoryPath, const Char * _directory ) override; + + public: + bool existFile( const Char * _filePath ) override; + bool removeFile( const Char * _filePath ) override; + bool moveFile( const Char * _oldFilePath, const Char * _newFilePath ) override; + + public: + virtual bool findFiles( const Char * _base, const Char * _path, const Char * _mask, const LambdaFilePath & _lambda ) const override; + + public: + uint64_t getFileTime( const Char * _filePath ) const override; }; } \ No newline at end of file diff --git a/src/Systems/Win32ThreadSystem/Win32ThreadIdentity.cpp b/src/Systems/Win32ThreadSystem/Win32ThreadIdentity.cpp index 7046d3ff94..3b113c2b47 100644 --- a/src/Systems/Win32ThreadSystem/Win32ThreadIdentity.cpp +++ b/src/Systems/Win32ThreadSystem/Win32ThreadIdentity.cpp @@ -20,7 +20,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static DWORD WINAPI s_treadJob( LPVOID lpThreadParameter ) + static DWORD WINAPI treadJob( LPVOID lpThreadParameter ) { Win32ThreadIdentity * thread = static_cast(lpThreadParameter); @@ -82,7 +82,7 @@ namespace Mengine { m_runner = Helper::makeFactorableUnique( _doc, _lambda, _sleep ); - HANDLE thread = ::CreateThread( NULL, 0, &Detail::s_treadJob, (LPVOID)this, 0, NULL ); + HANDLE thread = ::CreateThread( NULL, 0, &Detail::treadJob, (LPVOID)this, 0, NULL ); if( thread == NULL ) { diff --git a/src/Systems/Win32ThreadSystem/Win32ThreadProcessor.cpp b/src/Systems/Win32ThreadSystem/Win32ThreadProcessor.cpp index cc6653c666..1d94148b56 100644 --- a/src/Systems/Win32ThreadSystem/Win32ThreadProcessor.cpp +++ b/src/Systems/Win32ThreadSystem/Win32ThreadProcessor.cpp @@ -15,7 +15,7 @@ namespace Mengine namespace Detail { ////////////////////////////////////////////////////////////////////////// - static DWORD WINAPI s_treadJob( LPVOID lpThreadParameter ) + static DWORD WINAPI treadJob( LPVOID lpThreadParameter ) { Win32ThreadProcessor * thread = static_cast(lpThreadParameter); @@ -71,7 +71,7 @@ namespace Mengine ::InitializeConditionVariable( &m_conditionVariable ); #endif - HANDLE thread = ::CreateThread( NULL, 0, &Detail::s_treadJob, (LPVOID)this, 0, NULL ); + HANDLE thread = ::CreateThread( NULL, 0, &Detail::treadJob, (LPVOID)this, 0, NULL ); if( thread == NULL ) { @@ -180,7 +180,7 @@ namespace Mengine MENGINE_PROFILER_FRAME( "thread" ); - m_task->main(); + m_task->process(); m_mutex->unlock(); }