2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Retrieve the full pathname from a lock or a filehandle.
9 #include <proto/exec.h>
10 #include "dos_intern.h"
11 #include <proto/dos.h>
12 #include <aros/debug.h>
14 BOOL
namefrom_internal(struct DosLibrary
*DOSBase
, BPTR lock
, STRPTR buffer
, LONG length
)
18 BPTR parentlock
, origlock
;
19 struct FileInfoBlock
*fib
;
22 SIPTR code
= DOSFALSE
;
25 D(origbuffer
= buffer
);
26 D(bug("[DOS] namefrom_internal(0x%p, 0x%p, %d)\n", BADDR(lock
), buffer
, length
));
30 SetIoErr(ERROR_LINE_TOO_LONG
);
34 fib
= AllocDosObject(DOS_FIB
, 0);
37 SetIoErr(ERROR_NO_FREE_STORE
);
42 port
= ((struct FileLock
*)BADDR(lock
))->fl_Task
;
44 port
= DOSBase
->dl_Root
->rn_BootProc
;
47 /* Construct the name from top to bottom */
48 name
= buffer
+ length
;
57 error
= dopacket2(DOSBase
, NULL
, port
, ACTION_EXAMINE_OBJECT
, lock
, MKBADDR(fib
)) == 0;
58 //bug("name='%s'\n", fib->fib_FileName);
60 parentlock
= (BPTR
)dopacket1(DOSBase
, &code
, port
, ACTION_PARENT
, lock
);
61 if (!parentlock
&& !first
)
63 //bug("parentlock=%x\n", parentlock);
65 if (lock
!= origlock
&& lock
)
70 /* Move name to the top of the buffer. */
74 s1
= s2
= fib
->fib_FileName
;
89 error
= ERROR_LINE_TOO_LONG
;
100 error
= ERROR_LINE_TOO_LONG
;
108 if (name
- (s2
- s1
) >= buffer
)
117 error
= ERROR_LINE_TOO_LONG
;
125 while(!error
&& parentlock
);
127 /* Move the name from the top to the bottom of the buffer. */
128 if ((!error
) && (name
!= buffer
))
130 UBYTE c
, old_c
= '\0';
136 if ((c
!= '/') || (old_c
!= ':'))
147 FreeDosObject(DOS_FIB
, fib
);
153 D(bug("[NameFromX]='%s':%d\n", origbuffer
, error
));