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

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: examine.c,v 1.8 1997/01/27 00:36:18 ldp Exp $
  4.     $Log: examine.c,v $
  5.     Revision 1.8  1997/01/27 00:36:18  ldp
  6.     Polish
  7.  
  8.     Revision 1.7  1996/12/09 13:53:25  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.6  1996/10/24 15:50:27  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.5  1996/09/13 17:50:06  digulla
  17.     Use IPTR
  18.  
  19.     Revision 1.4  1996/08/13 13:52:45  digulla
  20.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  21.     Replaced AROS_LA by AROS_LHA
  22.  
  23.     Revision 1.3  1996/08/12 14:20:38  digulla
  24.     Added aliases
  25.  
  26.     Revision 1.2  1996/08/01 17:40:50  digulla
  27.     Added standard header for all files
  28.  
  29.     Desc:
  30.     Lang: english
  31. */
  32. #include <exec/memory.h>
  33. #include <proto/exec.h>
  34. #include <dos/filesystem.h>
  35. #include <dos/exall.h>
  36. #include "dos_intern.h"
  37.  
  38. /*****************************************************************************
  39.  
  40.     NAME */
  41. #include <proto/dos.h>
  42.  
  43.     AROS_LH2(BOOL, Examine,
  44.  
  45. /*  SYNOPSIS */
  46.     AROS_LHA(BPTR,                   lock, D1),
  47.     AROS_LHA(struct FileInfoBlock *, fib,  D2),
  48.  
  49. /*  LOCATION */
  50.     struct DosLibrary *, DOSBase, 17, Dos)
  51.  
  52. /*  FUNCTION
  53.  
  54.     INPUTS
  55.  
  56.     RESULT
  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. /*****************************************************************************
  75.  
  76.     NAME
  77. #include <clib/dos_protos.h>
  78.  
  79.     AROS_LH2(BOOL, ExamineFH,
  80.  
  81.     SYNOPSIS
  82.     AROS_LHA(BPTR                  , fh, D1),
  83.     AROS_LHA(struct FileInfoBlock *, fib, D2),
  84.  
  85.     LOCATION
  86.     struct DosLibrary *, DOSBase, 65, Dos)
  87.  
  88.     FUNCTION
  89.  
  90.     INPUTS
  91.  
  92.     RESULT
  93.  
  94.     NOTES
  95.  
  96.     EXAMPLE
  97.  
  98.     BUGS
  99.  
  100.     SEE ALSO
  101.  
  102.     INTERNALS
  103.  
  104.     HISTORY
  105.     29-10-95    digulla automatically created from
  106.                 dos_lib.fd and clib/dos_protos.h
  107.  
  108. *****************************************************************************/
  109. /*AROS alias ExamineFH Examine */
  110. {
  111.     AROS_LIBFUNC_INIT
  112.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  113.  
  114.     UBYTE buffer[512];
  115.     struct ExAllData *ead=(struct ExAllData *)buffer;
  116.     STRPTR src, dst;
  117.     ULONG i;
  118.  
  119.     /* Get pointer to filehandle */
  120.     struct FileHandle *fh=(struct FileHandle *)BADDR(lock);
  121.  
  122.     /* Get pointer to process structure */
  123.     struct Process *me=(struct Process *)FindTask(NULL);
  124.  
  125.     /* Get pointer to I/O request. Use stackspace for now. */
  126.     struct IOFileSys io,*iofs=&io;
  127.  
  128.     /* Prepare I/O request. */
  129.     iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
  130.     iofs->IOFS.io_Message.mn_ReplyPort     =&me->pr_MsgPort;
  131.     iofs->IOFS.io_Message.mn_Length     =sizeof(struct IOFileSys);
  132.     iofs->IOFS.io_Device =fh->fh_Device;
  133.     iofs->IOFS.io_Unit     =fh->fh_Unit;
  134.     iofs->IOFS.io_Command=FSA_EXAMINE;
  135.     iofs->IOFS.io_Flags  =0;
  136.     iofs->io_Args[0]=(IPTR)buffer;
  137.     iofs->io_Args[1]=512;
  138.     iofs->io_Args[2]=ED_OWNER;
  139.  
  140.     /* Send the request. */
  141.     DoIO(&iofs->IOFS);
  142.  
  143.     /* Set error code and return */
  144.     if((me->pr_Result2=iofs->io_DosError))
  145.     return 0;
  146.     else
  147.     {
  148.     fib->fib_DiskKey=0;
  149.     fib->fib_DirEntryType=ead->ed_Type;
  150.     src=ead->ed_Name;
  151.     dst=fib->fib_FileName;
  152.     if(src!=NULL)
  153.         for(i=0;i<107;i++)
  154.         if(!(*dst++=*src++))
  155.             break;
  156.     *dst++=0;
  157.     fib->fib_Protection=ead->ed_Prot^0xf;
  158.     fib->fib_EntryType=ead->ed_Type;
  159.     fib->fib_Size=ead->ed_Size;
  160.     fib->fib_Date.ds_Days=ead->ed_Days;
  161.     fib->fib_Date.ds_Minute=ead->ed_Mins;
  162.     fib->fib_Date.ds_Tick=ead->ed_Ticks;
  163.     src=ead->ed_Comment;
  164.     dst=fib->fib_Comment;
  165.     if(src!=NULL)
  166.         for(i=0;i<79;i++)
  167.         if(!(*dst++=*src++))
  168.             break;
  169.     *dst++=0;
  170.     fib->fib_OwnerUID=ead->ed_OwnerUID;
  171.     fib->fib_OwnerGID=ead->ed_OwnerGID;
  172.     return 1;
  173.     }
  174.  
  175.     AROS_LIBFUNC_EXIT
  176. } /* Examine */
  177.