tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / dos / getcurrentdirname.c
blob7134e5c7be0f7f8bf451f50b73d140844b925b7d
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Get the name of the current directory.
6 Lang: english
7 */
8 #include <aros/debug.h>
10 #include <proto/exec.h>
11 #include <dos/dos.h>
12 #include "dos_intern.h"
13 #include <string.h>
15 /*****************************************************************************
17 NAME */
18 #include <proto/dos.h>
20 AROS_LH2(BOOL, GetCurrentDirName,
22 /* SYNOPSIS */
23 AROS_LHA(STRPTR, buf, D1),
24 AROS_LHA(LONG , len, D2),
26 /* LOCATION */
27 struct DosLibrary *, DOSBase, 94, Dos)
29 /* FUNCTION
30 Copies the name of the current directory from the CLI structure
31 into the buffer. If the buffer is too small the name is truncated,
32 and a failure is returned. If the current process doesn't have
33 a CLI structure, a 0 length string is put into the buffer and a
34 failure is returned.
36 INPUTS
37 buf - Buffer for the name.
38 len - Size of the buffer in bytes.
40 RESULT
41 !=0 on success, 0 on failure. IoErr() gives additional information
42 in that case.
44 NOTES
45 Documented as returning ERROR_OBJECT_WRONG_TYPE if CLI structure
46 is not present but actually it fallbacks to NameFromLock().
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 SetCurrentDirName()
55 INTERNALS
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct Process *me = (struct Process *)FindTask(NULL);
62 struct CommandLineInterface *cli;
63 STRPTR cname;
64 ULONG clen;
65 BOOL ret = DOSTRUE;
67 ASSERT_VALID_PROCESS(me);
69 cli = BADDR(me->pr_CLI);
70 if (cli == NULL)
71 return NameFromLock(me->pr_CurrentDir, buf, len);
73 cname = AROS_BSTR_ADDR(cli->cli_SetName);
74 clen = (ULONG)AROS_BSTR_strlen(cli->cli_SetName);
75 if (clen >= (len-1))
77 clen = len-1;
78 me->pr_Result2 = ERROR_LINE_TOO_LONG;
79 ret = DOSFALSE;
81 CopyMem(cname, buf, clen);
82 buf[clen] = '\0';
84 return ret;
85 AROS_LIBFUNC_EXIT
86 } /* GetCurrentDirName */