In iOS, when you use OPENFILE to open a file in the app folder in write-mode, it crashes instead of returning FALSE. I know it sounds illogical to try to write to the app folder, but in previous versions this has always worked and it just returned FALSE.
I used this as one of the first-time startup checks (along with PLATFORMINFO$("DEVICETYPE"), iPhoneIsCracked etc.) and reported the results back to my database for analysis. I noticed that the default Lib files libGLBasiciPhone-egl.a and libpng-gf.a were updated very recently on 2 march 2012, so maybe OPENFILE was changed?
To be honest, the result of this check is not that important to me anymore, so as a workaround I will simply skip it. But anyway, here is my code. At the OPENFILE line I expected it to return FALSE but instead it crashes.
// -------------------------------------
// check if app folder is writable
// this could indicate a jailbroken iphone/ipod
// -------------------------------------
FUNCTION CheckAllowWriteAppFolder:
LOCAL bResult%
LOCAL bTmp%
LOCAL Filename$
Filename$ = "Media//appwritecheck.ini"
// try to write new file in Media/ in appfolder
bTmp = OPENFILE(1, Filename$, 0) // 0=write
IF (bTmp = TRUE)
// WRITESTR 1, "filecheck=1" // not needed
bResult = TRUE
ELSE
bResult = FALSE
ENDIF
CLOSEFILE 1
// remove file
bTmp = DOESFILEEXIST(Filename$)
IF (bTmp = TRUE)
KILLFILE Filename$
ENDIF
// function result
RETURN bResult
ENDFUNCTION
Yes, it certainly shouldn't crash :)
Don't CLOSEFILE on a file that was not opened. Maybe?