op_filnf.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_filnf.c
  8. **
  9. ** Description: Test Program to verify the PR_FILE_NOT_FOUND_ERROR
  10. ** This test program also uses the TRUNCATE option
  11. **
  12. ** Modification History:
  13. ** 03-June-97 AGarcia- Initial version
  14. ***********************************************************************/
  15. /***********************************************************************
  16. ** Includes
  17. ***********************************************************************/
  18. /* Used to get the command line option */
  19. #include "prinit.h"
  20. #include "prmem.h"
  21. #include "prio.h"
  22. #include "prerror.h"
  23. #include <stdio.h>
  24. #include "plgetopt.h"
  25. static PRFileDesc *t1;
  26. PRIntn error_code;
  27. int main(int argc, char **argv)
  28. {
  29. PR_STDIO_INIT();
  30. t1 = PR_Open("./tmp-ttools/err03.tmp", PR_TRUNCATE | PR_RDWR, 0666);
  31. if (t1 == NULL) {
  32. if (PR_GetError() == PR_FILE_NOT_FOUND_ERROR) {
  33. printf ("error code is %d \n", PR_GetError());
  34. printf ("PASS\n");
  35. return 0;
  36. }
  37. else {
  38. printf ("error code is %d \n", PR_GetError());
  39. printf ("FAIL\n");
  40. return 1;
  41. }
  42. }
  43. PR_Close(t1);
  44. printf ("opened a file that should not exist\n");
  45. printf ("FAIL\n");
  46. return 1;
  47. }