Moved cMakeDir::MakeDir to cFile::CreateFolder.
And exported to Lua.
This commit is contained in:
parent
2ff882f239
commit
55999ee118
@ -1399,14 +1399,6 @@
|
|||||||
RelativePath="..\source\OSSupport\ListenThread.h"
|
RelativePath="..\source\OSSupport\ListenThread.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\source\OSSupport\MakeDir.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\source\OSSupport\MakeDir.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\source\OSSupport\Semaphore.cpp"
|
RelativePath="..\source\OSSupport\Semaphore.cpp"
|
||||||
>
|
>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Lua binding: AllToLua
|
** Lua binding: AllToLua
|
||||||
** Generated automatically by tolua++-1.0.92 on 10/09/13 09:38:09.
|
** Generated automatically by tolua++-1.0.92 on 10/09/13 09:54:54.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
@ -2686,6 +2686,37 @@ static int tolua_AllToLua_cFile_GetSize00(lua_State* tolua_S)
|
|||||||
}
|
}
|
||||||
#endif //#ifndef TOLUA_DISABLE
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
|
/* method: CreateFolder of class cFile */
|
||||||
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_cFile_CreateFolder00
|
||||||
|
static int tolua_AllToLua_cFile_CreateFolder00(lua_State* tolua_S)
|
||||||
|
{
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
if (
|
||||||
|
!tolua_isusertable(tolua_S,1,"cFile",0,&tolua_err) ||
|
||||||
|
!tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
|
||||||
|
!tolua_isnoobj(tolua_S,3,&tolua_err)
|
||||||
|
)
|
||||||
|
goto tolua_lerror;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
const AString a_FolderPath = ((const AString) tolua_tocppstring(tolua_S,2,0));
|
||||||
|
{
|
||||||
|
bool tolua_ret = (bool) cFile::CreateFolder(a_FolderPath);
|
||||||
|
tolua_pushboolean(tolua_S,(bool)tolua_ret);
|
||||||
|
tolua_pushcppstring(tolua_S,(const char*)a_FolderPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
#ifndef TOLUA_RELEASE
|
||||||
|
tolua_lerror:
|
||||||
|
tolua_error(tolua_S,"#ferror in function 'CreateFolder'.",&tolua_err);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif //#ifndef TOLUA_DISABLE
|
||||||
|
|
||||||
/* function: BlockStringToType */
|
/* function: BlockStringToType */
|
||||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_BlockStringToType00
|
#ifndef TOLUA_DISABLE_tolua_AllToLua_BlockStringToType00
|
||||||
static int tolua_AllToLua_BlockStringToType00(lua_State* tolua_S)
|
static int tolua_AllToLua_BlockStringToType00(lua_State* tolua_S)
|
||||||
@ -29140,6 +29171,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
|||||||
tolua_function(tolua_S,"IsFolder",tolua_AllToLua_cFile_IsFolder00);
|
tolua_function(tolua_S,"IsFolder",tolua_AllToLua_cFile_IsFolder00);
|
||||||
tolua_function(tolua_S,"IsFile",tolua_AllToLua_cFile_IsFile00);
|
tolua_function(tolua_S,"IsFile",tolua_AllToLua_cFile_IsFile00);
|
||||||
tolua_function(tolua_S,"GetSize",tolua_AllToLua_cFile_GetSize00);
|
tolua_function(tolua_S,"GetSize",tolua_AllToLua_cFile_GetSize00);
|
||||||
|
tolua_function(tolua_S,"CreateFolder",tolua_AllToLua_cFile_CreateFolder00);
|
||||||
tolua_endmodule(tolua_S);
|
tolua_endmodule(tolua_S);
|
||||||
tolua_constant(tolua_S,"E_BLOCK_AIR",E_BLOCK_AIR);
|
tolua_constant(tolua_S,"E_BLOCK_AIR",E_BLOCK_AIR);
|
||||||
tolua_constant(tolua_S,"E_BLOCK_STONE",E_BLOCK_STONE);
|
tolua_constant(tolua_S,"E_BLOCK_STONE",E_BLOCK_STONE);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
** Lua binding: AllToLua
|
** Lua binding: AllToLua
|
||||||
** Generated automatically by tolua++-1.0.92 on 10/09/13 09:38:10.
|
** Generated automatically by tolua++-1.0.92 on 10/09/13 09:54:54.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Exported function */
|
/* Exported function */
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../Tracer.h"
|
#include "../Tracer.h"
|
||||||
#include "../Root.h"
|
#include "../Root.h"
|
||||||
#include "../OSSupport/MakeDir.h"
|
|
||||||
#include "../OSSupport/Timer.h"
|
#include "../OSSupport/Timer.h"
|
||||||
#include "../MersenneTwister.h"
|
#include "../MersenneTwister.h"
|
||||||
#include "../Chunk.h"
|
#include "../Chunk.h"
|
||||||
@ -1340,7 +1339,7 @@ bool cPlayer::LoadFromDisk()
|
|||||||
|
|
||||||
bool cPlayer::SaveToDisk()
|
bool cPlayer::SaveToDisk()
|
||||||
{
|
{
|
||||||
cMakeDir::MakeDir("players");
|
cFile::CreateFolder(FILE_IO_PREFIX + AString("players"));
|
||||||
|
|
||||||
// create the JSON data
|
// create the JSON data
|
||||||
Json::Value JSON_PlayerPosition;
|
Json::Value JSON_PlayerPosition;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include "OSSupport/MakeDir.h"
|
|
||||||
#include "OSSupport/IsThread.h"
|
#include "OSSupport/IsThread.h"
|
||||||
|
|
||||||
#if defined(ANDROID_NDK)
|
#if defined(ANDROID_NDK)
|
||||||
@ -24,9 +23,9 @@ cLog::cLog(const AString & a_FileName )
|
|||||||
s_Log = this;
|
s_Log = this;
|
||||||
|
|
||||||
// create logs directory
|
// create logs directory
|
||||||
cMakeDir::MakeDir("logs");
|
cFile::CreateFolder(FILE_IO_PREFIX + AString("logs"));
|
||||||
|
|
||||||
OpenLog( (FILE_IO_PREFIX + std::string("logs/") + a_FileName).c_str() );
|
OpenLog((FILE_IO_PREFIX + AString("logs/") + a_FileName).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,8 +44,10 @@ cLog::~cLog()
|
|||||||
|
|
||||||
cLog* cLog::GetInstance()
|
cLog* cLog::GetInstance()
|
||||||
{
|
{
|
||||||
if(s_Log)
|
if (s_Log != NULL)
|
||||||
|
{
|
||||||
return s_Log;
|
return s_Log;
|
||||||
|
}
|
||||||
|
|
||||||
new cLog("log.txt");
|
new cLog("log.txt");
|
||||||
return s_Log;
|
return s_Log;
|
||||||
|
@ -310,11 +310,11 @@ bool cFile::Copy(const AString & a_SrcFileName, const AString & a_DstFileName)
|
|||||||
bool cFile::IsFolder(const AString & a_Path)
|
bool cFile::IsFolder(const AString & a_Path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
|
DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
|
||||||
return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0));
|
return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0));
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
|
return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,11 +325,11 @@ bool cFile::IsFolder(const AString & a_Path)
|
|||||||
bool cFile::IsFile(const AString & a_Path)
|
bool cFile::IsFile(const AString & a_Path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
|
DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
|
||||||
return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0));
|
return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0));
|
||||||
#else
|
#else
|
||||||
struct stat st;
|
struct stat st;
|
||||||
return ((stat(a_Path.c_str(), &st) == 0) && S_ISREG(st.st_mode));
|
return ((stat(a_Path.c_str(), &st) == 0) && S_ISREG(st.st_mode));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,6 +351,19 @@ int cFile::GetSize(const AString & a_FileName)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cFile::CreateFolder(const AString & a_FolderPath)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
return (CreateDirectory(a_FolderPath.c_str(), NULL) != 0);
|
||||||
|
#else
|
||||||
|
return (mkdir(a_FolderPath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO) == 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cFile::Printf(const char * a_Fmt, ...)
|
int cFile::Printf(const char * a_Fmt, ...)
|
||||||
{
|
{
|
||||||
AString buf;
|
AString buf;
|
||||||
|
@ -118,6 +118,9 @@ public:
|
|||||||
/// Returns the size of the file, or a negative number on error
|
/// Returns the size of the file, or a negative number on error
|
||||||
static int GetSize(const AString & a_FileName);
|
static int GetSize(const AString & a_FileName);
|
||||||
|
|
||||||
|
/// Creates a new folder with the specified name. Returns true if successful. Path may be relative or absolute
|
||||||
|
static bool CreateFolder(const AString & a_FolderPath);
|
||||||
|
|
||||||
// tolua_end
|
// tolua_end
|
||||||
|
|
||||||
int Printf(const char * a_Fmt, ...);
|
int Printf(const char * a_Fmt, ...);
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
|
||||||
|
|
||||||
#include "MakeDir.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cMakeDir::MakeDir(const AString & a_Directory)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
SECURITY_ATTRIBUTES Attrib;
|
|
||||||
Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
|
|
||||||
Attrib.lpSecurityDescriptor = NULL;
|
|
||||||
Attrib.bInheritHandle = false;
|
|
||||||
::CreateDirectory( (FILE_IO_PREFIX + a_Directory).c_str(), &Attrib);
|
|
||||||
#else
|
|
||||||
mkdir( (FILE_IO_PREFIX + a_Directory).c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class cMakeDir
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static void MakeDir(const AString & a_Directory);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -58,7 +58,6 @@
|
|||||||
#include "Mobs/Zombie.h"
|
#include "Mobs/Zombie.h"
|
||||||
#include "Mobs/Zombiepigman.h"
|
#include "Mobs/Zombiepigman.h"
|
||||||
|
|
||||||
#include "OSSupport/MakeDir.h"
|
|
||||||
#include "MersenneTwister.h"
|
#include "MersenneTwister.h"
|
||||||
#include "Generating/Trees.h"
|
#include "Generating/Trees.h"
|
||||||
#include "PluginManager.h"
|
#include "PluginManager.h"
|
||||||
@ -261,7 +260,7 @@ cWorld::cWorld(const AString & a_WorldName) :
|
|||||||
{
|
{
|
||||||
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
|
LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str());
|
||||||
|
|
||||||
cMakeDir::MakeDir(m_WorldName.c_str());
|
cFile::CreateFolder(FILE_IO_PREFIX + m_WorldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "../ItemGrid.h"
|
#include "../ItemGrid.h"
|
||||||
#include "../StringCompression.h"
|
#include "../StringCompression.h"
|
||||||
#include "../Entities/Entity.h"
|
#include "../Entities/Entity.h"
|
||||||
#include "../OSSupport/MakeDir.h"
|
|
||||||
#include "FastNBT.h"
|
#include "FastNBT.h"
|
||||||
#include "../Entities/FallingBlock.h"
|
#include "../Entities/FallingBlock.h"
|
||||||
#include "../Entities/Boat.h"
|
#include "../Entities/Boat.h"
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "../Item.h"
|
#include "../Item.h"
|
||||||
#include "../ItemGrid.h"
|
#include "../ItemGrid.h"
|
||||||
#include "../StringCompression.h"
|
#include "../StringCompression.h"
|
||||||
#include "../OSSupport/MakeDir.h"
|
|
||||||
#include "FastNBT.h"
|
#include "FastNBT.h"
|
||||||
#include "../Mobs/Monster.h"
|
#include "../Mobs/Monster.h"
|
||||||
#include "../Entities/Boat.h"
|
#include "../Entities/Boat.h"
|
||||||
@ -200,7 +199,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk)
|
|||||||
// Load it anew:
|
// Load it anew:
|
||||||
AString FileName;
|
AString FileName;
|
||||||
Printf(FileName, "%s/region", m_World->GetName().c_str());
|
Printf(FileName, "%s/region", m_World->GetName().c_str());
|
||||||
cMakeDir::MakeDir(FileName);
|
cFile::CreateFolder(FILE_IO_PREFIX + FileName);
|
||||||
AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ);
|
AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ);
|
||||||
cMCAFile * f = new cMCAFile(FileName, RegionX, RegionZ);
|
cMCAFile * f = new cMCAFile(FileName, RegionX, RegionZ);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user