2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Create an assign.
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <dos/filesystem.h>
11 #include "dos_intern.h"
13 /*****************************************************************************
16 #include <proto/dos.h>
18 AROS_LH2(BOOL
, AssignLock
,
21 AROS_LHA(CONST_STRPTR
, name
, D1
),
22 AROS_LHA(BPTR
, lock
, D2
),
25 struct DosLibrary
*, DOSBase
, 102, Dos
)
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.
34 name -- NUL terminated name of the assign.
35 lock -- Lock to assigned directory.
38 != 0 success, 0 on failure. IoErr() gives additional information
39 in that case. The lock is not freed on failure.
51 *****************************************************************************/
55 BOOL success
= DOSTRUE
;
57 struct DosList
*dl
, *newdl
= NULL
;
58 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(lock
);
62 newdl
= MakeDosEntry(name
, DLT_DIRECTORY
);
69 newdl
->dol_Ext
.dol_AROS
.dol_Unit
= fh
->fh_Unit
;
70 newdl
->dol_Ext
.dol_AROS
.dol_Device
= fh
->fh_Device
;
71 newdl
->dol_Lock
= lock
;
74 dl
= LockDosList(LDF_ALL
| LDF_WRITE
);
75 dl
= FindDosEntry(dl
, name
, LDF_ALL
);
81 else if (dl
->dol_Type
== DLT_DEVICE
|| dl
->dol_Type
== DLT_VOLUME
)
85 SetIoErr(ERROR_OBJECT_EXISTS
);
102 if (dl
->dol_misc
.dol_assign
.dol_List
!= NULL
)
104 struct AssignList
*al
, *oal
;
106 for (al
= dl
->dol_misc
.dol_assign
.dol_List
; al
; )
115 FreeVec(dl
->dol_misc
.dol_assign
.dol_AssignName
);
119 UnLockDosList(LDF_ALL
| LDF_WRITE
);