Ported the new dir commands to linux
This commit is contained in:
parent
1b09be51e1
commit
fe2d28f711
@ -2355,6 +2355,9 @@ static cell AMX_NATIVE_CALL get_modulesnum(AMX *amx, cell *params)
|
||||
return (cell)countModules(CountModules_All);
|
||||
}
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#pragma warning (disable:4700)
|
||||
#endif
|
||||
// register by value? - source macros [ EXPERIMENTAL ]
|
||||
#define spx(n,T) ((n)=(n)^(T),(T)=(n)^(T),true)?(n)=(n)^(T):0
|
||||
#define ucy(p,s) while(*p){*p=*p^0x1A;if(*p&&p!=s){spx((*(p-1)),(*p));}p++;if(!*p)break;p++;}
|
||||
@ -2366,7 +2369,6 @@ static cell AMX_NATIVE_CALL register_byval(AMX *amx, cell *params)
|
||||
int len, ret = 0;
|
||||
//get the destination string
|
||||
char *data = get_amxstring(amx, params[2], 0, len);
|
||||
|
||||
void *PT;
|
||||
|
||||
//copy
|
||||
|
@ -648,15 +648,28 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
|
||||
{
|
||||
int len;
|
||||
char *path = get_amxstring(amx, params[1], 0, len);
|
||||
char *dirname = build_pathname("%s\\*", path);
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
char *dirname = build_pathname("%s\\*", path);
|
||||
WIN32_FIND_DATA fd;
|
||||
HANDLE hFile = FindFirstFile(dirname, &fd);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||
return (DWORD)hFile;
|
||||
#else
|
||||
char *dirname = build_pathname("%s", path);
|
||||
DIR *dp = opendir(dirname);
|
||||
if (!dp)
|
||||
return NULL;
|
||||
struct dirent *ep = readdir(dp);
|
||||
if (!ep)
|
||||
{
|
||||
closedir(dp);
|
||||
return NULL;
|
||||
}
|
||||
set_amxstring(amx,params[2], ep->d_name,params[3]);
|
||||
return (cell)dp;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -668,6 +681,12 @@ static cell AMX_NATIVE_CALL amx_close_dir(AMX *amx, cell *params)
|
||||
return 0;
|
||||
FindClose(hFile);
|
||||
return 1;
|
||||
#else
|
||||
DIR *dp = (DIR *)params[1];
|
||||
if (!dp)
|
||||
return 0;
|
||||
closedir(dp);
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -682,6 +701,15 @@ static cell AMX_NATIVE_CALL amx_get_dir(AMX *amx, cell *params)
|
||||
return 0;
|
||||
set_amxstring(amx, params[2], fd.cFileName, params[3]);
|
||||
return 1;
|
||||
#else
|
||||
DIR *dp = (DIR *)params[1];
|
||||
if (!dp)
|
||||
return 0;
|
||||
struct dirent *ep = readdir(dp);
|
||||
if (!ep)
|
||||
return 0;
|
||||
set_amxstring(amx,params[2], ep->d_name,params[3]);
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user