Subdirectory Files
#1

I'm currently trying to log everything into the logs folder but it wont let me do it. My log function is:

pawn Код:
Log(sz_fileName[], sz_input[]) {

    new
        sz_logEntry[156],
        i_dateTime[2][3],
        File: fileHandle = fopen(sz_fileName, io_append);

    gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
    getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);

    format(sz_logEntry, sizeof(sz_logEntry), "[%i/%i/%i - %i:%i:%i] %s\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], sz_input);
    fwrite(fileHandle, sz_logEntry);
    return fclose(fileHandle);
}
and I'm using

pawn Код:
Log("logs/test.log", "hi");
Any help? It's like the function doesn't work at all when I add a path.
Reply
#2

Is the folder logs already made?
Reply
#3

Nope.

EDIT: Just tried that and it works, appreciate it.


I got another question, would I be using

pawn Код:
if(fexist("users/pie.ini"))
or something else?
Reply
#4

You can use:
pawn Код:
if(fileHandle)
{
    // File was able to be opened
    // Do your code / saving
}
else
{
    // Couldn't open the file
}
But to your question, yes, you can also use that.
pawn Код:
if(fexist(sz_fileName))
{
    // Exists
}
else
{
    // Doesn't Exist
}
Reply
#5

All fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)