home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / io / prdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.0 KB  |  84 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "primpl.h"
  20.  
  21. PR_IMPLEMENT(PRDir*) PR_OpenDir(const char *name)
  22. {
  23.     PRDir *dir;
  24.     PRStatus sts;
  25.  
  26.     dir = PR_NEW(PRDir);
  27.     if (dir) {
  28.         sts = _PR_MD_OPEN_DIR(&dir->md,name);
  29.         if (sts != PR_SUCCESS) {
  30.             PR_DELETE(dir);
  31.             return NULL;
  32.         }
  33.     } else {
  34.         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);
  35.     }
  36.     return dir;
  37. }
  38.  
  39. PR_IMPLEMENT(PRDirEntry*) PR_ReadDir(PRDir *dir, PRDirFlags flags)
  40. {
  41.     /* _MD_READ_DIR return a char* to the name; allocation in machine-dependent code */
  42.     char* name = _PR_MD_READ_DIR(&dir->md, flags);
  43.     dir->d.name = name;
  44.     return name ? &dir->d : NULL;
  45. }
  46.  
  47. PR_IMPLEMENT(PRStatus) PR_CloseDir(PRDir *dir)
  48. {
  49. PRInt32 rv;
  50.  
  51.     if (dir) {
  52.         rv = _PR_MD_CLOSE_DIR(&dir->md);
  53.         PR_DELETE(dir);
  54.         if (rv < 0) {
  55.             return PR_FAILURE;
  56.         } else
  57.             return PR_SUCCESS;
  58.     }
  59.     return PR_SUCCESS;
  60. }
  61.  
  62. PR_IMPLEMENT(PRStatus) PR_MkDir(const char *name, PRIntn mode)
  63. {
  64. PRInt32 rv;
  65.  
  66.     rv = _PR_MD_MKDIR(name, mode);
  67.     if (rv < 0) {
  68.         return PR_FAILURE;
  69.     } else
  70.         return PR_SUCCESS;
  71. }
  72.  
  73. PR_IMPLEMENT(PRStatus) PR_RmDir(const char *name)
  74. {
  75. PRInt32 rv;
  76.  
  77.     rv = _PR_MD_RMDIR(name);
  78.     if (rv < 0) {
  79.         return PR_FAILURE;
  80.     } else
  81.         return PR_SUCCESS;
  82. }
  83.  
  84.