//
// DS_Dictionary::copyFile from 0x10015bc70 to 0x10015c0b6 (1094 bytes)
//
// 1 xrefs:
// > GManager::loadDataFromFile @ 0x1004a5681
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:25:06 +0000
//
__int64 __fastcall DS_Dictionary::copyFile(std::string::value_type *__s, std::string::value_type *a2)
{
const char *data; // r15
const char *v3; // r14
FILE *v5; // rax
FILE *v6; // rax
std::string v7; // [rsp+10h] [rbp-500h] BYREF
std::string v8; // [rsp+30h] [rbp-4E0h] BYREF
__int128 v9; // [rsp+48h] [rbp-4C8h] BYREF
void *__p; // [rsp+58h] [rbp-4B8h]
char v11; // [rsp+67h] [rbp-4A9h] BYREF
__int64 (__fastcall **v12)(); // [rsp+68h] [rbp-4A8h] BYREF
_BYTE v13[120]; // [rsp+70h] [rbp-4A0h] BYREF
FILE *v14; // [rsp+E8h] [rbp-428h]
int v15; // [rsp+1F8h] [rbp-318h]
int v16; // [rsp+1FCh] [rbp-314h]
std::ios_base v17; // [rsp+208h] [rbp-308h] BYREF
__int64 v18; // [rsp+290h] [rbp-280h]
int v19; // [rsp+298h] [rbp-278h]
_QWORD v20[2]; // [rsp+2A0h] [rbp-270h] BYREF
_BYTE __sb[120]; // [rsp+2B0h] [rbp-260h] BYREF
FILE *v22; // [rsp+328h] [rbp-1E8h]
int v23; // [rsp+438h] [rbp-D8h]
int v24; // [rsp+43Ch] [rbp-D4h]
std::ios_base v25; // [rsp+448h] [rbp-C8h] BYREF
__int64 v26; // [rsp+4D0h] [rbp-40h]
int v27; // [rsp+4D8h] [rbp-38h]
FileOperation::getFilePath(&v9);
if ( (v9 & 1) != 0 )
{
sub_10001AD30(&v7, __p, *((unsigned __int64 *)&v9 + 1));
}
else
{
v7.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(_OWORD *)&v7.__r_.__value_.__l.0 = v9;
}
std::string::append(&v7, __s);
if ( (*(_BYTE *)&v7.__r_.__value_.__s.0 & 1) != 0 )
{
data = v7.__r_.__value_.__l.__data_;
if ( (v9 & 1) != 0 )
{
LABEL_6:
sub_10001AD30(&v8, __p, *((unsigned __int64 *)&v9 + 1));
goto LABEL_9;
}
}
else
{
data = v7.__r_.__value_.__s.__data_;
if ( (v9 & 1) != 0 )
goto LABEL_6;
}
v8.__r_.__value_.__r.__words[2] = (std::string::size_type)__p;
*(_OWORD *)&v8.__r_.__value_.__l.0 = v9;
LABEL_9:
std::string::append(&v8, a2);
if ( (*(_BYTE *)&v8.__r_.__value_.__s.0 & 1) != 0 )
v3 = v8.__r_.__value_.__l.__data_;
else
v3 = v8.__r_.__value_.__s.__data_;
v25.__loc_ = nullptr;
v20[0] = &off_100AC75D0;
v25.__vftable = (std::ios_base_vtbl *)&off_100AC75F8;
v20[1] = 0;
std::ios_base::init(&v25, __sb);
v26 = 0;
v27 = -1;
v20[0] = &off_100AC7560;
v25.__vftable = (std::ios_base_vtbl *)off_100AC7588;
sub_100162D10(__sb);
if ( v22 || (v5 = fopen(data, "r"), (v22 = v5) == nullptr) )
{
std::ios_base::clear(
(std::ios_base *)((char *)v20 + *(_QWORD *)(v20[0] - 24LL)),
*(_DWORD *)&__sb[*(_QWORD *)(v20[0] - 24LL) + 16] | 4);
}
else
{
v23 = 8;
if ( v24 == 34 )
{
setbuf(v5, nullptr);
v24 = 0;
}
}
v17.__loc_ = nullptr;
v12 = (__int64 (__fastcall **)())&off_100AC7460;
v17.__vftable = (std::ios_base_vtbl *)&off_100AC7488;
std::ios_base::init(&v17, v13);
v18 = 0;
v19 = -1;
v12 = &off_100AC73F0;
v17.__vftable = (std::ios_base_vtbl *)off_100AC7418;
sub_100162D10(v13);
if ( v14 || (v6 = fopen(v3, "w"), (v14 = v6) == nullptr) )
{
std::ios_base::clear((std::ios_base *)&v13[(_QWORD)*(v12 - 3) - 8], *(_DWORD *)&v13[(_QWORD)*(v12 - 3) + 24] | 4);
}
else
{
v15 = 16;
if ( v16 == 34 )
{
setbuf(v6, nullptr);
v16 = 0;
}
}
sub_100162E50(&v11, *(_QWORD *)&__sb[*(_QWORD *)(v20[0] - 24LL) + 24], 0, *(_QWORD *)&v13[(_QWORD)*(v12 - 3) + 32]);
v12 = &off_100AC73F0;
v17.__vftable = (std::ios_base_vtbl *)off_100AC7418;
sub_100161420(v13);
std::ostream::~ostream(&v12, off_100AC7430);
std::ios::~ios(&v17);
v20[0] = &off_100AC7560;
v25.__vftable = (std::ios_base_vtbl *)off_100AC7588;
sub_100161420(__sb);
std::istream::~istream(v20, off_100AC75A0);
std::ios::~ios(&v25);
if ( (*(_BYTE *)&v8.__r_.__value_.__s.0 & 1) == 0 )
{
if ( (*(_BYTE *)&v7.__r_.__value_.__s.0 & 1) == 0 )
goto LABEL_18;
LABEL_21:
operator delete(v7.__r_.__value_.__l.__data_);
if ( (v9 & 1) == 0 )
return __stack_chk_guard;
goto LABEL_22;
}
operator delete(v8.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v7.__r_.__value_.__s.0 & 1) != 0 )
goto LABEL_21;
LABEL_18:
if ( (v9 & 1) == 0 )
return __stack_chk_guard;
LABEL_22:
operator delete(__p);
return __stack_chk_guard;
}