bjh 99/06/06 02:17:52
Modified: apr/test testfile.c Log: Modify testfile.c to take into account that in OS/2 and possibly other platforms: - An open file can't be deleted. - The directory entry for a file doesn't have it's size attribute updated until the file is closed or flushed. I've also added an extra error check. Revision Changes Path 1.26 +8 -5 apache-apr/apr/test/testfile.c Index: testfile.c =================================================================== RCS file: /home/cvs/apache-apr/apr/test/testfile.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- testfile.c 1999/06/03 19:43:55 1.25 +++ testfile.c 1999/06/06 09:17:50 1.26 @@ -55,6 +55,7 @@ #include "apr_file_io.h" #include "apr_errno.h" #include "apr_general.h" +#include "apr_lib.h" #include "errno.h" #include <stdio.h> #ifdef BEOS @@ -193,11 +194,11 @@ return stat; } - if ((stat = ap_remove_file(context, "testdel")) != APR_SUCCESS) { + if ((stat = ap_close(thefile)) != APR_SUCCESS) { return stat; } - if ((stat = ap_close(thefile)) != APR_SUCCESS) { + if ((stat = ap_remove_file(context, "testdel")) != APR_SUCCESS) { return stat; } @@ -234,6 +235,7 @@ bytes = strlen("Another test!!!"); ap_write(file, "Another test!!", &bytes); + ap_close(file); fprintf(stdout, "\tOpening Directory......."); if (ap_opendir(context, "testdir", &temp) != APR_SUCCESS) { @@ -259,7 +261,10 @@ /* Because I want the file I created, I am skipping the "." and ".." * files that are here. */ - ap_readdir(temp); + if (ap_readdir(temp) != APR_SUCCESS) { + fprintf(stderr, "Error reading directory testdir"); + return -1; + } ap_get_dir_filename(temp, &fname); } while (fname[0] == '.'); if (strcmp(fname, "testfile")) { @@ -296,8 +301,6 @@ else { fprintf(stdout, "OK\n"); } - - ap_close(file); fprintf(stdout, "\tRemoving file from directory......."); if (ap_remove_file(context, "testdir/testfile") != APR_SUCCESS) {