From c1789e69869370889bbe57f2ec8606ba45ab5034 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 23 Dec 2011 15:49:09 -0500 Subject: complex: Remove test dependence on cmSystemTools Use C standard 'remove' and POSIX standard 'stat'. --- Tests/Complex/Executable/complex.cxx | 24 ++++++++++++------------ Tests/ComplexOneConfig/Executable/complex.cxx | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index f095449..ca73bcb 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -11,7 +11,6 @@ extern "C" { } #ifdef COMPLEX_TEST_CMAKELIB #include "cmStandardIncludes.h" -#include "cmSystemTools.h" #else #include #include @@ -19,6 +18,12 @@ extern "C" { #include #endif +#include +#include +#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,20 +96,14 @@ 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); - } + cmPassed("Find dir: ", filename); } } diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index f095449..ca73bcb 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -11,7 +11,6 @@ extern "C" { } #ifdef COMPLEX_TEST_CMAKELIB #include "cmStandardIncludes.h" -#include "cmSystemTools.h" #else #include #include @@ -19,6 +18,12 @@ extern "C" { #include #endif +#include +#include +#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,20 +96,14 @@ 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); - } + cmPassed("Find dir: ", filename); } } -- cgit v0.12