1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pr/tests/op_nofil.c Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,56 @@ 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_nofil.c 1.12 +** 1.13 +** Description: Test Program to verify the PR_FILE_NOT_FOUND_ERROR 1.14 +** 1.15 +** Modification History: 1.16 +** 03-June-97 AGarcia- Initial version 1.17 +***********************************************************************/ 1.18 + 1.19 +/*********************************************************************** 1.20 +** Includes 1.21 +***********************************************************************/ 1.22 +/* Used to get the command line option */ 1.23 +#include "prinit.h" 1.24 +#include "prmem.h" 1.25 +#include "prio.h" 1.26 +#include "prerror.h" 1.27 +#include <stdio.h> 1.28 +#include "plgetopt.h" 1.29 + 1.30 +/* 1.31 + * A file name that cannot exist 1.32 + */ 1.33 +#define NO_SUCH_FILE "/no/such/file.tmp" 1.34 + 1.35 +static PRFileDesc *t1; 1.36 + 1.37 +int main(int argc, char **argv) 1.38 +{ 1.39 + PR_STDIO_INIT(); 1.40 + t1 = PR_Open(NO_SUCH_FILE, PR_RDONLY, 0666); 1.41 + if (t1 == NULL) { 1.42 + if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) { 1.43 + printf ("error code is PR_FILE_NOT_FOUND_ERROR, as expected\n"); 1.44 + printf ("PASS\n"); 1.45 + return 0; 1.46 + } else { 1.47 + printf ("error code is %d \n", PR_GetError()); 1.48 + printf ("FAIL\n"); 1.49 + return 1; 1.50 + } 1.51 + } 1.52 + printf ("File %s exists on this machine!?\n", NO_SUCH_FILE); 1.53 + if (PR_Close(t1) == PR_FAILURE) { 1.54 + printf ("cannot close file\n"); 1.55 + printf ("error code is %d \n", PR_GetError()); 1.56 + } 1.57 + printf ("FAIL\n"); 1.58 + return 1; 1.59 +}