Subdirectory Files - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Subdirectory Files (
/showthread.php?tid=283653)
Subdirectory Files -
andrew4699 - 16.09.2011
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.
Re: Subdirectory Files -
dowster - 16.09.2011
Is the folder logs already made?
Re: Subdirectory Files -
andrew4699 - 16.09.2011
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?
Re: Subdirectory Files - [L3th4l] - 16.09.2011
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
}
Re: Subdirectory Files -
andrew4699 - 16.09.2011
All fixed.