ios - Open file in .bundle using fopen() -
I have created a custom framework and the resource bundle for use in other projects, in various resource bundles .sqlite And .bin files are included. I am trying to successfully open a file in any project in any other project.
Let's say my bundle is called CustomFramework.bundle . Trying to open mybin.bin in customframwork.bundle , I have a class ResourceHelper.cpp within my framework.
At this time I am trying to open it:
ZERO RESOURCES Helper :: OpenBillFormersSolder (file ** file) {std :: string path; Path = "custom framework. Bundle /"; Path.append ("mybin.bin"); * File = fopen (path.c_str (), "rb"); } How do I feel that
file
is null .
Thanks
zero resource Helper :: openBinFromResourceFolder (const char * binName, FILE ** file) {std :: string path; // Name and file type in the split bin name (bin) std :: string binStr = binName; Std :: size_t pos = binStr.find ("."); Std :: string filename = binStr.substr (0, position); Std :: string type = binStr.substr (pos + 1); // Millions Bundle and CFTTRings CFBundleRef Main Bundle = CFBundleGetMainBundle (); CFStringRef cf_resource_path = CFStringCreateWithCString (NULL, sourcePath_.c_str (), KCF string encoding UTF8); CFStringRef cf_filename = CFStringCreateWithCString (NULL, filename.c_str (), KCF string encoding UTF 8); CFStringRef cf_file_type = CFStringCreateWithCString (NULL, type.c_str (), KCF string encoding UTF8); Seafloorf url_resource = CFBundleCopyResourceURL (main bundle, cf_filename, cf_file_type, cf_resource_path); CFStringRef urlString = CFRKPFile system path (url_resource, kCFURLPOSIXPathStyle); Path = CFStringGetCStringPtr (urlString, kCFStringEncodingUTF8); * File = fopen (path.c_str (), "rb"); }
Comments
Post a Comment