Monday 15 June 2015

c - fgetpos failing in iOS 6.1 simulator when opening files in bundles -


I'm working on some multipatal C ++ code. Therefore, the need to use FOPN, FASTOPA etc. The following was working first on iOS and stopped working with their updates in the latest version.

I have some text files in Shader.vsh and Shader to open the file in which FSH is copying to the bundle, I do the following.

 < Code> CFBundLerf main bundle = CFBundlegetManibandle (); CFStringRef cfstrFilename = CFRFFrame Concept Striper ("Shadar"); CFStringRef cfstrFileType = CFSTRFromConstCharPtr ("vsh"); CFStringRef cfstrSubDir = CFSTRFromConstCharPtr ("Shader"); CFLRF resources URL = CFBundleCopyResourceURL (main bundle, sefstuff filemenam, CFFFileType, CFSTBSBDR); CFStringRef str = CFURLCopyFileSystemPath (resourcesURL, kCFURLPOSIXPathStyle); CFRs (for resources); Four paths [PATH_MAX]; CFStringGetCString (str, path, FILENAME_MAX, kCFStringEncodingASCII); CFRs (ARR); FILE * fp = fopen (path, "rb");   

At this point, fp is non-faucet, so I think it was successful. Later, when I try to do

  fpos_t pos; Int results = fgetpos (fp, and fpos_t);   

Result = -1 and error = 0x2, which I believe is not found in the file.

As I said earlier, it used to do some work on an earlier version. I started working on it again and stopped working in the updated XCode, etc. in the process.

The path I pass to the file / user / shammy / library / application support / iPhone simulator / 6.1 / application / 9132490 F-71 AC-4C61-A584-E8F 6C5b 261FF / TestApple.APP / Shaders / Shader.Vish I am able to view and open that file in Finder / Console and confirm that it is valid.

What am I doing wrong? Is there any other option that allows me to use portable IO functions?

Problem found I failed to mention here which is between 2 sections of the above code . Before that, I had my own riff counting solution and recently changed to use share_ptr allowed my own referee counting solution to be inserted in. With Share_ptr, you can not do this, here's the exact code ...

std :: shared_ptr & lt; Binary Stream & gt; BundleNameSpace :: OpenStream (Const four * _szPath,

 BinaryStream :: Mode _eMode) {std :: shared_ptr & lt; Binary Stream & gt; PStream = __super :: OpenStream (_szpath, _eMode); If (! PStream) {std :: string strDir; Std :: string strfile; Std :: string strExt; Split path (_szpath, strdir, strfile, strExt); Std :: string strFullPath = GetResourcePathFor (strFile.c_str), strExt.c_str (), strDir.c_str ()); FILE * fp = fopen (strFullPath.c_str), _eMode == BinaryStream :: Mode_Read? "R": "w + b"); PStream = std :: make_shared & lt; Filestream & gt; (FP, _eMode); } Return PTTrem; }   

The problem here

  pStream = std :: make_shared & lt; Filestream> (fp, _eMode);   

calls to my filestream district fclose (m_pFile) to fix it, to change it.

  pStream = std :: Static_pointer_cast & lt; Barystream & gt; (Std :: make_shared & lt; filestream & gt; (fp, _emode));   

In addition to this, the use of mess () is more useful than trying to use confusion.

No comments:

Post a Comment