Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / examine.c
blob03e439c6f760b2c7dc32a119bde8216997ffc69f
1 /*
2 Copyright © 1995-2001, 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
94 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
96 UBYTE buffer[512];
97 struct ExAllData *ead=(struct ExAllData *)buffer;
98 STRPTR src, dst;
99 ULONG i;
101 /* Get pointer to filehandle */
102 struct FileHandle *fh = (struct FileHandle *)BADDR(lock);
104 /* Get pointer to I/O request. Use stackspace for now. */
105 struct IOFileSys iofs;
107 /* Prepare I/O request. */
108 InitIOFS(&iofs, FSA_EXAMINE, DOSBase);
110 iofs.IOFS.io_Device = fh->fh_Device;
111 iofs.IOFS.io_Unit = fh->fh_Unit;
113 iofs.io_Union.io_EXAMINE.io_ead = (struct ExAllData *)buffer;
114 iofs.io_Union.io_EXAMINE.io_Size = sizeof(buffer);
115 iofs.io_Union.io_EXAMINE.io_Mode = ED_OWNER;
117 /* Send the request. */
118 DosDoIO(&iofs.IOFS);
120 /* Set error code and return */
121 SetIoErr(iofs.io_DosError);
123 if(iofs.io_DosError)
124 return DOSFALSE;
125 else
127 /* in fib_DiskKey the result from telldir is being stored which
128 gives us important info for a call to ExNext() */
129 fib->fib_DiskKey = iofs.io_DirPos;
130 fib->fib_DirEntryType = ead->ed_Type;
132 src = ead->ed_Name;
133 dst = fib->fib_FileName;
135 if(src != NULL)
137 for(i = 0; i < MAXFILENAMELENGTH - 1; i++)
139 if(!(*dst++ = *src++))
140 break;
144 *dst++ = 0;
146 fib->fib_Protection = ead->ed_Prot;
147 fib->fib_EntryType = ead->ed_Type;
148 fib->fib_Size = ead->ed_Size;
149 fib->fib_Date.ds_Days = ead->ed_Days;
150 fib->fib_Date.ds_Minute = ead->ed_Mins;
151 fib->fib_Date.ds_Tick = ead->ed_Ticks;
153 src = ead->ed_Comment;
154 dst = fib->fib_Comment;
156 if(src != NULL)
158 for(i = 0; i < 79; i++)
160 if(!(*dst++ = *src++))
161 break;
165 *dst++ = 0;
166 fib->fib_OwnerUID = ead->ed_OwnerUID;
167 fib->fib_OwnerGID = ead->ed_OwnerGID;
169 return DOSTRUE;
172 AROS_LIBFUNC_EXIT
173 } /* Examine */