2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Create a late-binding (deferred) assign.
8 #include <exec/memory.h>
9 #include <proto/exec.h>
11 #include <dos/dosextens.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
17 #include <proto/dos.h>
19 AROS_LH2(BOOL
, AssignLate
,
22 AROS_LHA(CONST_STRPTR
, name
, D1
),
23 AROS_LHA(CONST_STRPTR
, path
, D2
),
26 struct DosLibrary
*, DOSBase
, 103, Dos
)
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.
36 name -- NULL terminated name of the assign.
37 path -- NULL terminated path to be resolved on the first reference.
40 != 0 success, 0 on failure. IoErr() gives additional information
50 Lock(), AssignAdd(), AssignPath(), AssignLock()
54 *****************************************************************************/
57 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
59 struct DosList
*dl
, *newdl
;
62 BOOL result
= DOSTRUE
;
66 newdl
= MakeDosEntry(name
, DLT_LATE
);
76 namelen
= s2
- path
+ 1;
77 pathcopy
= AllocVec(namelen
, MEMF_PUBLIC
| MEMF_CLEAR
);
82 SetIoErr(ERROR_NO_FREE_STORE
);
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
);
97 else if(dl
->dol_Type
== DLT_VOLUME
|| dl
->dol_Type
== DLT_DEVICE
)
100 FreeVec(newdl
->dol_misc
.dol_assign
.dol_AssignName
);
102 SetIoErr(ERROR_OBJECT_EXISTS
);
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
; )
128 FreeVec(dl
->dol_misc
.dol_assign
.dol_AssignName
);
132 UnLockDosList(LDF_ALL
| LDF_WRITE
);