2
0
mirror of https://github.com/rehlds/metamod-r.git synced 2024-12-27 07:05:34 +03:00

Use MAX_PATH instead PATH_MAX to use one style

This commit is contained in:
s1lent 2017-11-18 23:30:43 +07:00
parent 2f1df890bd
commit e32e4f6d6e
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
11 changed files with 21 additions and 22 deletions

View File

@ -36,7 +36,7 @@ bool MConfig::set(const char* key, const char* value) const
bool MConfig::set(option_t* setp, const char* setstr)
{
char pathbuf[PATH_MAX];
char pathbuf[MAX_PATH];
int* optval = (int *)setp->dest;
char** optstr = (char **)setp->dest;
// cvar_t *optcvar = (cvar_t *) setp->dest;
@ -92,7 +92,7 @@ bool MConfig::set(option_t* setp, const char* setstr)
bool MConfig::load(const char* fn)
{
char loadfile[PATH_MAX];
char loadfile[MAX_PATH];
char line[MAX_CONF_LEN];
// Make full pathname (from gamedir if relative, collapse "..",

View File

@ -44,8 +44,8 @@ static const game_modinfo_t *lookup_game(const char *name)
bool lookup_game_postfixes(gamedll_t *gamedll)
{
char pathname[PATH_MAX];
static char postfix_path[PATH_MAX] = "";
char pathname[MAX_PATH];
static char postfix_path[MAX_PATH] = "";
Q_strlcpy(pathname, gamedll->pathname);

View File

@ -241,7 +241,7 @@ bool meta_init_gamedll()
{
Q_memset(&g_GameDLL, 0, sizeof g_GameDLL);
char gamedir[PATH_MAX];
char gamedir[MAX_PATH];
GET_GAME_DIR(gamedir);
normalize_path(gamedir);
@ -269,7 +269,7 @@ bool meta_init_gamedll()
else {
// New style; GET_GAME_DIR returned game name. Copy this into our
// game name, and prepend the current working directory.
char buf[PATH_MAX];
char buf[MAX_PATH];
if (!_getcwd(buf, sizeof buf)) {
META_WARNING("dll: Couldn't get cwd; %s", strerror(errno));
return false;

View File

@ -20,10 +20,10 @@ struct gamedll_t
{
char name[NAME_MAX]; // ie "cstrike" (from gamedir)
char desc[NAME_MAX]; // ie "Counter-Strike"
char gamedir[PATH_MAX]; // ie "/home/willday/half-life/cstrike"
char pathname[PATH_MAX]; // ie "/home/willday/half-life/cstrike/dlls/cs_i386.so"
char gamedir[MAX_PATH]; // ie "/home/willday/half-life/cstrike"
char pathname[MAX_PATH]; // ie "/home/willday/half-life/cstrike/dlls/cs_i386.so"
char const* file; // ie "cs_i386.so"
char real_pathname[PATH_MAX]; // in case pathname overridden by bot, etc
char real_pathname[MAX_PATH]; // in case pathname overridden by bot, etc
CSysModule sys_module;
gamedll_funcs_t funcs; // dllapi_table, newapi_table
};

View File

@ -44,5 +44,5 @@ public:
private:
size_t m_last_index;
plugins_t m_plugins; // array of plugins
char m_inifile[PATH_MAX]; // full pathname
char m_inifile[MAX_PATH]; // full pathname
};

View File

@ -113,7 +113,7 @@ bool MPlugin::ini_parseline(char *line)
// Parse a line from console "load" command into a plugin.
bool MPlugin::cmd_parseline(const char *line)
{
char buf[NAME_MAX + PATH_MAX + MAX_DESC_LEN];
char buf[NAME_MAX + MAX_PATH + MAX_DESC_LEN];
char *ptr_token;
Q_strlcpy(buf, line);

View File

@ -161,10 +161,10 @@ private:
gamedll_funcs_t m_gamedll_funcs;
mutil_funcs_t m_mutil_funcs;
char m_filename[PATH_MAX]; // ie "dlls/mm_test_i386.so", from inifile
char m_filename[MAX_PATH]; // ie "dlls/mm_test_i386.so", from inifile
char *m_file; // ie "mm_test_i386.so", ptr from filename
char m_desc[MAX_DESC_LEN]; // ie "Test metamod plugin", from inifile
char m_pathname[PATH_MAX]; // UNIQUE, ie "/home/willday/half-life/cstrike/dlls/mm_test_i386.so", built with GameDLL.gamedir
char m_pathname[MAX_PATH]; // UNIQUE, ie "/home/willday/half-life/cstrike/dlls/mm_test_i386.so", built with GameDLL.gamedir
static const char *s_rPrintLoadTime[][4];

View File

@ -241,7 +241,7 @@ const char* EXT_FUNC mutil_GetUserMsgName(plid_t plid, int msgid, int* size)
// Return the full path of the plugin's loaded dll/so file.
const char* EXT_FUNC mutil_GetPluginPath(plid_t plid)
{
static char buf[PATH_MAX];
static char buf[MAX_PATH] = "";
auto plug = g_plugins->find(plid);
if (!plug) {

View File

@ -17,7 +17,6 @@
#elif defined(_WIN32)
#include <stdlib.h>
#define NAME_MAX _MAX_FNAME
#define PATH_MAX _MAX_PATH
#endif // _WIN32
// Various other windows routine differences.

View File

@ -91,8 +91,8 @@ bool is_platform_postfix(const char* pf)
#ifdef _WIN32
char* realpath(const char* file_name, char* resolved_name)
{
int ret = GetFullPathName(file_name, PATH_MAX, resolved_name, nullptr);
if (ret > PATH_MAX) {
int ret = GetFullPathName(file_name, MAX_PATH, resolved_name, nullptr);
if (ret > MAX_PATH) {
errno = ENAMETOOLONG;
return nullptr;
}
@ -123,7 +123,7 @@ char* realpath(const char* file_name, char* resolved_name)
// Special-case-recognize "/dev/null" as a valid file.
bool is_file_exists_in_gamedir(const char* path)
{
char buf[PATH_MAX];
char buf[MAX_PATH];
if (!path)
return false;
@ -168,10 +168,10 @@ bool is_file_exists_in_gamedir(const char* path)
// - calls NormalizePath() to fix backslashes, etc
//
// Much like realpath, buffer pointed to by fullpath is assumed to be
// able to store a string of PATH_MAX length.
char* full_gamedir_path(const char* path, char (&fullpath)[PATH_MAX])
// able to store a string of MAX_PATH length.
char* full_gamedir_path(const char* path, char (&fullpath)[MAX_PATH])
{
char buf[PATH_MAX];
char buf[MAX_PATH];
// Build pathname from filename, plus gamedir if relative path.
if (is_abs_path(path)) {

View File

@ -32,7 +32,7 @@ bool is_abs_path(const char *path);
bool is_valid_path(const char *path);
bool is_platform_postfix(const char *pf);
bool is_file_exists_in_gamedir(const char *path);
char *full_gamedir_path(const char *path, char (&fullpath)[PATH_MAX]);
char *full_gamedir_path(const char *path, char (&fullpath)[MAX_PATH]);
bool mem_compare(const char* addr, const char* pattern, size_t len);
void NORETURN Sys_Error(const char *error, ...);