Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / assignpath.c
blobe37ad6d83eeee50d32a559ee6d04b75c9f3df6c8
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Create a non-binding (path) 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, AssignPath,
21 /* SYNOPSIS */
22 AROS_LHA(CONST_STRPTR, name, D1),
23 AROS_LHA(CONST_STRPTR, path, D2),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 104, Dos)
28 /* FUNCTION
29 Create an assign for the given name, which will be resolved upon
30 each reference to it. There will be no permanent lock kept on the
31 specified path. This way you can create assigns to unmounted volumes
32 which will only be requested when accessed. Also, using AssignPath()
33 to assign C: to df0:c would make references go to to df0:c even if
34 you change the disk.
36 INPUTS
37 name -- NULL terminated name of the assign.
38 path -- NULL terminated path to be resolved on each reference.
40 RESULT
41 != 0 in case of success, 0 on failure. IoErr() gives additional
42 information in that case.
44 NOTES
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 AssignAdd(), AssignLock(), AssignLate(), Open()
53 INTERNALS
55 *****************************************************************************/
57 AROS_LIBFUNC_INIT
58 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
60 CONST_STRPTR s2;
61 struct DosList *dl, *newdl;
63 BOOL result = DOSTRUE;
64 STRPTR pathcopy;
65 ULONG namelen;
67 newdl = MakeDosEntry(name, DLT_NONBINDING);
69 if(newdl == NULL)
70 return DOSFALSE;
72 s2 = path;
74 while(*s2++)
77 namelen = s2 - path + 1;
78 pathcopy = AllocVec(namelen, MEMF_PUBLIC | MEMF_CLEAR);
80 if(pathcopy == NULL)
82 FreeDosEntry(newdl);
83 SetIoErr(ERROR_NO_FREE_STORE);
85 return DOSFALSE;
88 CopyMem(path, pathcopy, namelen);
89 newdl->dol_misc.dol_assign.dol_AssignName = pathcopy;
91 dl = LockDosList(LDF_ALL | LDF_WRITE);
92 dl = FindDosEntry(dl, name, LDF_ALL);
94 if(dl == NULL)
96 AddDosEntry(newdl);
98 else if(dl->dol_Type == DLT_VOLUME || dl->dol_Type == DLT_DEVICE)
100 dl = NULL;
101 FreeVec(newdl->dol_misc.dol_assign.dol_AssignName);
102 FreeDosEntry(newdl);
103 SetIoErr(ERROR_OBJECT_EXISTS);
105 result = DOSFALSE;
107 else
109 RemDosEntry(dl);
110 AddDosEntry(newdl);
113 if(dl != NULL)
115 UnLock(dl->dol_Lock);
117 if(dl->dol_misc.dol_assign.dol_List != NULL)
119 struct AssignList *al, *oal;
121 for(al = dl->dol_misc.dol_assign.dol_List; al; )
123 UnLock(al->al_Lock);
124 oal = al;
125 al = al->al_Next;
126 FreeVec(oal);
130 FreeVec(dl->dol_misc.dol_assign.dol_AssignName);
131 FreeDosEntry(dl);
134 UnLockDosList(LDF_ALL | LDF_WRITE);
136 return result;
138 AROS_LIBFUNC_EXIT
139 } /* AssignPath */