Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / assignlate.c
blobe98aab65f5dfeb9495ce56cf1e24ee6fb493ff3c
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a late-binding (deferred) 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, AssignLate,
21 /* SYNOPSIS */
22 AROS_LHA(CONST_STRPTR, name, D1),
23 AROS_LHA(CONST_STRPTR, path, D2),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 103, Dos)
28 /* FUNCTION
29 Create an assign for the given name, which will be resolved upon the
30 first reference to it. If this succeeds (i.e. the path exists and
31 can be locked) it will be turned into an AssignLock() type assign.
32 This way you can create assigns to unmounted volumes which will only
33 be requested when accessed.
35 INPUTS
36 name -- NULL terminated name of the assign.
37 path -- NULL terminated path to be resolved on the first reference.
39 RESULT
40 != 0 success, 0 on failure. IoErr() gives additional information
41 in that case.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 Lock(), AssignAdd(), AssignPath(), AssignLock()
52 INTERNALS
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
57 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
59 struct DosList *dl, *newdl;
60 CONST_STRPTR s2;
62 BOOL result = DOSTRUE;
63 STRPTR pathcopy;
64 ULONG namelen;
66 newdl = MakeDosEntry(name, DLT_LATE);
68 if (newdl == NULL)
69 return DOSFALSE;
71 s2 = path;
73 while(*s2++)
76 namelen = s2 - path + 1;
77 pathcopy = AllocVec(namelen, MEMF_PUBLIC | MEMF_CLEAR);
79 if(pathcopy == NULL)
81 FreeDosEntry(newdl);
82 SetIoErr(ERROR_NO_FREE_STORE);
84 return DOSFALSE;
87 CopyMem(path, pathcopy, namelen);
88 newdl->dol_misc.dol_assign.dol_AssignName = pathcopy;
90 dl = LockDosList(LDF_ALL | LDF_WRITE);
91 dl = FindDosEntry(dl, name, LDF_ALL);
93 if(dl == NULL)
95 AddDosEntry(newdl);
97 else if(dl->dol_Type == DLT_VOLUME || dl->dol_Type == DLT_DEVICE)
99 dl = NULL;
100 FreeVec(newdl->dol_misc.dol_assign.dol_AssignName);
101 FreeDosEntry(newdl);
102 SetIoErr(ERROR_OBJECT_EXISTS);
103 result = DOSFALSE;
105 else
107 RemDosEntry(dl);
108 AddDosEntry(newdl);
111 if(dl != NULL)
113 UnLock(dl->dol_Lock);
115 if(dl->dol_misc.dol_assign.dol_List != NULL)
117 struct AssignList *al, *oal;
119 for(al = dl->dol_misc.dol_assign.dol_List; al; )
121 UnLock(al->al_Lock);
122 oal = al;
123 al = al->al_Next;
124 FreeVec(oal);
128 FreeVec(dl->dol_misc.dol_assign.dol_AssignName);
129 FreeDosEntry(dl);
132 UnLockDosList(LDF_ALL | LDF_WRITE);
134 return result;
136 AROS_LIBFUNC_EXIT
137 } /* AssignLate */