op_nofil.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. ** Name: op_nofil.c
  8. **
  9. ** Description: Test Program to verify the PR_FILE_NOT_FOUND_ERROR
  10. **
  11. ** Modification History:
  12. ** 03-June-97 AGarcia- Initial version
  13. ***********************************************************************/
  14. /***********************************************************************
  15. ** Includes
  16. ***********************************************************************/
  17. /* Used to get the command line option */
  18. #include "prinit.h"
  19. #include "prmem.h"
  20. #include "prio.h"
  21. #include "prerror.h"
  22. #include <stdio.h>
  23. #include "plgetopt.h"
  24. /*
  25. * A file name that cannot exist
  26. */
  27. #define NO_SUCH_FILE "/no/such/file.tmp"
  28. static PRFileDesc *t1;
  29. int main(int argc, char **argv)
  30. {
  31. PR_STDIO_INIT();
  32. t1 = PR_Open(NO_SUCH_FILE, PR_RDONLY, 0666);
  33. if (t1 == NULL) {
  34. if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {
  35. printf ("error code is PR_FILE_NOT_FOUND_ERROR, as expected\n");
  36. printf ("PASS\n");
  37. return 0;
  38. } else {
  39. printf ("error code is %d \n", PR_GetError());
  40. printf ("FAIL\n");
  41. return 1;
  42. }
  43. }
  44. printf ("File %s exists on this machine!?\n", NO_SUCH_FILE);
  45. if (PR_Close(t1) == PR_FAILURE) {
  46. printf ("cannot close file\n");
  47. printf ("error code is %d \n", PR_GetError());
  48. }
  49. printf ("FAIL\n");
  50. return 1;
  51. }