Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / dos / examine.c
blob37bf4fdd5f5698d4424f73ae2ed8ed84ef8d7685
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: dos.library function Examine().
6 Lang: English
7 */
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <dos/filesystem.h>
11 #include <dos/exall.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/dos.h>
19 AROS_LH2(BOOL, Examine,
21 /* SYNOPSIS */
22 AROS_LHA(BPTR, lock, D1),
23 AROS_LHA(struct FileInfoBlock *, fib, D2),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 17, Dos)
28 /* FUNCTION
30 Fill in a FileInfoBlock structure concerning a file or directory
31 associated with a particular lock.
33 INPUTS
35 lock -- lock to examine
36 fib -- FileInfoBlock where the result of the examination is stored
38 RESULT
40 A boolean telling whether the operation was successful or not.
42 NOTES
44 FileInfoBlocks should be allocated with AllocDosObject(). You may make
45 a copy of the FileInfoBlock but, however, this copy may NOT be passed
46 to ExNext()!
48 EXAMPLE
50 BUGS
52 SEE ALSO
54 Lock(), UnLock(), ExNext(), AllocDosObject(), ExAll(), <dos/dos.h>
56 INTERNALS
58 *****************************************************************************/
60 /*****************************************************************************
62 NAME
63 #include <clib/dos_protos.h>
65 AROS_LH2(BOOL, ExamineFH,
67 SYNOPSIS
68 AROS_LHA(BPTR , fh, D1),
69 AROS_LHA(struct FileInfoBlock *, fib, D2),
71 LOCATION
72 struct DosLibrary *, DOSBase, 65, Dos)
74 FUNCTION
76 INPUTS
78 RESULT
80 NOTES
82 EXAMPLE
84 BUGS
86 SEE ALSO
88 INTERNALS
90 *****************************************************************************/
91 /*AROS alias ExamineFH Examine */
93 AROS_LIBFUNC_INIT
95 UBYTE buffer[512];
96 struct ExAllData *ead=(struct ExAllData *)buffer;
97 STRPTR src, dst;
98 ULONG i;
100 /* Get pointer to filehandle */
101 struct FileHandle *fh = (struct FileHandle *)BADDR(lock);
103 /* Get pointer to I/O request. Use stackspace for now. */
104 struct IOFileSys iofs;
106 /* Prepare I/O request. */
107 InitIOFS(&iofs, FSA_EXAMINE, DOSBase);
109 iofs.IOFS.io_Device = fh->fh_Device;
110 iofs.IOFS.io_Unit = fh->fh_Unit;
112 iofs.io_Union.io_EXAMINE.io_ead = (struct ExAllData *)buffer;
113 iofs.io_Union.io_EXAMINE.io_Size = sizeof(buffer);
114 iofs.io_Union.io_EXAMINE.io_Mode = ED_OWNER;
116 /* Send the request. */
117 DosDoIO(&iofs.IOFS);
119 /* Set error code and return */
120 SetIoErr(iofs.io_DosError);
122 if(iofs.io_DosError)
123 return DOSFALSE;
124 else
126 /* in fib_DiskKey the result from telldir is being stored which
127 gives us important info for a call to ExNext() */
128 fib->fib_DiskKey = iofs.io_DirPos;
129 fib->fib_DirEntryType = ead->ed_Type;
131 src = ead->ed_Name;
132 dst = fib->fib_FileName;
134 if(src != NULL)
136 for(i = 0; i < MAXFILENAMELENGTH - 1; i++)
138 if(!(*dst++ = *src++))
139 break;
143 *dst++ = 0;
145 fib->fib_Protection = ead->ed_Prot;
146 fib->fib_EntryType = ead->ed_Type;
147 fib->fib_Size = ead->ed_Size;
148 fib->fib_Date.ds_Days = ead->ed_Days;
149 fib->fib_Date.ds_Minute = ead->ed_Mins;
150 fib->fib_Date.ds_Tick = ead->ed_Ticks;
152 src = ead->ed_Comment;
153 dst = fib->fib_Comment;
155 if(src != NULL)
157 for(i = 0; i < 79; i++)
159 if(!(*dst++ = *src++))
160 break;
164 *dst++ = 0;
165 fib->fib_OwnerUID = ead->ed_OwnerUID;
166 fib->fib_OwnerGID = ead->ed_OwnerGID;
168 return DOSTRUE;
171 AROS_LIBFUNC_EXIT
172 } /* Examine */