complex: Remove test dependence on cmSystemTools

Use C standard 'remove' and POSIX standard 'stat'.
This commit is contained in:
Brad King 2011-12-23 15:49:09 -05:00
parent 569cee1d9e
commit c1789e6986
2 changed files with 24 additions and 24 deletions

View File

@ -11,7 +11,6 @@ extern "C" {
}
#ifdef COMPLEX_TEST_CMAKELIB
#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
#else
#include <vector>
#include <string>
@ -19,6 +18,12 @@ extern "C" {
#include <string.h>
#endif
#include <stdio.h>
#include <sys/stat.h>
#if !defined(S_ISDIR)
# define S_ISDIR(mode) ((mode) & _S_IFDIR)
#endif
#ifdef COMPLEX_TEST_LINK_STATIC
extern "C"
{
@ -69,13 +74,14 @@ void cmPassed(const char* Message, const char* m2="")
void TestAndRemoveFile(const char* filename)
{
if (!cmSystemTools::FileExists(filename))
struct stat st;
if(stat(filename, &st) < 0)
{
cmFailed("Could not find file: ", filename);
}
else
{
if (!cmSystemTools::RemoveFile(filename))
if (remove(filename) < 0)
{
cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
}
@ -90,22 +96,16 @@ void TestAndRemoveFile(const char* filename)
void TestDir(const char* filename)
{
if (!cmSystemTools::FileExists(filename))
struct stat st;
if(stat(filename, &st) < 0 || !S_ISDIR(st.st_mode))
{
cmFailed("Could not find dir: ", filename);
}
else
{
if (!cmSystemTools::FileIsDirectory(filename))
{
cmFailed("Unable to check if file is a directory: ", filename);
}
else
{
cmPassed("Find dir: ", filename);
}
}
}
#endif

View File

@ -11,7 +11,6 @@ extern "C" {
}
#ifdef COMPLEX_TEST_CMAKELIB
#include "cmStandardIncludes.h"
#include "cmSystemTools.h"
#else
#include <vector>
#include <string>
@ -19,6 +18,12 @@ extern "C" {
#include <string.h>
#endif
#include <stdio.h>
#include <sys/stat.h>
#if !defined(S_ISDIR)
# define S_ISDIR(mode) ((mode) & _S_IFDIR)
#endif
#ifdef COMPLEX_TEST_LINK_STATIC
extern "C"
{
@ -69,13 +74,14 @@ void cmPassed(const char* Message, const char* m2="")
void TestAndRemoveFile(const char* filename)
{
if (!cmSystemTools::FileExists(filename))
struct stat st;
if(stat(filename, &st) < 0)
{
cmFailed("Could not find file: ", filename);
}
else
{
if (!cmSystemTools::RemoveFile(filename))
if (remove(filename) < 0)
{
cmFailed("Unable to remove file. It does not imply that this test failed, but it *will* be corrupted thereafter if this file is not removed: ", filename);
}
@ -90,22 +96,16 @@ void TestAndRemoveFile(const char* filename)
void TestDir(const char* filename)
{
if (!cmSystemTools::FileExists(filename))
struct stat st;
if(stat(filename, &st) < 0 || !S_ISDIR(st.st_mode))
{
cmFailed("Could not find dir: ", filename);
}
else
{
if (!cmSystemTools::FileIsDirectory(filename))
{
cmFailed("Unable to check if file is a directory: ", filename);
}
else
{
cmPassed("Find dir: ", filename);
}
}
}
#endif