tested file natives and handle system
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40260
This commit is contained in:
parent
f072110a44
commit
929957643f
@ -51,7 +51,10 @@ cell_t sm_OpenDirectory(IPluginContext *pContext, const cell_t *params)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDirectory *pDir = g_LibSys.OpenDirectory(path);
|
char realpath[PLATFORM_MAX_PATH+1];
|
||||||
|
g_LibSys.PathFormat(realpath, sizeof(realpath), "%s/%s", g_SourceMod.GetBaseDir(), path);
|
||||||
|
|
||||||
|
IDirectory *pDir = g_LibSys.OpenDirectory(realpath);
|
||||||
if (!pDir)
|
if (!pDir)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -95,20 +98,36 @@ cell_t sm_ReadDirEntry(IPluginContext *pContext, const cell_t *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *path = pDir->GetEntryName();
|
const char *path = pDir->GetEntryName();
|
||||||
if ((err=pContext->StringToLocalUTF8(params[2], params[3],path, NULL))
|
if ((err=pContext->StringToLocalUTF8(params[2], params[3], path, NULL))
|
||||||
!= SP_ERROR_NONE)
|
!= SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
pContext->ThrowNativeErrorEx(err, NULL);
|
pContext->ThrowNativeErrorEx(err, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDir->NextEntry();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cell_t PrintStuff(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
char *stuff;
|
||||||
|
pContext->LocalToString(params[1], &stuff);
|
||||||
|
|
||||||
|
FILE *fp = fopen("c:\\debug.txt", "at");
|
||||||
|
fprintf(fp, "%s\n", stuff);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static FileNatives s_FileNatives;
|
||||||
|
|
||||||
REGISTER_NATIVES(filesystem)
|
REGISTER_NATIVES(filesystem)
|
||||||
{
|
{
|
||||||
{"OpenDirectory", sm_OpenDirectory},
|
{"OpenDirectory", sm_OpenDirectory},
|
||||||
{"ReadDirEntry", sm_ReadDirEntry},
|
{"ReadDirEntry", sm_ReadDirEntry},
|
||||||
|
{"PrintStuff", PrintStuff},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -165,5 +165,7 @@ REGISTER_NATIVES(basicstrings)
|
|||||||
{"IntToString", sm_numtostr},
|
{"IntToString", sm_numtostr},
|
||||||
{"StringToFloat", sm_strtofloat},
|
{"StringToFloat", sm_strtofloat},
|
||||||
{"FloatToString", sm_floattostr},
|
{"FloatToString", sm_floattostr},
|
||||||
|
{"Format", sm_format},
|
||||||
|
{"FormatEx", sm_formatex},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
@ -200,6 +200,11 @@ const char *SourceModBase::GetSMBaseDir()
|
|||||||
return m_SMBaseDir;
|
return m_SMBaseDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *SourceModBase::GetBaseDir()
|
||||||
|
{
|
||||||
|
return g_BaseDir.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
SMGlobalClass *SMGlobalClass::head = NULL;
|
SMGlobalClass *SMGlobalClass::head = NULL;
|
||||||
|
|
||||||
SMGlobalClass::SMGlobalClass()
|
SMGlobalClass::SMGlobalClass()
|
||||||
|
@ -37,6 +37,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
const char *GetSMBaseDir();
|
const char *GetSMBaseDir();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the base folder for file natives.
|
||||||
|
*/
|
||||||
|
const char *GetBaseDir();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns whether our load in this map is late.
|
* @brief Returns whether our load in this map is late.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user