home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / diropen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-21  |  1.8 KB  |  77 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: diropen.c,v 1.5 1995/10/21 17:48:35 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    diropen.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    04 Jul 1984
  9.  * Last update:    25 Aug 1984, cleanup buffer sizes
  10.  *        23 Jul 1984, enhanced warning messages
  11.  *        15 Jul 1984, to provide 'diropen2' entrypoint.
  12.  *
  13.  * Function:    This procedure is used by FLIST to check that a directory
  14.  *        is both readable and writeable before attempting an operation
  15.  *        (such as EDIT or COPY) which would modify the directory.
  16.  *
  17.  * Parameters:    name_    => filespec containing, at least, the pathname of
  18.  *               the directory to check.  For example, if the
  19.  *               new file will be
  20.  *
  21.  *                DBC4:[DICKEY.C]DIROPEN.C
  22.  *
  23.  *               then the 'name_' string will include
  24.  *
  25.  *                DBC4:[DICKEY.C]
  26.  *
  27.  *               DIROPEN then translates this pathname into the
  28.  *               name of the directory file in the parent directory
  29.  *
  30.  *                DBC4:[DICKEY]C.DIR
  31.  *
  32.  *               and tests that it is writeable.
  33.  *
  34.  * Returns:    TRUE iff the directory can be modified.  If not, a warning
  35.  *        message is emitted via 'warn'.
  36.  */
  37.  
  38. #include    <rms.h>
  39.  
  40. #include    "bool.h"
  41. #include    "flist.h"    /* for 'error()' */
  42. #include    "dirent.h"
  43. #include    "getprot.h"
  44. #include    "pathup.h"
  45.  
  46. int    diropen (char *name_)
  47. {
  48.     GETPROT    prot;
  49.     char    parent    [MAX_PATH],
  50.         *msg    = 0;
  51.  
  52.     if (! pathup (parent, name_))
  53.         msg = "Illegal pathname";
  54.     else if (getprot (&prot, parent))
  55.         msg = "Cannot read directory";
  56.     else if (! cmpprot (&prot, "rw"))
  57.         msg = "Directory is not modifiable";
  58.  
  59.     if (msg)
  60.     {
  61.         warn ("%s: %s", msg, name_);
  62.         return (FALSE);
  63.     }
  64.     else
  65.         return (TRUE);
  66. }
  67.  
  68. /*
  69.  * Most of FLIST's calls on this module already have a specific 'filelist[]'
  70.  * entry which is being tested.  Use this entrypoint to hide knowledge of the
  71.  * relationship to 'pathlist'.
  72.  */
  73. int    diropen2 (FILENT *z)
  74. {
  75.     return (diropen ( zPATHOF(z) ));
  76. }
  77.