Indentation fix, cleanup.
[AROS.git] / rom / dos / assignadd.c
blob3fe15b2f421cb97ec91b5eecbb98253ab589e84d
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a directory to an assign.
6 Lang: English
7 */
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <dos/dos.h>
11 #include <dos/dosextens.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/dos.h>
19 AROS_LH2(BOOL, AssignAdd,
21 /* SYNOPSIS */
22 AROS_LHA(CONST_STRPTR, name, D1),
23 AROS_LHA(BPTR , lock, D2),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 105, Dos)
28 /* FUNCTION
29 Create a multi-directory assign, or adds to it if it already was one.
30 Do not use or free the lock after calling this function - it becomes
31 the assign and will be freed by the system when the assign is removed.
33 INPUTS
34 name - NULL terminated name of the assign.
35 lock - Lock on the assigned directory.
37 RESULT
38 != 0 success, 0 on failure. IoErr() gives additional information
39 in that case. The lock is not freed on failure.
41 NOTES
42 This will only work with an assign created with AssignLock() or
43 a resolved AssignLate() assign.
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 Lock(), AssignLock(), AssignPath(), AssignLate(), DupLock(),
51 RemAssignList()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
58 struct DosList *dl;
59 struct AssignList **al, *newal;
61 if(lock == BNULL)
62 return DOSFALSE;
64 dl = LockDosList(LDF_ASSIGNS | LDF_WRITE);
65 dl = FindDosEntry(dl, name, LDF_ASSIGNS);
67 if((dl == NULL) || (dl->dol_Type != DLT_DIRECTORY))
69 UnLockDosList(LDF_ASSIGNS | LDF_WRITE);
70 SetIoErr(ERROR_OBJECT_WRONG_TYPE);
72 return DOSFALSE;
75 newal = AllocVec(sizeof(struct AssignList), MEMF_PUBLIC | MEMF_CLEAR);
77 if(newal == NULL)
79 UnLockDosList(LDF_ASSIGNS | LDF_WRITE);
80 SetIoErr(ERROR_NO_FREE_STORE);
82 return DOSFALSE;
85 newal->al_Lock = lock;
87 for(al = &dl->dol_misc.dol_assign.dol_List; *al; al = &((*al)->al_Next));
89 *al = newal;
90 UnLockDosList(LDF_ASSIGNS | LDF_WRITE);
92 return DOSTRUE;
94 AROS_LIBFUNC_EXIT
95 } /* AssignAdd */