nsprpub/pr/tests/op_filnf.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nsprpub/pr/tests/op_filnf.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +/***********************************************************************
    1.10 +**
    1.11 +** Name: op_filnf.c
    1.12 +**
    1.13 +** Description: Test Program to verify the PR_FILE_NOT_FOUND_ERROR
    1.14 +**				This test program also uses the TRUNCATE option
    1.15 +**
    1.16 +** Modification History:
    1.17 +** 03-June-97 AGarcia- Initial version
    1.18 +***********************************************************************/
    1.19 +
    1.20 +/***********************************************************************
    1.21 +** Includes
    1.22 +***********************************************************************/
    1.23 +/* Used to get the command line option */
    1.24 +#include "prinit.h"
    1.25 +#include "prmem.h"
    1.26 +#include "prio.h"
    1.27 +#include "prerror.h"
    1.28 +#include <stdio.h>
    1.29 +#include "plgetopt.h"
    1.30 +
    1.31 +static PRFileDesc *t1;
    1.32 +PRIntn error_code;
    1.33 +
    1.34 +int main(int argc, char **argv)
    1.35 +{
    1.36 +    PR_STDIO_INIT();
    1.37 +	t1 = PR_Open("/usr/tmp/ttools/err03.tmp", PR_TRUNCATE | PR_RDWR, 0666);
    1.38 +	if (t1 == NULL) {
    1.39 +		if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {
    1.40 +				printf ("error code is %d \n", PR_GetError());
    1.41 +				printf ("PASS\n");
    1.42 +				return 0;
    1.43 +		}
    1.44 +		else {
    1.45 +				printf ("error code is %d \n", PR_GetError());
    1.46 +				printf ("FAIL\n");
    1.47 +			return 1;
    1.48 +		}
    1.49 +	}
    1.50 +	PR_Close(t1);
    1.51 +	printf ("opened a file that should not exist\n");
    1.52 +	printf ("FAIL\n");
    1.53 +	return 1;
    1.54 +}			

mercurial