From b90c6abc33bab36f675f554948ffc9d24a048473 Mon Sep 17 00:00:00 2001 From: irov Date: Tue, 3 Dec 2024 19:19:26 +0200 Subject: [PATCH] fix ios --- src/Systems/AppleFileSystem/AppleFileSystem.mm | 2 ++ src/Systems/AppleHttpSystem/AppleHttpRequest.h | 6 ++++-- src/Systems/AppleHttpSystem/AppleHttpRequest.mm | 14 +++++++++++--- .../AppleHttpRequestDeleteMessage.mm | 1 + .../AppleHttpSystem/AppleHttpRequestGetAsset.mm | 1 + .../AppleHttpSystem/AppleHttpRequestGetMessage.mm | 1 + .../AppleHttpSystem/AppleHttpRequestHeaderData.mm | 1 + .../AppleHttpSystem/AppleHttpRequestPing.mm | 1 + .../AppleHttpSystem/AppleHttpRequestPostMessage.mm | 1 + 9 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Systems/AppleFileSystem/AppleFileSystem.mm b/src/Systems/AppleFileSystem/AppleFileSystem.mm index ef186ba8d8..e2fc8ecbef 100644 --- a/src/Systems/AppleFileSystem/AppleFileSystem.mm +++ b/src/Systems/AppleFileSystem/AppleFileSystem.mm @@ -139,6 +139,8 @@ static bool isDirectoryFullpath( const Char * _fullpath ) Path correctDirectory = {'\0'}; Helper::pathCorrectBackslashToA( correctDirectory, _directory ); + Helper::pathRemoveFileSpecA( correctDirectory, MENGINE_PATH_DELIM_BACKSLASH ); + size_t correctDirectoryLen = StdString::strlen( correctDirectory ); if( correctDirectoryLen == 0 ) diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequest.h b/src/Systems/AppleHttpSystem/AppleHttpRequest.h index a06fcf6cb1..b6987daaf3 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequest.h +++ b/src/Systems/AppleHttpSystem/AppleHttpRequest.h @@ -11,14 +11,14 @@ namespace Mengine : public BaseHttpRequest { public: - AppleHttpRequest(); + AppleHttpRequest( bool _isJSON ); ~AppleHttpRequest() override; protected: void _onThreadTaskPreparation() override; bool _onThreadTaskRun() override; bool _onThreadTaskProcess() override; - + protected: virtual MengineHttpResponseParam * _onHttp( MengineHttpRequestParam * request ) = 0; @@ -26,6 +26,8 @@ namespace Mengine void _onThreadTaskComplete( bool _successful ) override; protected: + bool m_isJSON; + ThreadMutexInterfacePtr m_mutex; }; ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequest.mm b/src/Systems/AppleHttpSystem/AppleHttpRequest.mm index 36b5652ec3..1ce4969454 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequest.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequest.mm @@ -16,7 +16,8 @@ namespace Mengine { ////////////////////////////////////////////////////////////////////////// - AppleHttpRequest::AppleHttpRequest() + AppleHttpRequest::AppleHttpRequest( bool _isJSON ) + : m_isJSON( _isJSON ) { } ////////////////////////////////////////////////////////////////////////// @@ -81,9 +82,16 @@ if( response.HTTP_CONTENT_DATA != nullptr ) { - const Char * bytes = (const Char *)[response.HTTP_CONTENT_DATA bytes]; + const void * bytes = [response.HTTP_CONTENT_DATA bytes]; - m_response->appendData( bytes, response.HTTP_CONTENT_LENGTH ); + if( m_isJSON == true ) + { + m_response->appendJSON( bytes, response.HTTP_CONTENT_LENGTH ); + } + else + { + m_response->appendData( bytes, response.HTTP_CONTENT_LENGTH ); + } } if( response.HTTP_ERROR_MESSAGE != nullptr ) diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequestDeleteMessage.mm b/src/Systems/AppleHttpSystem/AppleHttpRequestDeleteMessage.mm index b5d1c21cb5..d207d25ed1 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequestDeleteMessage.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequestDeleteMessage.mm @@ -4,6 +4,7 @@ { ////////////////////////////////////////////////////////////////////////// AppleHttpRequestDeleteMessage::AppleHttpRequestDeleteMessage() + : AppleHttpRequest( true ) { } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequestGetAsset.mm b/src/Systems/AppleHttpSystem/AppleHttpRequestGetAsset.mm index b24faaf256..da7c0801d1 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequestGetAsset.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequestGetAsset.mm @@ -16,6 +16,7 @@ { ////////////////////////////////////////////////////////////////////////// AppleHttpRequestGetAsset::AppleHttpRequestGetAsset() + : AppleHttpRequest( false ) { } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequestGetMessage.mm b/src/Systems/AppleHttpSystem/AppleHttpRequestGetMessage.mm index a3e528665a..e0130444da 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequestGetMessage.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequestGetMessage.mm @@ -4,6 +4,7 @@ { ////////////////////////////////////////////////////////////////////////// AppleHttpRequestGetMessage::AppleHttpRequestGetMessage() + : AppleHttpRequest( true ) { } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequestHeaderData.mm b/src/Systems/AppleHttpSystem/AppleHttpRequestHeaderData.mm index 5d1612c44d..73e31790a5 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequestHeaderData.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequestHeaderData.mm @@ -6,6 +6,7 @@ { ////////////////////////////////////////////////////////////////////////// AppleHttpRequestHeaderData::AppleHttpRequestHeaderData() + : AppleHttpRequest( true ) { } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequestPing.mm b/src/Systems/AppleHttpSystem/AppleHttpRequestPing.mm index e9f0f05c9b..26fa563d80 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequestPing.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequestPing.mm @@ -4,6 +4,7 @@ { ////////////////////////////////////////////////////////////////////////// AppleHttpRequestPing::AppleHttpRequestPing() + : AppleHttpRequest( true ) { } ////////////////////////////////////////////////////////////////////////// diff --git a/src/Systems/AppleHttpSystem/AppleHttpRequestPostMessage.mm b/src/Systems/AppleHttpSystem/AppleHttpRequestPostMessage.mm index 9847257a23..5e6bd61ae6 100644 --- a/src/Systems/AppleHttpSystem/AppleHttpRequestPostMessage.mm +++ b/src/Systems/AppleHttpSystem/AppleHttpRequestPostMessage.mm @@ -6,6 +6,7 @@ { ////////////////////////////////////////////////////////////////////////// AppleHttpRequestPostMessage::AppleHttpRequestPostMessage() + : AppleHttpRequest( true ) { } //////////////////////////////////////////////////////////////////////////