11#include <android/asset_manager.h> 
   12#include <android/asset_manager_jni.h> 
   13#include <android/log.h> 
   14#include <Manager/EngineCore.h> 
   15#include <Manager/ResMgr.h> 
   17#define  LOG_TAG    "SCENGINE" 
   20#include <CoreFoundation/CFURL.h> 
   21#include <CoreFoundation/CFURLAccess.h> 
   22#include <CoreFoundation/CFBundle.h> 
   23#include <CoreFoundation/CFPropertyList.h> 
   27    static std::string NativeAssetsPath() {
 
   29#if defined(__CSE_EDITOR__) 
   30    #if defined(MSVC_CMAKE) 
   31        path.append(
"../../../../../Assets/");
 
   32    #elif defined(__EMSCRIPTEN__) 
   35        path.append(
"../../../../Assets/");
 
   37#elif defined(MSVC_CMAKE) 
   38        path.append(
"../../../../Assets/");
 
   41#elif defined(_WIN32) || defined(__linux__) || defined(__APPLE_CC__) 
   42        path.append(
"../../../Assets/");
 
   50    static std::string AssetsPath() {
 
   53        if (Settings::IsAssetsPacked() == 
false)
 
   54            path = NativeAssetsPath();
 
   59    static std::string OpenNativeAssetsTxtFile(
const std::string& path) {
 
   64                AAssetManager* assetManager = CORE->GetCore(ResMgr)->GetAssetManager();
 
   65                AAsset* asset = AAssetManager_open(assetManager, path.c_str(), AASSET_MODE_STREAMING);
 
   70                off_t fileSize = AAsset_getRemainingLength(asset);
 
   75                char* strbuf = 
new char[fileSize + 1]();
 
   76                AAsset_read(asset, strbuf, fileSize);
 
   78                buf = std::string(strbuf, fileSize);
 
   80#elif defined (_WIN32) || defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__APPLE_CC__) 
   82        auto path_split = split(path, 
'.');
 
   83        CFStringRef cf_name = CFStringCreateWithCString(kCFAllocatorDefault, path_split[0].c_str(), kCFStringEncodingUTF8);
 
   84        CFStringRef cf_ext = CFStringCreateWithCString(kCFAllocatorDefault, path_split[1].c_str(), kCFStringEncodingUTF8);
 
   86        CFURLRef manifest_url = CFBundleCopyResourceURL(CFBundleGetMainBundle(), cf_name, cf_ext, NULL);
 
   87        char manifest_path[1024];
 
   88        CFURLGetFileSystemRepresentation(manifest_url, TRUE, (UInt8*)manifest_path, 
sizeof(manifest_path));
 
   89        CFRelease(manifest_url);
 
   93        std::ifstream fin(manifest_path, std::ios::binary);
 
   95        std::ifstream fin(path, std::ios::binary);
 
   97        if (!fin.is_open()) 
return "";
 
   99        fin.seekg(0, std::ios::end);
 
  100        size_t size = fin.tellg();
 
  102        buf = std::string(size, 
' ');
 
  103        fin.read(&buf[0], size);
 
  109    static bool SaveTxtFile(
const std::string& path, std::string data) {
 
  110#if defined(__ANDROID__) || defined(IOS) || defined(__EMSCRIPTEN__) 
  113        std::ofstream fout(path, std::ios::binary | std::ios::trunc);