Fixed a typo.
[AROS.git] / rom / dos / namefromfh.c
blob950f030245cc7e73d6bc3712f3c0ddfc256569ca
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Retrieve the full pathname from a filehandle.
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include "dos_intern.h"
11 #include <aros/debug.h>
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH3(BOOL, NameFromFH,
20 /* SYNOPSIS */
21 AROS_LHA(BPTR, fh , D1),
22 AROS_LHA(STRPTR, buffer, D2),
23 AROS_LHA(LONG, length, D3),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 68, Dos)
29 FUNCTION
30 Get the full path name associated with file-handle into a
31 user supplied buffer.
33 INPUTS
34 fh - File-handle to file or directory.
35 buffer - Buffer to fill. Contains a NUL terminated string if
36 all went well.
37 length - Size of the buffer in bytes.
39 RESULT
40 !=0 if all went well, 0 in case of an error. IoErr() will
41 give additional information in that case.
43 *****************************************************************************/
45 AROS_LIBFUNC_INIT
47 BOOL res = FALSE;
48 struct FileInfoBlock *fib;
49 BPTR parentlock = BNULL;
50 ULONG err = 0;
52 /* DupLock() calls are not allowed because they fail
53 * if FH has exclusive lock (MODE_NEWFILE)
56 fib = AllocDosObject(DOS_FIB, NULL);
57 if (fib) {
58 parentlock = ParentOfFH(fh);
59 if (parentlock) {
60 if (NameFromLock(parentlock, buffer, length)) {
61 if (ExamineFH(fh, fib)) {
62 if (AddPart(buffer, fib->fib_FileName, length)) {
63 res = TRUE;
68 err = IoErr(); /* UnLock() clears pr_Result2 */
69 FreeDosObject(DOS_FIB, fib);
70 } else {
71 err = ERROR_NO_FREE_STORE;
74 if (parentlock)
75 UnLock(parentlock);
77 SetIoErr(err);
78 return res;
80 AROS_LIBFUNC_EXIT