1 | Index: configure
|
---|
2 | ===================================================================
|
---|
3 | --- configure (revision 21685)
|
---|
4 | +++ configure (working copy)
|
---|
5 | @@ -760,8 +760,8 @@
|
---|
6 | type_1_byte='char'
|
---|
7 | type_2_byte='short'
|
---|
8 | type_4_byte='long'
|
---|
9 | - CXXFLAGS="$CFLAGS -newlib -mstrict-align -mcpu=750 -mtune=7400"
|
---|
10 | - LDFLAGS="$LDFLAGS -newlib"
|
---|
11 | + CXXFLAGS="$CFLAGS -mcrt=newlib -mstrict-align -mcpu=750 -mtune=7400"
|
---|
12 | + LDFLAGS="$LDFLAGS -mcrt=newlib"
|
---|
13 | ;;
|
---|
14 | *)
|
---|
15 | echo "Cross-compiling to unknown target $_host, please add your target to configure."
|
---|
16 | Index: common/util.h
|
---|
17 | ===================================================================
|
---|
18 | --- common/util.h (revision 21685)
|
---|
19 | +++ common/util.h (working copy)
|
---|
20 | @@ -26,7 +26,7 @@
|
---|
21 | #include "common/str.h"
|
---|
22 | #include "common/array.h"
|
---|
23 |
|
---|
24 | -#if defined (__INNOTEK_LIBC__)
|
---|
25 | +#if defined (__INNOTEK_LIBC__) || (defined (__amigaos4__) && defined(__NEWLIB__))
|
---|
26 | #undef MIN
|
---|
27 | #undef MAX
|
---|
28 | #endif
|
---|
29 | Index: common/scummsys.h
|
---|
30 | ===================================================================
|
---|
31 | --- common/scummsys.h (revision 21685)
|
---|
32 | +++ common/scummsys.h (working copy)
|
---|
33 | @@ -298,7 +298,7 @@
|
---|
34 | // are not compatible with our typedefs below, we need a proper fix.
|
---|
35 | // In general, though, you should avoid port specific includes in this
|
---|
36 | // header file, if possible.
|
---|
37 | - #include <exec/types.h>
|
---|
38 | + //#include <exec/types.h>
|
---|
39 |
|
---|
40 | #elif defined(__SYMBIAN32__)
|
---|
41 |
|
---|
42 | Index: backends/fs/amigaos4/amigaos4-fs.cpp
|
---|
43 | ===================================================================
|
---|
44 | --- backends/fs/amigaos4/amigaos4-fs.cpp (revision 21685)
|
---|
45 | +++ backends/fs/amigaos4/amigaos4-fs.cpp (working copy)
|
---|
46 | @@ -34,7 +34,7 @@
|
---|
47 |
|
---|
48 | #include <common/stdafx.h>
|
---|
49 |
|
---|
50 | -//#include "util.h"
|
---|
51 | +#include "common/util.h"
|
---|
52 |
|
---|
53 | #include "base/engine.h"
|
---|
54 | #include "backends/fs/fs.h"
|
---|
55 | @@ -43,7 +43,7 @@
|
---|
56 | #define LEAVE() /* debug(6, "Leave\n") */
|
---|
57 |
|
---|
58 |
|
---|
59 | -const uint32 ExAllBufferSize = 40960;
|
---|
60 | +const uint32 kExAllBufferSize = 40960; // TODO: is this okay for sure?
|
---|
61 |
|
---|
62 | class AmigaOSFilesystemNode : public AbstractFilesystemNode {
|
---|
63 | protected:
|
---|
64 | @@ -58,7 +58,10 @@
|
---|
65 | AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
|
---|
66 | AmigaOSFilesystemNode(const String &p);
|
---|
67 |
|
---|
68 | - ~AmigaOSFilesystemNode();
|
---|
69 | + // Note: Copy constructor is needed because it duplicates the file lock
|
---|
70 | + AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
|
---|
71 | +
|
---|
72 | + virtual ~AmigaOSFilesystemNode();
|
---|
73 |
|
---|
74 | virtual String displayName() const { return _sDisplayName; };
|
---|
75 | virtual bool isValid() const { return _bIsValid; };
|
---|
76 | @@ -111,11 +114,13 @@
|
---|
77 |
|
---|
78 | _sDisplayName = String(str + offset, len);
|
---|
79 |
|
---|
80 | + _pFileLock = 0;
|
---|
81 | +
|
---|
82 | // Check whether it is a directory, and whether the file actually exists
|
---|
83 |
|
---|
84 | struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
|
---|
85 | if (!fib) {
|
---|
86 | - //debug(6, "fib == 0\n");
|
---|
87 | + debug(6, "fib == 0\n");
|
---|
88 | LEAVE();
|
---|
89 | return;
|
---|
90 | }
|
---|
91 | @@ -145,12 +150,12 @@
|
---|
92 |
|
---|
93 | AmigaOSFilesystemNode::AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName) {
|
---|
94 | ENTER();
|
---|
95 | - int bufsize = 256;
|
---|
96 | + int bufSize = MAXPATHLEN;
|
---|
97 | _pFileLock = 0;
|
---|
98 |
|
---|
99 | while (1) {
|
---|
100 | - char *name = new char[bufsize];
|
---|
101 | - if (IDOS->NameFromLock(pLock, name, bufsize) != DOSFALSE) {
|
---|
102 | + char *name = new char[bufSize];
|
---|
103 | + if (IDOS->NameFromLock(pLock, name, bufSize) != DOSFALSE) {
|
---|
104 | _sPath = name;
|
---|
105 | _sDisplayName = pDisplayName ? pDisplayName : IDOS->FilePart(name);
|
---|
106 | delete [] name;
|
---|
107 | @@ -159,12 +164,12 @@
|
---|
108 |
|
---|
109 | if (IDOS->IoErr() != ERROR_LINE_TOO_LONG) {
|
---|
110 | _bIsValid = false;
|
---|
111 | - //debug(6, "Error\n");
|
---|
112 | + debug(6, "Error\n");
|
---|
113 | LEAVE();
|
---|
114 | delete [] name;
|
---|
115 | return;
|
---|
116 | }
|
---|
117 | - bufsize *= 2;
|
---|
118 | + bufSize *= 2;
|
---|
119 | delete [] name;
|
---|
120 | }
|
---|
121 |
|
---|
122 | @@ -172,7 +177,7 @@
|
---|
123 |
|
---|
124 | struct FileInfoBlock *fib = (struct FileInfoBlock *)IDOS->AllocDosObject(DOS_FIB, NULL);
|
---|
125 | if (!fib) {
|
---|
126 | - //debug(6, "fib == 0\n");
|
---|
127 | + debug(6, "fib == 0\n");
|
---|
128 | LEAVE();
|
---|
129 | return;
|
---|
130 | }
|
---|
131 | @@ -197,13 +202,14 @@
|
---|
132 | LEAVE();
|
---|
133 | }
|
---|
134 |
|
---|
135 | -AmigaOSFilesystemNode::AmigaOSFilesystemNode(const AmigaOSFilesystemNode *node) {
|
---|
136 | +// We need the custom copy constructor because of DupLock()
|
---|
137 | +AmigaOSFilesystemNode::AmigaOSFilesystemNode(const AmigaOSFilesystemNode& node) {
|
---|
138 | ENTER();
|
---|
139 | - _sDisplayName = node->_sDisplayName;
|
---|
140 | - _bIsValid = node->_bIsValid;
|
---|
141 | - _bIsDirectory = node->_bIsDirectory;
|
---|
142 | - _sPath = node->_sPath;
|
---|
143 | - _pFileLock = IDOS->DupLock(node->_pFileLock);
|
---|
144 | + _sDisplayName = node._sDisplayName;
|
---|
145 | + _bIsValid = node._bIsValid;
|
---|
146 | + _bIsDirectory = node._bIsDirectory;
|
---|
147 | + _sPath = node._sPath;
|
---|
148 | + _pFileLock = IDOS->DupLock(node._pFileLock);
|
---|
149 | LEAVE();
|
---|
150 | }
|
---|
151 |
|
---|
152 | @@ -217,39 +223,36 @@
|
---|
153 | FSList AmigaOSFilesystemNode::listDir(ListMode mode) const {
|
---|
154 | ENTER();
|
---|
155 |
|
---|
156 | + FSList myList;
|
---|
157 | +
|
---|
158 | if (!_bIsValid) {
|
---|
159 | - //debug(6, "Invalid node\n");
|
---|
160 | + debug(6, "Invalid node\n");
|
---|
161 | LEAVE();
|
---|
162 | - //return 0;
|
---|
163 | + return myList; // Empty list
|
---|
164 | }
|
---|
165 |
|
---|
166 | if (!_bIsDirectory) {
|
---|
167 | - //debug(6, "Not a directory\n");
|
---|
168 | + debug(6, "Not a directory\n");
|
---|
169 | LEAVE();
|
---|
170 | - //return 0;
|
---|
171 | + return myList; // Empty list
|
---|
172 | }
|
---|
173 |
|
---|
174 | if (_pFileLock == 0) {
|
---|
175 | - //debug(6, "Root node\n");
|
---|
176 | + debug(6, "Root node\n");
|
---|
177 | LEAVE();
|
---|
178 | return listVolumes();
|
---|
179 | }
|
---|
180 |
|
---|
181 | //FSList *myList = new FSList();
|
---|
182 | - FSList myList;
|
---|
183 |
|
---|
184 | - struct ExAllControl *eac;
|
---|
185 | - struct ExAllData *data, *ead;
|
---|
186 | - BOOL bExMore;
|
---|
187 | -
|
---|
188 | - eac = (struct ExAllControl *)IDOS->AllocDosObject(DOS_EXALLCONTROL, 0);
|
---|
189 | + struct ExAllControl *eac = (struct ExAllControl *)IDOS->AllocDosObject(DOS_EXALLCONTROL, 0);
|
---|
190 | if (eac) {
|
---|
191 | - data = (struct ExAllData *)IExec->AllocVec(ExAllBufferSize, MEMF_ANY);
|
---|
192 | + struct ExAllData *data = (struct ExAllData *)IExec->AllocVec(kExAllBufferSize, MEMF_ANY);
|
---|
193 | if (data) {
|
---|
194 | + BOOL bExMore;
|
---|
195 | eac->eac_LastKey = 0;
|
---|
196 | do {
|
---|
197 | - bExMore = IDOS->ExAll(_pFileLock, data, ExAllBufferSize,
|
---|
198 | - ED_TYPE, eac);
|
---|
199 | + bExMore = IDOS->ExAll(_pFileLock, data, kExAllBufferSize, ED_TYPE, eac);
|
---|
200 |
|
---|
201 | LONG error = IDOS->IoErr();
|
---|
202 | if (!bExMore && error != ERROR_NO_MORE_ENTRIES)
|
---|
203 | @@ -258,22 +261,19 @@
|
---|
204 | if (eac->eac_Entries == 0)
|
---|
205 | continue;
|
---|
206 |
|
---|
207 | - ead = data;
|
---|
208 | + struct ExAllData *ead = data;
|
---|
209 | do {
|
---|
210 | - AmigaOSFilesystemNode *entry;
|
---|
211 | - String full_path;
|
---|
212 | - BPTR lock;
|
---|
213 | -
|
---|
214 | - if ((ead->ed_Type > 0 && (mode & kListDirectoriesOnly)) ||
|
---|
215 | - (ead->ed_Type < 0 && (mode & kListFilesOnly))) {
|
---|
216 | - full_path = _sPath;
|
---|
217 | + if ((mode == kListAll) || (EAD_IS_DRAWER(ead) && (mode == kListDirectoriesOnly)) ||
|
---|
218 | + (EAD_IS_FILE(ead) && (mode == kListFilesOnly))) {
|
---|
219 | + String full_path = _sPath;
|
---|
220 | full_path += (char*)ead->ed_Name;
|
---|
221 | - lock = IDOS->Lock((char *)full_path.c_str(), SHARED_LOCK);
|
---|
222 | +
|
---|
223 | + BPTR lock = IDOS->Lock((char *)full_path.c_str(), SHARED_LOCK);
|
---|
224 | if (lock) {
|
---|
225 | - entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name);
|
---|
226 | + AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name);
|
---|
227 | if (entry) {
|
---|
228 | if (entry->isValid())
|
---|
229 | - myList.push_back(wrap(entry));
|
---|
230 | + myList.push_back(wrap(entry));
|
---|
231 | else
|
---|
232 | delete entry;
|
---|
233 | }
|
---|
234 | @@ -289,26 +289,28 @@
|
---|
235 |
|
---|
236 | IDOS->FreeDosObject(DOS_EXALLCONTROL, eac);
|
---|
237 | }
|
---|
238 | +
|
---|
239 | LEAVE();
|
---|
240 | return myList;
|
---|
241 | }
|
---|
242 |
|
---|
243 | AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const {
|
---|
244 | ENTER();
|
---|
245 | - AmigaOSFilesystemNode *node;
|
---|
246 |
|
---|
247 | if (!_bIsDirectory) {
|
---|
248 | - //debug(6, "No directory\n");
|
---|
249 | + debug(6, "No directory\n");
|
---|
250 | LEAVE();
|
---|
251 | return 0;
|
---|
252 | }
|
---|
253 |
|
---|
254 | if (_pFileLock == 0) {
|
---|
255 | - //debug(6, "Root node\n");
|
---|
256 | + debug(6, "Root node\n");
|
---|
257 | LEAVE();
|
---|
258 | return new AmigaOSFilesystemNode(*this);
|
---|
259 | }
|
---|
260 |
|
---|
261 | + AmigaOSFilesystemNode *node;
|
---|
262 | +
|
---|
263 | BPTR parentDir = IDOS->ParentDir( _pFileLock );
|
---|
264 | if (parentDir) {
|
---|
265 | node = new AmigaOSFilesystemNode(parentDir);
|
---|
266 | @@ -326,14 +328,12 @@
|
---|
267 | //FSList *myList = new FSList();
|
---|
268 | FSList myList;
|
---|
269 |
|
---|
270 | - struct DosList *dosList;
|
---|
271 | + const uint32 kLockFlags = LDF_READ | LDF_VOLUMES;
|
---|
272 | + char name[MAXPATHLEN];
|
---|
273 |
|
---|
274 | - const uint32 lockFlags = LDF_READ | LDF_VOLUMES;
|
---|
275 | - char name[256];
|
---|
276 | -
|
---|
277 | - dosList = IDOS->LockDosList(lockFlags);
|
---|
278 | + struct DosList *dosList = IDOS->LockDosList(kLockFlags);
|
---|
279 | if (!dosList) {
|
---|
280 | - //debug(6, "Cannot lock dos list\n");
|
---|
281 | + debug(6, "Cannot lock dos list\n");
|
---|
282 | LEAVE();
|
---|
283 | return myList;
|
---|
284 | }
|
---|
285 | @@ -344,30 +344,29 @@
|
---|
286 | if (dosList->dol_Type == DLT_VOLUME &&
|
---|
287 | dosList->dol_Name &&
|
---|
288 | dosList->dol_Task) {
|
---|
289 | - AmigaOSFilesystemNode *entry;
|
---|
290 | - const char *volname = (const char *)BADDR(dosList->dol_Name)+1;
|
---|
291 | - const char *devname = (const char *)((struct Task *)dosList->dol_Task->mp_SigTask)->tc_Node.ln_Name;
|
---|
292 | + const char *volName = (const char *)BADDR(dosList->dol_Name)+1;
|
---|
293 | + const char *devName = (const char *)((struct Task *)dosList->dol_Task->mp_SigTask)->tc_Node.ln_Name;
|
---|
294 |
|
---|
295 | - strcpy(name, volname);
|
---|
296 | + strcpy(name, volName);
|
---|
297 | strcat(name, ":");
|
---|
298 |
|
---|
299 | - BPTR volume_lock = IDOS->Lock(name, SHARED_LOCK);
|
---|
300 | - if (volume_lock) {
|
---|
301 | - sprintf(name, "%s (%s)", volname, devname);
|
---|
302 | - entry = new AmigaOSFilesystemNode(volume_lock, name);
|
---|
303 | + BPTR volumeLock = IDOS->Lock(name, SHARED_LOCK);
|
---|
304 | + if (volumeLock) {
|
---|
305 | + sprintf(name, "%s (%s)", volName, devName);
|
---|
306 | + AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, name);
|
---|
307 | if (entry) {
|
---|
308 | if (entry->isValid())
|
---|
309 | myList.push_back(wrap(entry));
|
---|
310 | else
|
---|
311 | delete entry;
|
---|
312 | }
|
---|
313 | - IDOS->UnLock(volume_lock);
|
---|
314 | + IDOS->UnLock(volumeLock);
|
---|
315 | }
|
---|
316 | }
|
---|
317 | dosList = IDOS->NextDosEntry(dosList, LDF_VOLUMES);
|
---|
318 | }
|
---|
319 |
|
---|
320 | - IDOS->UnLockDosList(lockFlags);
|
---|
321 | + IDOS->UnLockDosList(kLockFlags);
|
---|
322 |
|
---|
323 | LEAVE();
|
---|
324 | return myList;
|
---|