Skip to content

Commit

Permalink
wip apple file system
Browse files Browse the repository at this point in the history
  • Loading branch information
irov committed Nov 4, 2024
1 parent 48dd0ea commit 64b3380
Show file tree
Hide file tree
Showing 23 changed files with 172 additions and 138 deletions.
4 changes: 3 additions & 1 deletion src/Kernel/JSONHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "Config/StdString.h"

#include "stdex/memorycopy.h"

namespace Mengine
{
namespace Helper
Expand Down Expand Up @@ -58,7 +60,7 @@ namespace Mengine
}

const uint8_t * jd_buffer = jd->buffer + jd->carriage;
StdString::memcpy( _buffer, jd_buffer, _buflen );
stdex::memorycopy( _buffer, 0, jd_buffer, _buflen );
jd->carriage += _buflen;

return _buflen;
Expand Down
6 changes: 4 additions & 2 deletions src/Kernel/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "Config/StdString.h"
#include "Config/StdIO.h"

#include "stdex/memorycopy.h"

#define SHA1_ROLL Detail::SHA1_rotl32
#define SHA1_BLK0(i) (block->l[i] = (SHA1_ROLL(block->l[i],24)&0xFF00FF00) | (SHA1_ROLL(block->l[i],8)&0x00FF00FF))
#define SHA1_BLK(i) (block->l[i&15] = SHA1_ROLL(block->l[(i+13)&15]^block->l[(i+8)&15]^block->l[(i+2)&15]^block->l[i&15],1))
Expand Down Expand Up @@ -105,7 +107,7 @@ namespace Mengine

if( (j + len) > 63 )
{
StdString::memcpy( &context->buffer[j], data, (i = 64 - j) * sizeof( uint8_t ) );
stdex::memorycopy( context->buffer, j, data, (i = 64 - j) * sizeof( uint8_t ) );

SHA1_Transform( context->state, context->buffer );

Expand All @@ -121,7 +123,7 @@ namespace Mengine
i = 0;
}

StdString::memcpy( &context->buffer[j], &data[i], (len - i) * sizeof( uint8_t ) );
stdex::memorycopy( context->buffer, j, &data[i], (len - i) * sizeof( uint8_t ) );
}
//////////////////////////////////////////////////////////////////////////
MENGINE_INLINE void SHA1_Final( SHA1_CTX * context, uint8_t * const digest, size_t _size )
Expand Down
12 changes: 7 additions & 5 deletions src/Kernel/StringSlice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "Config/StdString.h"

#include "stdex/memorycopy.h"

