Adding a function (checkAndCreateDirectoryP) tp create directories recursively
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5616 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e99d7592fb
commit
f4f78803b3
@ -376,6 +376,38 @@ bool FileManager::checkAndCreateDirectory(const std::string &path)
|
||||
return !error;
|
||||
} // checkAndCreateDirectory
|
||||
|
||||
bool FileManager::checkAndCreateDirectoryP(const std::string &path)
|
||||
{
|
||||
std::cout << "creating...:" << path << std::endl;
|
||||
// irrlicht apparently returns true for files and directory
|
||||
// (using access/_access internally):
|
||||
|
||||
if(m_file_system->existFile(io::path(path.c_str())))
|
||||
return true;
|
||||
|
||||
for(int i = 0; i <= path.size(); i++)
|
||||
{
|
||||
if(path.c_str()[i] == '/')
|
||||
{
|
||||
std::string current_path = path.substr(0, i + 1);
|
||||
std::cout << "Checking for: " << current_path << std::endl;
|
||||
if(m_file_system->existFile(io::path(current_path.c_str())))
|
||||
std::cout << "The directory exist." << std::endl;
|
||||
else
|
||||
{
|
||||
if(!checkAndCreateDirectory(current_path))
|
||||
{
|
||||
fprintf(stderr, "Can't create dir '%s'",
|
||||
current_path.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool error = checkAndCreateDirectory(path);
|
||||
|
||||
return error;
|
||||
} // checkAndCreateDirectory
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Checks if the config directory exists, and it not, tries to create it. */
|
||||
void FileManager::checkAndCreateConfigDir()
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
XMLNode *createXMLTree(const std::string &filename);
|
||||
|
||||
std::string getConfigDir () const;
|
||||
bool checkAndCreateDirectoryP(const std::string &path);
|
||||
#ifdef ADDONS_MANAGER
|
||||
std::string getAddonsDir () const;
|
||||
void checkAndCreateDirForAddons(std::string addons_name, std::string addons_type);
|
||||
|
Loading…
Reference in New Issue
Block a user