is there any chance thiswill work on all platforms hmmm added removeAdirectory
This commit is contained in:
parent
303cb13e0b
commit
cd5ec5ee1b
@ -13,6 +13,7 @@
|
|||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
#include "kwsysPrivate.h"
|
#include "kwsysPrivate.h"
|
||||||
#include KWSYS_HEADER(SystemTools.hxx)
|
#include KWSYS_HEADER(SystemTools.hxx)
|
||||||
|
#include KWSYS_HEADER(Directory.hxx)
|
||||||
|
|
||||||
#include KWSYS_HEADER(std/iostream)
|
#include KWSYS_HEADER(std/iostream)
|
||||||
#include KWSYS_HEADER(std/fstream)
|
#include KWSYS_HEADER(std/fstream)
|
||||||
@ -44,6 +45,10 @@ inline int Mkdir(const char* dir)
|
|||||||
{
|
{
|
||||||
return _mkdir(dir);
|
return _mkdir(dir);
|
||||||
}
|
}
|
||||||
|
inline int Rmdir(const char* dir)
|
||||||
|
{
|
||||||
|
return _rmdir(dir);
|
||||||
|
}
|
||||||
inline const char* Getcwd(char* buf, unsigned int len)
|
inline const char* Getcwd(char* buf, unsigned int len)
|
||||||
{
|
{
|
||||||
return _getcwd(buf, len);
|
return _getcwd(buf, len);
|
||||||
@ -64,6 +69,10 @@ inline int Mkdir(const char* dir)
|
|||||||
{
|
{
|
||||||
return mkdir(dir, 00777);
|
return mkdir(dir, 00777);
|
||||||
}
|
}
|
||||||
|
inline int Rmdir(const char* dir)
|
||||||
|
{
|
||||||
|
return rmdir(dir);
|
||||||
|
}
|
||||||
inline const char* Getcwd(char* buf, unsigned int len)
|
inline const char* Getcwd(char* buf, unsigned int len)
|
||||||
{
|
{
|
||||||
return getcwd(buf, len);
|
return getcwd(buf, len);
|
||||||
@ -1005,6 +1014,38 @@ bool SystemTools::RemoveFile(const char* source)
|
|||||||
return unlink(source) != 0 ? false : true;
|
return unlink(source) != 0 ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SystemTools::RemoveADirectory(const char* source)
|
||||||
|
{
|
||||||
|
Directory dir;
|
||||||
|
dir.Load(source);
|
||||||
|
size_t fileNum;
|
||||||
|
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
|
||||||
|
{
|
||||||
|
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
|
||||||
|
strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
|
||||||
|
{
|
||||||
|
kwsys_std::string fullPath = source;
|
||||||
|
fullPath += "/";
|
||||||
|
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
|
||||||
|
if(SystemTools::FileIsDirectory(fullPath.c_str()))
|
||||||
|
{
|
||||||
|
if (!SystemTools::RemoveADirectory(fullPath.c_str()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(!SystemTools::RemoveFile(fullPath.c_str()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Rmdir(source) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the file the given name. Searches the given path and then
|
* Find the file the given name. Searches the given path and then
|
||||||
@ -1042,9 +1083,10 @@ kwsys_std::string SystemTools::FindFile(const char* name,
|
|||||||
* the system search path. Returns the full path to the executable if it is
|
* the system search path. Returns the full path to the executable if it is
|
||||||
* found. Otherwise, the empty string is returned.
|
* found. Otherwise, the empty string is returned.
|
||||||
*/
|
*/
|
||||||
kwsys_std::string SystemTools::FindProgram(const char* name,
|
kwsys_std::string SystemTools::FindProgram(
|
||||||
const kwsys_std::vector<kwsys_std::string>& userPaths,
|
const char* name,
|
||||||
bool no_system_path)
|
const kwsys_std::vector<kwsys_std::string>& userPaths,
|
||||||
|
bool no_system_path)
|
||||||
{
|
{
|
||||||
if(!name)
|
if(!name)
|
||||||
{
|
{
|
||||||
|
@ -150,6 +150,9 @@ public:
|
|||||||
///! Remove a file.
|
///! Remove a file.
|
||||||
static bool RemoveFile(const char* source);
|
static bool RemoveFile(const char* source);
|
||||||
|
|
||||||
|
///! Remove a directory
|
||||||
|
static bool RemoveADirectory(const char* source);
|
||||||
|
|
||||||
///! Find a file in the system PATH, with optional extra paths.
|
///! Find a file in the system PATH, with optional extra paths.
|
||||||
static kwsys_std::string FindFile(const char* name,
|
static kwsys_std::string FindFile(const char* name,
|
||||||
const kwsys_std::vector<kwsys_std::string>& path= kwsys_std::vector<kwsys_std::string>());
|
const kwsys_std::vector<kwsys_std::string>& path= kwsys_std::vector<kwsys_std::string>());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user