X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Fremove.c;h=184a1f2dcf181209a0e4f80b1f224d12e8db2ae4;hb=67cb1ca6543f8c00240597d140675bd1a66df90f;hp=970db6add911607e9a430d3d5a87cc1a5c31807d;hpb=e814d98512182702c60ba26236b14774e8ee88cc;p=pdclib.old diff --git a/platform/example/functions/_PDCLIB/remove.c b/platform/example/functions/_PDCLIB/remove.c index 970db6a..184a1f2 100644 --- a/platform/example/functions/_PDCLIB/remove.c +++ b/platform/example/functions/_PDCLIB/remove.c @@ -22,7 +22,7 @@ int _PDCLIB_remove( const char * filename ) int prev_errno = errno; int rc; errno = 0; - if ( ( ( rc = unlink( filename ) ) != 0 ) && ( errno == EPERM ) ) + if ( ( ( rc = unlink( filename ) ) != 0 ) && ( errno == EISDIR ) ) { rc = rmdir( filename ); } @@ -37,9 +37,28 @@ int _PDCLIB_remove( const char * filename ) #undef SEEK_SET #include <_PDCLIB_test.h> +#include +#include + int main( void ) { - TESTCASE( NO_TESTDRIVER ); + char filename[] = "touch testfile"; + system( filename ); + /* file is actually readable */ + TESTCASE( fopen( filename + 6, "r" ) != NULL ); + /* remove function does not return error */ + TESTCASE( _PDCLIB_remove( filename + 6 ) == 0 ); + /* file is no longer readable */ + TESTCASE( fopen( filename + 6, "r" ) == NULL ); + /* remove function does return error */ + TESTCASE( _PDCLIB_remove( filename + 6 ) != 0 ); + memcpy( filename, "mkdir", 5 ); + /* create directory */ + system( filename ); + /* remove function does not return error */ + TESTCASE( _PDCLIB_remove( filename + 6 ) == 0 ); + /* remove function does return error */ + TESTCASE( _PDCLIB_remove( filename + 6 ) != 0 ); return TEST_RESULTS; }