fremove problem - 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: fremove problem (
/showthread.php?tid=625514)
fremove problem -
TonyII - 02.01.2017
Hey, I've got a small problem with fremove. The problem is that it doesn't remove a file if the destinations string is 17. 17 is the max, anything under 17 it gets removed without a problem.
new string[128];
format(string, sizeof(string), "/groups/names/%s.ini", GroupInfo[groupid][gName]);
fremove(string);
So let's say the string stored in GroupInfo[groupid][gName] is: abcdefghijklmnop (16 characters)
It will remove this without a problem
But if the string is abcdefghijklmnopq (17 characters) it won't get removed.
Any idea why it does that?
Re: fremove problem -
Vince - 02.01.2017
Probably related to the directory seperator. Windows uses the backslash so it treats a forward slash as part of the filename. The same problem occurs if trying to include files with forward slashes; a path greater than 36-ish characters in length produces glitchy behavior. consider doing something like:
PHP код:
#define OS_WINDOWS
#if defined OS_WINDOWS
static const pattern[] = \"\groups\names\%s.ini";
#else
static const pattern[] = \"/groups/names/%s.ini";
#endif
format(string, sizeof(string), pattern, GroupInfo[groupid][gName]);
Obviously defining OS_WINDOWS as necessary. Comment the line when compiling for a Linux host.
Re: fremove problem -
TonyII - 03.01.2017
Quote:
Originally Posted by Vince
Probably related to the directory seperator. Windows uses the backslash so it treats a forward slash as part of the filename. The same problem occurs if trying to include files with forward slashes; a path greater than 36-ish characters in length produces glitchy behavior. consider doing something like:
PHP код:
#define OS_WINDOWS
#if defined OS_WINDOWS
static const pattern[] = \"\groups\names\%s.ini";
#else
static const pattern[] = \"/groups/names/%s.ini";
#endif
format(string, sizeof(string), pattern, GroupInfo[groupid][gName]);
Obviously defining OS_WINDOWS as necessary. Comment the line when compiling for a Linux host.
|
Thanks for the help, but my problem was at a strcat :/ I tried the code above, storing it worked fine but it wouldn't get rid of a 17 character string still.
My problem got solved when I had changed this:
strcat((GroupInfo[i][gName] = 0, GroupInfo[i][gName]), params, 17);
To this:
strcat((GroupInfo[i][gName] = 0, GroupInfo[i][gName]), params, 18 );
This code was under a command named /creategroup and the first strcat code with the 17 at the end stored all characters fine when I checked, so I didn't really understand why it would cause a problem but nonetheless it got fixed.