Merged changes from 1.1 branch.

This commit is contained in:
Scott Ehlert
2008-12-05 15:57:49 -06:00
9 changed files with 177 additions and 39 deletions
+5 -5
View File
@@ -176,11 +176,11 @@ native ReadFile(Handle:hndl, items[], num_items, size);
* @param hndl Handle to the file.
* @param buffer Buffer to store the string.
* @param max_size Maximum size of the string buffer.
* @param stop If true, reading will stop once max_size-1 bytes have
* been read. If false, reading will stop once a NUL
* terminator is reached. The buffer will simply be
* terminated in either case, the difference is in how
* the far the file position is changed.
* @param read_count If -1, reads until a null terminator is encountered in
* the file. Otherwise, read_count bytes are read
* into the buffer provided. In this case the buffer
* is not explicitly null terminated, and the buffer
* will contain any null terminators read from the file.
* @return Number of characters written to the buffer, or -1
* if an error was encountered.
* @error Invalid Handle, or read_count > max_size.
+1 -1
View File
@@ -58,7 +58,7 @@ stock FindTeamByName(const String:name[])
{
GetTeamName(i, team_name, sizeof(team_name));
if (strncmp(team_name, name, name_len) == 0)
if (strncmp(team_name, name, name_len, false) == 0)
{
if (found_team >= 0)
{
+62
View File
@@ -0,0 +1,62 @@
#include <sourcemod>
public Plugin:myinfo =
{
name = "File test",
author = "AlliedModders LLC",
description = "Tests file functions",
version = "1.0.0.0",
url = "http://www.sourcemod.net/"
};
public OnPluginStart()
{
RegServerCmd("test_fread1", Test_ReadBinStr);
}
Handle:OpenFile2(const String:path[], const String:mode[])
{
new Handle:file = OpenFile(path, mode);
if (file == INVALID_HANDLE)
PrintToServer("Failed to open file %s for %s", path, mode);
else
PrintToServer("Opened file handle %x: %s", file, path);
return file;
}
public Action:Test_ReadBinStr(args)
{
new items[] = {1, 3, 5, 7, 0, 92, 193, 26, 0, 84, 248, 2};
new Handle:of = OpenFile2("smbintest", "wb");
if (of == INVALID_HANDLE)
return Plugin_Handled;
WriteFile(of, items, sizeof(items), 1);
CloseHandle(of);
new Handle:inf = OpenFile2("smbintest", "rb");
new String:buffer[sizeof(items)];
ReadFileString(inf, buffer, sizeof(items), sizeof(items));
FileSeek(inf, 0, SEEK_SET);
new items2[sizeof(items)];
ReadFile(inf, items2, sizeof(items), 1);
CloseHandle(inf);
for (new i = 0; i < sizeof(items); i++)
{
if (buffer[i] != items[i])
{
PrintToServer("FAILED ON INDEX %d: %d != %d", i, buffer[i], items[i]);
return Plugin_Handled;
}
else if (items2[i] != items[i])
{
PrintToServer("FAILED ON INDEX %d: %d != %d", i, items2[i], items[i]);
return Plugin_Handled;
}
}
PrintToServer("Test passed!");
return Plugin_Handled;
}