6 #include <exec/types.h>
7 #include <exec/memory.h>
8 #include <workbench/icon.h>
9 #include <workbench/workbench.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
15 #include <proto/icon.h>
16 #include <proto/intuition.h>
17 #include <proto/iconobject.h>
18 #include <proto/utility.h>
20 #include <proto/scalos.h>
22 #include <clib/alib_protos.h>
25 #include <datatypes/iconobject.h>
26 #include <scalos/scalos.h>
35 #include "scalos_structures.h"
36 #include "functions.h"
37 #include "Variables.h"
39 //-------------------------------------------------------------------------
41 static Object
*ReadIconObject(CONST_STRPTR Path
);
42 static Object
*ReadIconObject_NoFail(CONST_STRPTR Path
);
44 //-------------------------------------------------------------------------
46 struct ScaWindowStruct
*OpenDrawerByName(CONST_STRPTR Path
, struct TagItem
*TagList
)
48 struct ScaWindowStruct
*Result
= NULL
;
50 Object
*AllocIconObj
= NULL
;
51 struct SM_StartWindow
*StartWindowMsg
= NULL
;
53 d1(KPrintF("%s/%s/%ld: Path=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, Path
));
56 // special treatment for Volumes/Devices : look for "VOLNAME:disk.info"
57 size_t len
= strlen(Path
);
59 if (':' == Path
[len
- 1])
61 d1(KPrintF("%s/%s/%ld: open device window Path=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, Path
));
62 SCA_OpenIconWindowTags(
63 SCA_Path
, (ULONG
) Path
,
64 SCA_CheckOverlappingIcons
, CurrentPrefs
.pref_CheckOverlappingIcons
,
65 TAG_MORE
, (ULONG
) TagList
,
71 iconObj
= AllocIconObj
= ReadIconObject(Path
);
73 d1(KPrintF("%s/%s/%ld: iconObj=%08lx Path=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
, Path
));
77 iconObj
= AllocIconObj
= ReadIconObject_NoFail(Path
);
83 IDTA_Flags
, DDFLAGS_SHOWALL
,
87 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
92 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));
94 SCA_OpenIconWindowTags(
95 SCA_CheckOverlappingIcons
, CurrentPrefs
.pref_CheckOverlappingIcons
,
96 SCA_IconObject
, (ULONG
) iconObj
,
97 SCA_WindowStruct
, (ULONG
) &Result
,
98 TAG_MORE
, (ULONG
) TagList
,
105 SCA_FreeMessage(&StartWindowMsg
->ScalosMessage
);
107 DisposeIconObject(AllocIconObj
);
109 d1(KPrintF("%s/%s/%ld: Result=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, Result
));
115 static Object
*ReadIconObject(CONST_STRPTR Path
)
120 FullPath
= AllocPathBuffer();
123 // change path names like "Download:" to a fully qualified name
124 BPTR doLock
= Lock((STRPTR
) Path
, ACCESS_READ
);
126 d1(kprintf("%s/%s/%ld doLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, doLock
));
130 if (NameFromLock(doLock
, FullPath
, Max_PathLen
))
137 d1(kprintf("%s/%s/%ld Path=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, Path
));
139 iconObj
= ReadIconObject_NoFail(Path
);
142 FreePathBuffer(FullPath
);
148 static Object
*ReadIconObject_NoFail(CONST_STRPTR Path
)
152 iconObj
= NewIconObject(Path
, NULL
);
155 struct WBArg OriginalLocation
;
157 BPTR parentLock
= (BPTR
)NULL
;
159 d1(kprintf("%s/%s/%ld Path=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, Path
));
162 dirLock
= Lock(Path
, ACCESS_READ
);
163 d1(kprintf("%s/%s/%ld dirLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, dirLock
));
164 if ((BPTR
)NULL
== dirLock
)
167 parentLock
= ParentDir(dirLock
);
168 d1(kprintf("%s/%s/%ld parentLock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, parentLock
));
171 OriginalLocation
.wa_Lock
= parentLock
;
172 OriginalLocation
.wa_Name
= (STRPTR
) FilePart(Path
);
176 OriginalLocation
.wa_Lock
= (BPTR
)NULL
;
177 OriginalLocation
.wa_Name
= (STRPTR
) Path
;
180 d1(kprintf("%s/%s/%ld wa_Lock=%08lx wa_Name=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, OriginalLocation
.wa_Lock
, OriginalLocation
.wa_Name
));
182 iconObj
= GetDefIconObjectTags(WBDRAWER
,
183 IDTA_IconLocation
, (ULONG
) &OriginalLocation
,
184 DTA_Name
, (ULONG
) Path
,
187 d1(kprintf("%s/%s/%ld iconObj=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iconObj
));