X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;ds=sidebyside;f=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Fremove.c;fp=platform%2Fexample%2Ffunctions%2F_PDCLIB%2Fremove.c;h=0000000000000000000000000000000000000000;hb=0d54a75af25ca44411e7c4190cc2a93a390e61a2;hp=184a1f2dcf181209a0e4f80b1f224d12e8db2ae4;hpb=18af9d0a4cd252433e0cbd5daf4640e325c9d0ab;p=pdclib.old diff --git a/platform/example/functions/_PDCLIB/remove.c b/platform/example/functions/_PDCLIB/remove.c deleted file mode 100644 index 184a1f2..0000000 --- a/platform/example/functions/_PDCLIB/remove.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $Id$ */ - -/* _PDCLIB_remove( const char * ) - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -/* This is an example implementation of _PDCLIB_remove() (declared in - _PDCLIB_glue.h), fit for use in POSIX kernels. - NOTE: Linux is *not* POSIX-compliant in this, as it sets EISDIR instead of - EPERM if you try to unlink a directory. Check the manpage for unlink(2). -*/ - -#ifndef REGTEST -#include <_PDCLIB_glue.h> -#include -#include - -int _PDCLIB_remove( const char * filename ) -{ - int prev_errno = errno; - int rc; - errno = 0; - if ( ( ( rc = unlink( filename ) ) != 0 ) && ( errno == EISDIR ) ) - { - rc = rmdir( filename ); - } - errno = prev_errno; - return rc; -} - -#endif - -#ifdef TEST -/* TODO: Work around the following undef */ -#undef SEEK_SET -#include <_PDCLIB_test.h> - -#include -#include - -int main( void ) -{ - 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; -} - -#endif