fopen returns NULL
#1

I've got a problem:

The program doesn't want to create a new file. the part of the colde looks like:
pawn Код:
if(!fexist(SettingFile))
{
    dini_Create(SettingFile);
    dini_IntSet(SettingFile, "PocketMoney", 1000);
    dini_IntSet(SettingFile, "AnnounceSeconds", 3);
    dini_IntSet(SettingFile, "PassMin", 3);
    dini_IntSet(SettingFile, "PassMax", 15);
}
I am sure that file doesn't exist.
I have tried to figure out the problem and I realised the problem comes here(in dini_Create):
pawn Код:
stock dini_Create(filename[]) {
    if (fexist(filename))
    {
        return false;
    }
    new File:fhnd;
    fhnd=fopen(filename,io_write);
    if (fhnd) // IT DOESN'T ENTER THIS if clause <-----
    {
        fclose(fhnd);
        return true;
    }
    return false;
}
So fopen returns NULL.
I don't know how to fix that.
Btw. I have reinstalled my computer and now it doesn't work(but before it worked perfectly)
I have aloso some dini_Create which work perfectly.
I would be very greatful if you can help me.

PS: Sorry for that codes, I dunno how to put "pawn code console"
Reply
#2

Код:
[ pawn ]code between this, do NOT use the spaces between it ofcourse[ / pawn ]
Did you format the SettingFile? If so: show us the format
Reply
#3

#define SettingFile "AdminScript/Settings/MainSettings.ini"
It doesn't need format(), I thinik.
Aswell, I've seen if the problem appears in dev c++ you can easily find the reason with perror();
Reply
#4

Yeah sorry, forgot it didnt need a name in it
Did you made the folders "AdminScript/Settings" in your scriptfils?
Reply
#5

Yea, otherwise server would chrash, I think. It didn't crash. Now I checked if I spelled it right.
Reply
#6

Yes you were right, my Folder was called MainSettings, not Settings. Thank you very much!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)