X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Fremove.c;h=609ddbe4b49d70b3a722e29fe6838fb8b73c1cb5;hb=f76c403c1ea4678d59e118173088064851e5dfbe;hp=970db6add911607e9a430d3d5a87cc1a5c31807d;hpb=dc494d280a8f7ebcfdfe897c663910f1a6b8f82e;p=pdclib.old diff --git a/platform/example/functions/_PDCLIB/remove.c b/platform/example/functions/_PDCLIB/remove.c index 970db6a..609ddbe 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,30 @@ int _PDCLIB_remove( const char * filename ) #undef SEEK_SET #include <_PDCLIB_test.h> +#include +#include + int main( void ) { - TESTCASE( NO_TESTDRIVER ); + char filename[ L_tmpnam + 6 ] = "touch "; + tmpnam( filename + 6 ); + /* create file */ + 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; }