//
// MusicDownloadManager::pathForSongFolder from 0x82f714 to 0x82f95c (584 bytes)
//
// 4 xrefs:
// > MusicDownloadManager::pathForSong @ 0x82f990
// > MusicDownloadManager::parseMusicLibrary @ 0x8381fc
// > MusicDownloadManager::onDownloadMusicLibraryCompleted @ 0x83a13c
// > ??> @ 0x9b988
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __usercall MusicDownloadManager::pathForSongFolder@(
MusicDownloadManager *this@,
int a2@,
__int64 a3@)
{
GameManager *v7; // x0
cocos2d::CCFileUtils *v8; // x0
void *v9; // x0
cocos2d::CCFileUtils *v10; // x0
void *v11; // x0
unsigned int *v12; // x2
int v13; // w1
unsigned int *v14; // x1
int v15; // w2
__int64 v16; // [xsp+48h] [xbp+48h] BYREF
__int64 v17; // [xsp+50h] [xbp+50h] BYREF
sub_D153B8(a3, &byte_F288A0);
if ( MusicDownloadManager::isResourceSong(this, a2) )
{
sub_D15FD4(a3, "songs/", 6);
}
else
{
v7 = GameManager::sharedState();
if ( GameManager::getGameVariable(v7, "0033") )
{
v8 = cocos2d::CCFileUtils::sharedFileUtils();
((void (__fastcall *)(__int64 *__return_ptr))v8->isAbsolutePath)(&v16);
sub_D163D4(a3, &v16);
v9 = (void *)(v16 - 24);
if ( (__int64 *)(v16 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v14 = (unsigned int *)(v16 - 8);
do
v15 = __ldaxr(v14);
while ( __stlxr(v15 - 1, v14) );
}
else
{
v15 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v15 - 1;
}
if ( v15 <= 0 )
operator delete(v9);
}
sub_D15FD4(a3, "Resources\\", 10);
}
else
{
v10 = cocos2d::CCFileUtils::sharedFileUtils();
v10->init((cocos2d::CCFileUtils *)&v17);
sub_D163D4(a3, &v17);
v11 = (void *)(v17 - 24);
if ( (__int64 *)(v17 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v12 = (unsigned int *)(v17 - 8);
do
v13 = __ldaxr(v12);
while ( __stlxr(v13 - 1, v12) );
}
else
{
v13 = *(_DWORD *)(v17 - 8);
*(_DWORD *)(v17 - 8) = v13 - 1;
}
if ( v13 <= 0 )
operator delete(v11);
}
}
}
return a3;
}