namespace Mengine
{
namespace Helper
Expand All @@ -20,7 +22,7 @@ namespace Mengine

for( ; data_index + _capacity < _size; data_index += _capacity )
{
StdString::memcpy( _buffer, _in + data_index, _capacity );
stdex::memorycopy( _buffer, 0, _in + data_index, _capacity );
_buffer[_capacity] = '\0';

if( _lambda( _buffer ) == false )
Expand All @@ -36,7 +38,7 @@ namespace Mengine

size_t tail_size = _size - data_index;

StdString::memcpy( _buffer, _in + data_index, tail_size );
stdex::memorycopy( _buffer, 0, _in + data_index, tail_size );
_buffer[tail_size] = '\0';

if( _lambda( _buffer ) == false )
Expand Down Expand Up @@ -74,7 +76,7 @@ namespace Mengine

size_t correct_size = it_correct - it_slice;

StdString::memcpy( _buffer, it_slice, correct_size );
stdex::memorycopy( _buffer, 0, it_slice, correct_size );
_buffer[correct_size] = '\0';

if( _lambda( _buffer ) == false )
Expand All @@ -97,7 +99,7 @@ namespace Mengine

size_t tail_size = it_end - it_slice;

StdString::memcpy( _buffer, it_slice, tail_size );
stdex::memorycopy( _buffer, 0, it_slice, tail_size );
_buffer[tail_size] = '\0';

if( _lambda( _buffer ) == false )
Expand All @@ -109,4 +111,4 @@ namespace Mengine
}
///////////////////////////////////////////////////////////////////////
}
}
}
12 changes: 8 additions & 4 deletions src/Platforms/iOSPlatform/iOSPlatformService.mm
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@
//////////////////////////////////////////////////////////////////////////
size_t iOSPlatformService::getCurrentPath( Char * const _currentPath ) const
{
const Char deploy_mac_data[] = "";
StdString::strcpy( _currentPath, deploy_mac_data );
NSString * path = [[NSBundle mainBundle] resourcePath];

StdString::strncpy( _currentPath, [path UTF8String], MENGINE_MAX_PATH );
StdString::strncat( _currentPath, "/", MENGINE_MAX_PATH );

return sizeof( deploy_mac_data ) - 1;
size_t path_length = [path length] + 1;

return path_length;
}
//////////////////////////////////////////////////////////////////////////
size_t iOSPlatformService::getUserPath( Char * const _userPath ) const
Expand Down Expand Up @@ -1662,7 +1666,7 @@ static bool s_isDirectoryFullpath( const Char * _fullpath )
{
Char pathCorrect[MENGINE_MAX_PATH + 1] = {'\0'};
Helper::pathCorrectBackslashToA( pathCorrect, _filePath );

if( [[NSFileManager defaultManager] fileExistsAtPath:@(pathCorrect)] == NO)
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/AppleAppLovinPlugin/AppleAppLovinPlugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleAppLovinService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleAppLovin, Mengine::AppleAppLovinPlugin )
PLUGIN_FACTORY( AppleAppLovin, Mengine::AppleAppLovinPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleFirebaseAnalyticsService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleFirebaseAnalytics, Mengine::AppleFirebaseAnalyticsPlugin )
PLUGIN_FACTORY( AppleFirebaseAnalytics, Mengine::AppleFirebaseAnalyticsPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleFirebaseCrashlyticsService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleFirebaseCrashlytics, Mengine::AppleFirebaseCrashlyticsPlugin )
PLUGIN_FACTORY( AppleFirebaseCrashlytics, Mengine::AppleFirebaseCrashlyticsPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleFirebasePerformanceMonitoringService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleFirebasePerformanceMonitoring, Mengine::AppleFirebasePerformanceMonitoringPlugin )
PLUGIN_FACTORY( AppleFirebasePerformanceMonitoring, Mengine::AppleFirebasePerformanceMonitoringPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/AppleFirebasePlugin/AppleFirebasePlugin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "Kernel/PluginHelper.h"

//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleFirebase, Mengine::AppleFirebasePlugin )
PLUGIN_FACTORY( AppleFirebase, Mengine::AppleFirebasePlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleFirebaseRemoteConfigService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleFirebaseRemoteConfig, Mengine::AppleFirebaseRemoteConfigPlugin )
PLUGIN_FACTORY( AppleFirebaseRemoteConfig, Mengine::AppleFirebaseRemoteConfigPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleGeneralDataProtectionRegulationService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleGeneralDataProtectionRegulation, Mengine::AppleGeneralDataProtectionRegulationPlugin )
PLUGIN_FACTORY( AppleGeneralDataProtectionRegulation, Mengine::AppleGeneralDataProtectionRegulationPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleNativePythonService );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleNativePython, Mengine::AppleNativePythonPlugin )
PLUGIN_FACTORY( AppleNativePython, Mengine::AppleNativePythonPlugin );
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleStoreInAppPurchaseService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleStoreInAppPurchase, Mengine::AppleStoreInAppPurchasePlugin )
PLUGIN_FACTORY( AppleStoreInAppPurchase, Mengine::AppleStoreInAppPurchasePlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//////////////////////////////////////////////////////////////////////////
SERVICE_EXTERN( AppleStoreReviewService );
//////////////////////////////////////////////////////////////////////////
PLUGIN_FACTORY( AppleStoreReview, Mengine::AppleStoreReviewPlugin )
PLUGIN_FACTORY( AppleStoreReview, Mengine::AppleStoreReviewPlugin );
//////////////////////////////////////////////////////////////////////////
namespace Mengine
{
Expand Down
4 changes: 3 additions & 1 deletion src/Plugins/TheoraPlugin/TheoraVideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "Config/StdString.h"

#include "stdex/memorycopy.h"

#ifndef MENGINE_THEORA_OGG_BUFFER_SIZE
#define MENGINE_THEORA_OGG_BUFFER_SIZE 4096
#endif
Expand Down Expand Up @@ -168,7 +170,7 @@ namespace Mengine
}
else
{
StdString::memcpy( &m_oggStreamState, &oggStreamStateTest, sizeof( ogg_stream_state ) );
stdex::memorycopy( &m_oggStreamState, 0, &oggStreamStateTest, sizeof( ogg_stream_state ) );

theoraHeader = true;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Services/AccountService/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "Config/StdString.h"

#include "stdex/memorycopy.h"

#ifndef MENGINE_ACCOUNT_SETTINGS_JSON_PATH
#define MENGINE_ACCOUNT_SETTINGS_JSON_PATH "settings.json"
#endif
Expand Down Expand Up @@ -237,7 +239,7 @@ namespace Mengine
, uid
);

StdString::memcpy( m_uid.data, uid, 20 );
stdex::memorycopy( m_uid.data, 0, uid, 20 );

LOGGER_INFO( "account", "load account '%s' projectVersion [%u] uid '%.20s' settings"
, m_id.c_str()
Expand Down
8 changes: 3 additions & 5 deletions src/Systems/AppleFileSystem/AppleFileGroupDirectory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "Kernel/PathString.h"
#include "Kernel/DocumentHelper.h"

#include "SDL_rwops.h"

namespace Mengine
{
//////////////////////////////////////////////////////////////////////////
Expand All @@ -35,7 +33,7 @@
{
m_factoryInputStreamFile = Helper::makeFactoryPool<AppleFileInputStream, 8>( MENGINE_DOCUMENT_FACTORABLE );
m_factoryInputStreamMutexFile = Helper::makeFactoryPool<AppleMutexFileInputStream, 8>( MENGINE_DOCUMENT_FACTORABLE );
m_factoryOutputStreamFile = Helper::makeFactoryPool<FileOutputStream, 4>( MENGINE_DOCUMENT_FACTORABLE );
m_factoryOutputStreamFile = Helper::makeFactoryPool<AppleFileOutputStream, 4>( MENGINE_DOCUMENT_FACTORABLE );

return true;
}
Expand Down Expand Up @@ -213,7 +211,7 @@
}
}

SDLFileInputStreamPtr stream = m_factoryInputStreamFile->createObject( _doc );
AppleFileInputStreamPtr stream = m_factoryInputStreamFile->createObject( _doc );

MENGINE_ASSERTION_MEMORY_PANIC( stream, "invalid create input file '%s:%s'"
, m_folderPath.c_str()
Expand Down Expand Up @@ -321,7 +319,7 @@
//////////////////////////////////////////////////////////////////////////
OutputStreamInterfacePtr AppleFileGroupDirectory::createOutputFile( const DocumentInterfacePtr & _doc )
{
SDLFileOutputStreamPtr stream = m_factoryOutputStreamFile->createObject( _doc );
AppleFileOutputStreamPtr stream = m_factoryOutputStreamFile->createObject( _doc );

MENGINE_ASSERTION_MEMORY_PANIC( stream, "invalid create output file" );

Expand Down
4 changes: 2 additions & 2 deletions src/Systems/AppleFileSystem/AppleFileInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "Kernel/ThreadGuard.h"
#include "Kernel/BaseDebugFile.h"

#include "SDL_rwops.h"
#import <Foundation/Foundation.h>

#ifndef MENGINE_FILE_STREAM_BUFFER_SIZE
#define MENGINE_FILE_STREAM_BUFFER_SIZE 4096
Expand Down Expand Up @@ -49,7 +49,7 @@ namespace Mengine
bool memory( void ** const _memory, size_t * const _size ) override;

public:
m_fileHandle * getFileHandle() const;
NSFileHandle * getFileHandle() const;

protected:
bool openFile_( const FilePath & _relationPath, const FilePath & _folderPath, const FilePath & _filePath, Char * const _fullPath );
Expand Down
Loading

0 comments on commit 64b3380

Please sign in to comment.