More robust pjlib file test: it shouldn't leave the file on the disk if the test fails
git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@957 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
0deef106f1
commit
c77fd57bc1
|
@ -28,7 +28,7 @@
|
|||
static char buffer[11] = {'H', 'e', 'l', 'l', 'o', ' ',
|
||||
'W', 'o', 'r', 'l', 'd' };
|
||||
|
||||
int file_test(void)
|
||||
static int file_test_internal(void)
|
||||
{
|
||||
enum { FILE_MAX_AGE = 1000 };
|
||||
pj_oshandle_t fd = 0;
|
||||
|
@ -89,9 +89,9 @@ int file_test(void)
|
|||
if (stat.size != sizeof(buffer))
|
||||
return -70;
|
||||
|
||||
#if INCLUDE_FILE_TIME_TEST
|
||||
/* Check file creation time >= start_time. */
|
||||
if (!PJ_TIME_VAL_GTE(stat.ctime, start_time))
|
||||
#if INCLUDE_FILE_TIME_TEST
|
||||
return -80;
|
||||
/* Check file creation time is not much later. */
|
||||
PJ_TIME_VAL_SUB(stat.ctime, start_time);
|
||||
|
@ -206,6 +206,18 @@ int file_test(void)
|
|||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int file_test(void)
|
||||
{
|
||||
int rc = file_test_internal();
|
||||
|
||||
/* Delete test file if exists. */
|
||||
if (pj_file_exists(FILENAME))
|
||||
pj_file_delete(FILENAME);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#else
|
||||
int dummy_file_test;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue