fremove problem
#1

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?
Reply
#2

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(stringsizeof(string), patternGroupInfo[groupid][gName]); 
Obviously defining OS_WINDOWS as necessary. Comment the line when compiling for a Linux host.
Reply
#3

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(stringsizeof(string), patternGroupInfo[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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)