read_dir for msvc compiler

This commit is contained in:
Pavol Marko 2004-02-13 18:16:37 +00:00
parent 6645e5d4aa
commit 76915facd3
2 changed files with 42 additions and 19 deletions

View File

@ -70,8 +70,31 @@ static cell AMX_NATIVE_CALL read_dir(AMX *amx, cell *params)
closedir (dp); closedir (dp);
return a; return a;
#else #else
int tmp;
char *dirname = build_pathname("%s/*", get_amxstring(amx, params[1], 0, tmp));
tmp = params[2];
_finddata_t fd;
intptr_t handle = _findfirst(dirname, &fd);
if (handle < 0)
return 0; return 0;
#endif
++tmp;
for (int i = 0; i < tmp; ++i)
{
if (_findnext(handle, &fd) < 0)
{
tmp = 0;
break;
}
}
// current data in fd
cell *length = get_amxaddr(amx,params[5]); // pointer to the outLen parameter
*length = set_amxstring(amx, params[3], fd.name, params[4]); // set output and outLen parameters
_findclose(handle);
return tmp;
#endif // __GNUC__
} }
static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */ static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) /* 5 param */