home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / createdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.7 KB  |  109 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: createdir.c,v 1.5 1997/01/27 00:36:15 ldp Exp $
  4.     $Log: createdir.c,v $
  5.     Revision 1.5  1997/01/27 00:36:15  ldp
  6.     Polish
  7.  
  8.     Revision 1.4  1996/12/09 13:53:23  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.3  1996/10/24 15:50:25  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.2  1996/09/21 14:14:22  digulla
  17.     Hand DOSBase to DoName()
  18.  
  19.     Revision 1.1  1996/09/11 12:54:45  digulla
  20.     A couple of new DOS functions from M. Fleischer
  21.  
  22.     Desc:
  23.     Lang: english
  24. */
  25. #include <exec/memory.h>
  26. #include <proto/exec.h>
  27. #include <utility/tagitem.h>
  28. #include <dos/dos.h>
  29. #include <dos/filesystem.h>
  30. #include <proto/dos.h>
  31. #include <proto/utility.h>
  32. #include "dos_intern.h"
  33.  
  34. /*****************************************************************************
  35.  
  36.     NAME */
  37. #include <proto/dos.h>
  38.  
  39.     AROS_LH1(BPTR, CreateDir,
  40.  
  41. /*  SYNOPSIS */
  42.     AROS_LHA(STRPTR, name, D1),
  43.  
  44. /*  LOCATION */
  45.     struct DosLibrary *, DOSBase, 20, Dos)
  46.  
  47. /*  FUNCTION
  48.     Creates a new directory under the given name. If all went an
  49.     exclusive lock on the new diretory is returned.
  50.  
  51.     INPUTS
  52.     name       - NUL terminated name.
  53.  
  54.     RESULT
  55.     Exclusive lock to the new directory or 0 if couldn't be created.
  56.     IoErr() gives additional information in that case.
  57.  
  58.     NOTES
  59.  
  60.     EXAMPLE
  61.  
  62.     BUGS
  63.  
  64.     SEE ALSO
  65.  
  66.     INTERNALS
  67.  
  68.     HISTORY
  69.     29-10-95    digulla automatically created from
  70.                 dos_lib.fd and clib/dos_protos.h
  71.  
  72. *****************************************************************************/
  73. {
  74.     AROS_LIBFUNC_INIT
  75.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  76.  
  77.     struct FileHandle *ret;
  78.  
  79.     /* Get pointer to process structure */
  80.     struct Process *me=(struct Process *)FindTask(NULL);
  81.  
  82.     /* Get pointer to I/O request. Use stackspace for now. */
  83.     struct IOFileSys io,*iofs=&io;
  84.  
  85.     /* Allocate memory for lock */
  86.     ret=(struct FileHandle *)AllocDosObject(DOS_FILEHANDLE,NULL);
  87.     if(ret!=NULL)
  88.     {
  89.     /* Prepare I/O request. */
  90.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  91.     iofs->IOFS.io_Message.mn_ReplyPort   =&me->pr_MsgPort;
  92.     iofs->IOFS.io_Message.mn_Length      =sizeof(struct IOFileSys);
  93.     iofs->IOFS.io_Flags=0;
  94.     iofs->IOFS.io_Command=FSA_CREATE_DIR;
  95.     /* io_Args[0] is the name which is set by DoName(). */
  96.     iofs->io_Args[1]=FIBF_READ|FIBF_WRITE|FIBF_EXECUTE|FIBF_DELETE;
  97.     if(!DoName(iofs,name,DOSBase))
  98.     {
  99.         ret->fh_Unit  =iofs->IOFS.io_Unit;
  100.         ret->fh_Device=iofs->IOFS.io_Device;
  101.         return MKBADDR(ret);
  102.     }
  103.     FreeDosObject(DOS_FILEHANDLE,ret);
  104.     }else
  105.     me->pr_Result2=ERROR_NO_FREE_STORE;
  106.     return 0;
  107.     AROS_LIBFUNC_EXIT
  108. } /* CreateDir */
  109.