op_filok.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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_filok.c
  8. **
  9. ** Description: Test Program to verify the PR_Open finding an existing file.
  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. static PRFileDesc *t1;
  24. int main(int argc, char **argv)
  25. {
  26. PR_STDIO_INIT();
  27. t1 = PR_Open(argv[0], PR_RDONLY, 0666);
  28. if (t1 == NULL) {
  29. printf ("error code is %d \n", PR_GetError());
  30. printf ("File %s should be found\n", argv[0]);
  31. return 1;
  32. } else {
  33. if (PR_Close(t1) == PR_SUCCESS) {
  34. printf ("Test passed \n");
  35. return 0;
  36. } else {
  37. printf ("cannot close file\n");
  38. printf ("error code is %d\n", PR_GetError());
  39. return 1;
  40. }
  41. }
  42. }