Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / assignlock.c
blobcd9e42350ccae2a3d2e964d376b60af9848727c2
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create an assign.
6 Lang: English
7 */
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <dos/filesystem.h>
11 #include "dos_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH2(BOOL, AssignLock,
20 /* SYNOPSIS */
21 AROS_LHA(CONST_STRPTR, name, D1),
22 AROS_LHA(BPTR, lock, D2),
24 /* LOCATION */
25 struct DosLibrary *, DOSBase, 102, Dos)
27 /* FUNCTION
28 Create an assign from a given name to a lock. Replaces any older
29 assignments from that name, 0 cancels the assign completely. Do not
30 use or free the lock after calling this function - it becomes
31 the assign and will be freed by the system if the assign is removed.
33 INPUTS
34 name -- NUL terminated name of the assign.
35 lock -- Lock to 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
43 EXAMPLE
45 BUGS
47 SEE ALSO
49 INTERNALS
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
54 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
56 BOOL success = DOSTRUE;
58 struct DosList *dl, *newdl = NULL;
59 struct FileHandle *fh = (struct FileHandle *)BADDR(lock);
61 if (lock != NULL)
63 newdl = MakeDosEntry(name, DLT_DIRECTORY);
65 if (newdl == NULL)
67 return DOSFALSE;
70 newdl->dol_Unit = fh->fh_Unit;
71 newdl->dol_Device = fh->fh_Device;
72 newdl->dol_Lock = lock;
75 dl = LockDosList(LDF_ALL | LDF_WRITE);
76 dl = FindDosEntry(dl, name, LDF_ALL);
78 if (dl == NULL)
80 AddDosEntry(newdl);
82 else if (dl->dol_Type == DLT_DEVICE || dl->dol_Type == DLT_VOLUME)
84 dl = NULL;
85 FreeDosEntry(newdl);
86 SetIoErr(ERROR_OBJECT_EXISTS);
87 success = DOSFALSE;
89 else
91 RemDosEntry(dl);
93 AddDosEntry(newdl);
96 if (dl != NULL)
98 if (dl->dol_Lock)
100 UnLock(dl->dol_Lock);
103 if (dl->dol_misc.dol_assign.dol_List != NULL)
105 struct AssignList *al, *oal;
107 for (al = dl->dol_misc.dol_assign.dol_List; al; )
109 UnLock(al->al_Lock);
110 oal = al;
111 al = al->al_Next;
112 FreeVec(oal);
116 FreeVec(dl->dol_misc.dol_assign.dol_AssignName);
117 FreeDosEntry(dl);
120 UnLockDosList(LDF_ALL | LDF_WRITE);
122 return success;
124 AROS_LIBFUNC_EXIT
125 } /* AssignLock */