home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / library / rcs / mkdir.c,v < prev    next >
Encoding:
Text File  |  1992-07-04  |  1.9 KB  |  93 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @ *  @;
  7.  
  8.  
  9. 1.1
  10. date    92.05.14.19.55.40;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @create directory
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/*
  26.  *  This file is part of ixemul.library for the Amiga.
  27.  *  Copyright (C) 1991, 1992  Markus M. Wild
  28.  *
  29.  *  This library is free software; you can redistribute it and/or
  30.  *  modify it under the terms of the GNU Library General Public
  31.  *  License as published by the Free Software Foundation; either
  32.  *  version 2 of the License, or (at your option) any later version.
  33.  *
  34.  *  This library is distributed in the hope that it will be useful,
  35.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  36.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  37.  *  Library General Public License for more details.
  38.  *
  39.  *  You should have received a copy of the GNU Library General Public
  40.  *  License along with this library; if not, write to the Free
  41.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  42.  *
  43.  *  $Id$
  44.  *
  45.  *  $Log$
  46.  */
  47.  
  48. #define KERNEL
  49. #include "ixemul.h"
  50.  
  51. static int
  52. __mkdir_func (struct StandardPacket *sp, struct MsgPort *handler,
  53.               BPTR parent_lock,
  54.           BSTR name,
  55.           void *dummy, int *no_error)
  56. {
  57.   sp->sp_Pkt.dp_Type = ACTION_CREATE_DIR;
  58.   sp->sp_Pkt.dp_Arg1 = parent_lock;
  59.   sp->sp_Pkt.dp_Arg2 = name;
  60.  
  61.   PutPacket (handler, sp);
  62.   __wait_sync_packet (sp);
  63.  
  64.   *no_error = sp->sp_Pkt.dp_Res1 == -1;
  65.     
  66.   /* continue if we failed because of symlink - reference */
  67.   return 1;
  68. }
  69.  
  70.  
  71. int
  72. mkdir (char *path, int perm)
  73. {
  74.   BPTR lock;
  75.   int result = -1;
  76.   int omask;
  77.  
  78.   /* protect the obtained lock, we have to free it later */
  79.   omask = syscall (SYS_sigsetmask, ~0);  
  80.   lock = __plock (path, __mkdir_func, 0);
  81.  
  82.   if (lock)
  83.     {
  84.       __unlock (lock);
  85.       result = syscall (SYS_chmod, path, perm);
  86.     }
  87.   syscall (SYS_sigsetmask, omask);
  88.  
  89.   errno = __ioerr_to_errno (IoErr ());
  90.   return result;
  91. }
  92. @
  93.