//
// DS_Dictionary::saveRootSubDictToCompressedFile from 0x10017bfa0 to 0x10017c653 (1715 bytes)
//
// 0 xrefs:
//
// 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
//
bool __fastcall DS_Dictionary::saveRootSubDictToCompressedFile(DS_Dictionary *a1, const char *a2)
{
double v2; // xmm0_8
const std::string::value_type *data; // rsi
const char *v5; // rbx
char *v6; // rsi
char *v7; // rsi
const std::__fs::filesystem::path *v8; // r12
const std::__fs::filesystem::path *v9; // rdi
std::error_code *v10; // rdx
const char *v11; // r15
const std::__fs::filesystem::path *v12; // rdi
std::error_code *v13; // rdx
const std::__fs::filesystem::path *v14; // rdi
std::error_code *v15; // rsi
int v16; // eax
std::error_code *v17; // rdx
const std::__fs::filesystem::path *v18; // rsi
const char *v19; // rdi
FILE *v20; // rax
FILE *v21; // r14
std::string::pointer v22; // rdi
size_t size; // rdx
size_t v24; // r12
bool v25; // r14
FILE *v27; // rax
FILE *v28; // rax
std::string v29; // [rsp+10h] [rbp-540h] BYREF
std::string v30; // [rsp+28h] [rbp-528h] BYREF
__int16 v31; // [rsp+40h] [rbp-510h] BYREF
__int64 v32; // [rsp+48h] [rbp-508h]
void *v33; // [rsp+50h] [rbp-500h]
std::string v34; // [rsp+58h] [rbp-4F8h] BYREF
std::string v35; // [rsp+70h] [rbp-4E0h] BYREF
_WORD v36[8]; // [rsp+88h] [rbp-4C8h] BYREF
char *v37; // [rsp+98h] [rbp-4B8h]
char v38; // [rsp+A7h] [rbp-4A9h] BYREF
__int64 (__fastcall **v39)(); // [rsp+A8h] [rbp-4A8h] BYREF
_BYTE v40[120]; // [rsp+B0h] [rbp-4A0h] BYREF
FILE *v41; // [rsp+128h] [rbp-428h]
int v42; // [rsp+238h] [rbp-318h]
int v43; // [rsp+23Ch] [rbp-314h]
std::ios_base v44; // [rsp+248h] [rbp-308h] BYREF
__int64 v45; // [rsp+2D0h] [rbp-280h]
int v46; // [rsp+2D8h] [rbp-278h]
_QWORD v47[2]; // [rsp+2E0h] [rbp-270h] BYREF
_BYTE __sb[120]; // [rsp+2F0h] [rbp-260h] BYREF
FILE *v49; // [rsp+368h] [rbp-1E8h]
int v50; // [rsp+478h] [rbp-D8h]
int v51; // [rsp+47Ch] [rbp-D4h]
std::ios_base v52; // [rsp+488h] [rbp-C8h] BYREF
__int64 v53; // [rsp+510h] [rbp-40h]
int v54; // [rsp+518h] [rbp-38h]
v36[0] = 0;
FileOperation::getFilePath(&v29);
std::string::append(&v29, a2);
if ( (*(_BYTE *)&v29.__r_.__value_.__s.0 & 1) != 0 )
data = v29.__r_.__value_.__l.__data_;
else
data = v29.__r_.__value_.__s.__data_;
std::string::assign((std::string *)v36, data);
v5 = (char *)v36 + 1;
v6 = (char *)v36 + 1;
if ( (v36[0] & 1) != 0 )
v6 = v37;
sub_10017BB50(&v35, v6, "2.dat", v2);
v7 = (char *)v36 + 1;
if ( (v36[0] & 1) != 0 )
v7 = v37;
sub_10017BB50(&v34, v7, "3.dat", v2);
v8 = (const std::__fs::filesystem::path *)((char *)&v34.__r_.__value_.__l.0 + 1);
v9 = (const std::__fs::filesystem::path *)((char *)&v34.__r_.__value_.__l.0 + 1);
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) != 0 )
v9 = (const std::__fs::filesystem::path *)v34.__r_.__value_.__l.__data_;
remove(v9, (std::error_code *)v7);
v11 = v35.__r_.__value_.__s.__data_;
v12 = (const std::__fs::filesystem::path *)((char *)&v35.__r_.__value_.__l.0 + 1);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
{
v12 = (const std::__fs::filesystem::path *)v35.__r_.__value_.__l.__data_;
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_12:
rename(v12, (const std::__fs::filesystem::path *)((char *)&v34.__r_.__value_.__l.0 + 1), v10);
v14 = (const std::__fs::filesystem::path *)((char *)v36 + 1);
if ( (v36[0] & 1) == 0 )
goto LABEL_13;
goto LABEL_21;
}
}
else if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) == 0 )
{
goto LABEL_12;
}
rename(v12, (const std::__fs::filesystem::path *)v34.__r_.__value_.__l.__data_, v10);
v14 = (const std::__fs::filesystem::path *)((char *)v36 + 1);
if ( (v36[0] & 1) == 0 )
{
LABEL_13:
v15 = (std::error_code *)((char *)&v35.__r_.__value_.__l.0 + 1);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_14;
goto LABEL_22;
}
LABEL_21:
v14 = (const std::__fs::filesystem::path *)v37;
v15 = (std::error_code *)((char *)&v35.__r_.__value_.__l.0 + 1);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_14:
rename(v14, (const std::__fs::filesystem::path *)((char *)&v35.__r_.__value_.__l.0 + 1), v13);
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_15;
LABEL_23:
v8 = (const std::__fs::filesystem::path *)v34.__r_.__value_.__l.__data_;
if ( v16 )
goto LABEL_16;
LABEL_24:
remove(v8, v15);
goto LABEL_25;
}
LABEL_22:
v15 = (std::error_code *)v35.__r_.__value_.__l.__data_;
rename(v14, (const std::__fs::filesystem::path *)v35.__r_.__value_.__l.__data_, v13);
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_23;
LABEL_15:
if ( !v16 )
goto LABEL_24;
LABEL_16:
v18 = (const std::__fs::filesystem::path *)((char *)&v35.__r_.__value_.__l.0 + 1);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
v18 = (const std::__fs::filesystem::path *)v35.__r_.__value_.__l.__data_;
rename(v8, v18, v17);
LABEL_25:
v39 = (__int64 (__fastcall **)())sub_10063B550(a1, "plist");
v47[0] = sub_10063BA80(&v39, "gjver");
sub_10063AAD0(v47, "2.0");
sub_100642FA0(&v31, a1, "\t", 4, 0);
cocos2d::ZipUtils::compressString(&v30);
if ( (v31 & 1) == 0 )
{
v31 = 0;
v19 = (char *)v36 + 1;
if ( (v36[0] & 1) == 0 )
goto LABEL_30;
goto LABEL_29;
}
*(_BYTE *)v33 = 0;
v32 = 0;
v19 = (char *)v36 + 1;
if ( (v36[0] & 1) != 0 )
LABEL_29:
v19 = v37;
LABEL_30:
v20 = fopen(v19, "wb");
v21 = v20;
if ( !v20
|| ((*(_BYTE *)&v30.__r_.__value_.__s.0 & 1) == 0
? (size = *(_BYTE *)&v30.__r_.__value_.__l.0 >> 1, v22 = v30.__r_.__value_.__s.__data_)
: (std::string::pointer)(v22 = v30.__r_.__value_.__l.__data_, size = v30.__r_.__value_.__l.__size_),
v24 = fwrite(v22, 1u, size, v20),
fclose(v21),
v25 = 1,
!v24) )
{
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) != 0 )
v11 = v35.__r_.__value_.__l.__data_;
v52.__loc_ = nullptr;
v47[0] = &off_1008C3D00;
v52.__vftable = (std::ios_base_vtbl *)&off_1008C3D28;
v47[1] = 0;
std::ios_base::init(&v52, __sb);
v53 = 0;
v54 = -1;
v47[0] = &off_1008C3C90;
v52.__vftable = (std::ios_base_vtbl *)off_1008C3CB8;
sub_100183920(__sb);
if ( v49 || (v27 = fopen(v11, "r"), (v49 = v27) == nullptr) )
{
std::ios_base::clear(
(std::ios_base *)((char *)v47 + *(_QWORD *)(v47[0] - 24LL)),
*(_DWORD *)&__sb[*(_QWORD *)(v47[0] - 24LL) + 16] | 4);
}
else
{
v50 = 8;
if ( v51 == 34 )
{
setbuf(v27, nullptr);
v51 = 0;
}
}
if ( (v36[0] & 1) != 0 )
v5 = v37;
v44.__loc_ = nullptr;
v39 = (__int64 (__fastcall **)())&off_1008C3B90;
v44.__vftable = (std::ios_base_vtbl *)&off_1008C3BB8;
std::ios_base::init(&v44, v40);
v45 = 0;
v46 = -1;
v39 = &off_1008C3B20;
v44.__vftable = (std::ios_base_vtbl *)off_1008C3B48;
sub_100183920(v40);
if ( v41 || (v28 = fopen(v5, "w"), (v41 = v28) == nullptr) )
{
std::ios_base::clear((std::ios_base *)&v40[(_QWORD)*(v39 - 3) - 8], *(_DWORD *)&v40[(_QWORD)*(v39 - 3) + 24] | 4);
}
else
{
v42 = 16;
if ( v43 == 34 )
{
setbuf(v28, nullptr);
v43 = 0;
}
}
sub_100183A60(&v38, *(_QWORD *)&__sb[*(_QWORD *)(v47[0] - 24LL) + 24], 0, *(_QWORD *)&v40[(_QWORD)*(v39 - 3) + 32]);
v39 = &off_1008C3B20;
v44.__vftable = (std::ios_base_vtbl *)off_1008C3B48;
sub_100182030(v40);
std::ostream::~ostream(&v39, off_1008C3B60);
std::ios::~ios(&v44);
v47[0] = &off_1008C3C90;
v52.__vftable = (std::ios_base_vtbl *)off_1008C3CB8;
sub_100182030(__sb);
std::istream::~istream(v47, off_1008C3CD0);
std::ios::~ios(&v52);
v25 = 0;
}
if ( (*(_BYTE *)&v30.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v30.__r_.__value_.__l.__data_);
if ( (v31 & 1) == 0 )
{
LABEL_46:
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_47;
goto LABEL_53;
}
}
else if ( (v31 & 1) == 0 )
{
goto LABEL_46;
}
operator delete(v33);
if ( (*(_BYTE *)&v34.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_47:
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_48;
goto LABEL_54;
}
LABEL_53:
operator delete(v34.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v35.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_48:
if ( (*(_BYTE *)&v29.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_49;
LABEL_55:
operator delete(v29.__r_.__value_.__l.__data_);
if ( (v36[0] & 1) == 0 )
return v25;
LABEL_56:
operator delete(v37);
return v25;
}
LABEL_54:
operator delete(v35.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v29.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_55;
LABEL_49:
if ( (v36[0] & 1) != 0 )
goto LABEL_56;
return v25;
}