Debian Codegraph @

nsprpub/pr/tests/op_filnf.c

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 /***********************************************************************
7 **
8 ** Name: op_filnf.c
9 **
10 ** Description: Test Program to verify the PR_FILE_NOT_FOUND_ERROR
11 ** This test program also uses the TRUNCATE option
12 **
13 ** Modification History:
14 ** 03-June-97 AGarcia- Initial version
15 ***********************************************************************/
16
17 /***********************************************************************
18 ** Includes
19 ***********************************************************************/
20 /* Used to get the command line option */
21 #include "prinit.h"
22 #include "prmem.h"
23 #include "prio.h"
24 #include "prerror.h"
25 #include <stdio.h>
26 #include "plgetopt.h"
27
28 static PRFileDesc* t1;
29 PRIntn error_code;
30
31 int main(int argc, char** argv) {
32 PR_STDIO_INIT();
33 t1 = PR_Open("./tmp-ttools/err03.tmp", PR_TRUNCATE | PR_RDWR, 0666);
34 if (t1 == NULL) {
35 if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {
36 printf("error code is %d \n", PR_GetError());
37 printf("PASS\n");
38 return 0;
39 } else {
40 printf("error code is %d \n", PR_GetError());
41 printf("FAIL\n");
42 return 1;
43 }
44 }
45 PR_Close(t1);
46 printf("opened a file that should not exist\n");
47 printf("FAIL\n");
48 return 1;
49 }