• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

iOS Bug with file functions in iOS? Creating a file does not seem to work, "no such file" error.

G

Guest

Guest
I check for the existence of a file and, if it does not exist, create it, like so:

Code:
global.privacy_consent = false;
if (!file_exists("privacy_consent.bhsl"))
    {
    show_debug_message("* Privacy_consent.bhsl did not exist, creating it.");
    var privacy_consent_map = ds_map_create();
    privacy_consent_map[? "consent"] = false;
    var privacy_consent_map_string = ds_map_write(privacy_consent_map);
    var f = file_text_open_write("privacy_consent.bhsl");
    file_text_write_string(f, privacy_consent_map_string);
    file_text_close(f);
    ds_map_destroy(privacy_consent_map);
    }
if (file_exists("privacy_consent.bhsl"))
    {
    show_debug_message("* Reading privacy_consent.bhsl.");
    var f = file_text_open_read("privacy_consent.bhsl");
    show_debug_message("* Should have successfully opened privacy_consent.bhsl.");

    var privacy_consent_map_string = file_text_read_string(f);
    var privacy_consent_map = ds_map_create();
    ds_map_read(privacy_consent_map, privacy_consent_map_string);
    global.privacy_consent = privacy_consent_map[? "consent"];
    file_text_close(f);
    ds_map_destroy(privacy_consent_map);
    }
But running on an iPad using the VM and debugger, I get these errors and this output:

Code:
2019-07-24 10:37:44.615800-0700 BHSL[251:4819] * Privacy_consent.bhsl did not exist, creating it.
2019-07-24 10:37:44.619488-0700 BHSL[251:4819] * Reading privacy_consent.bhsl.
2019-07-24 10:37:44.619724-0700 BHSL[251:4819] Unable to open file  (No such file or directory)
2019-07-24 10:37:44.621225-0700 BHSL[251:4819] * Should have successfully opened privacy_consent.bhsl.
When I reboot the iPad (to close the game) and try to open the game, it hangs on a black screen rather than running correctly.

(I'm getting this problem with all my file functions, this was just the simplest example I had to copy and paste.)
 
Last edited by a moderator:
Top