1 |
|
---|
2 | Property changes on: /home/david/Projects/scummvm
|
---|
3 | ___________________________________________________________________
|
---|
4 | Name: svn:ignore
|
---|
5 | - config.log
|
---|
6 | scummvm
|
---|
7 | scummvm-static
|
---|
8 | config.h
|
---|
9 | config.mk
|
---|
10 | .gdb_history
|
---|
11 | dumps
|
---|
12 | Credits.rtf
|
---|
13 | *.mshark
|
---|
14 |
|
---|
15 | + config.log
|
---|
16 | scummvm
|
---|
17 | scummvm-static
|
---|
18 | config.h
|
---|
19 | config.mk
|
---|
20 | .gdb_history
|
---|
21 | dumps
|
---|
22 | Credits.rtf
|
---|
23 | *.mshark
|
---|
24 | reconf.sh
|
---|
25 |
|
---|
26 |
|
---|
27 | Index: /home/david/Projects/scummvm/backends/fs/abstract-fs-factory.h
|
---|
28 | ===================================================================
|
---|
29 | --- /home/david/Projects/scummvm/backends/fs/abstract-fs-factory.h (revision 0)
|
---|
30 | +++ /home/david/Projects/scummvm/backends/fs/abstract-fs-factory.h (revision 0)
|
---|
31 | @@ -0,0 +1,73 @@
|
---|
32 | +/* ScummVM - Graphic Adventure Engine
|
---|
33 | + *
|
---|
34 | + * ScummVM is the legal property of its developers, whose names
|
---|
35 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
36 | + * file distributed with this source distribution.
|
---|
37 | + *
|
---|
38 | + * This program is free software; you can redistribute it and/or
|
---|
39 | + * modify it under the terms of the GNU General Public License
|
---|
40 | + * as published by the Free Software Foundation; either version 2
|
---|
41 | + * of the License, or (at your option) any later version.
|
---|
42 | + *
|
---|
43 | + * This program is distributed in the hope that it will be useful,
|
---|
44 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
45 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
46 | + * GNU General Public License for more details.
|
---|
47 | + *
|
---|
48 | + * You should have received a copy of the GNU General Public License
|
---|
49 | + * along with this program; if not, write to the Free Software
|
---|
50 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
51 | + *
|
---|
52 | + * $URL: $
|
---|
53 | + * $Id: $
|
---|
54 | + */
|
---|
55 | +
|
---|
56 | +#ifndef ABSTRACT_FILESYSTEM_FACTORY_H
|
---|
57 | +#define ABSTRACT_FILESYSTEM_FACTORY_H
|
---|
58 | +
|
---|
59 | +#include "common/str.h"
|
---|
60 | +#include "backends/fs/abstract-fs.h"
|
---|
61 | +
|
---|
62 | +/**
|
---|
63 | + * Creates concrete FilesystemNode objects depending on the current architecture.
|
---|
64 | + */
|
---|
65 | +class AbstractFilesystemFactory {
|
---|
66 | +public:
|
---|
67 | + typedef Common::String String;
|
---|
68 | +
|
---|
69 | + /**
|
---|
70 | + * Destructor.
|
---|
71 | + */
|
---|
72 | + virtual ~AbstractFilesystemFactory() {}
|
---|
73 | +
|
---|
74 | + /**
|
---|
75 | + * Returns a node representing the "current directory".
|
---|
76 | + * If your system does not support this concept, you can either try to
|
---|
77 | + * emulate it or simply return some "sensible" default directory node,
|
---|
78 | + * e.g. the same value as getRoot() returns.
|
---|
79 | + */
|
---|
80 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const = 0;
|
---|
81 | +
|
---|
82 | + /**
|
---|
83 | + * Construct a node based on a path; the path is in the same format as it
|
---|
84 | + * would be for calls to fopen().
|
---|
85 | + *
|
---|
86 | + * Furthermore getNodeForPath(oldNode.path()) should create a new node
|
---|
87 | + * identical to oldNode. Hence, we can use the "path" value for persistent
|
---|
88 | + * storage e.g. in the config file.
|
---|
89 | + *
|
---|
90 | + * @param path The path string to create a FilesystemNode for.
|
---|
91 | + */
|
---|
92 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const = 0;
|
---|
93 | +
|
---|
94 | + /**
|
---|
95 | + * Returns a special node representing the filesystem root.
|
---|
96 | + * The starting point for any file system browsing.
|
---|
97 | + *
|
---|
98 | + * On Unix, this will be simply the node for / (the root directory).
|
---|
99 | + * On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
|
---|
100 | + */
|
---|
101 | + virtual AbstractFilesystemNode *makeRootFileNode() const = 0;
|
---|
102 | +};
|
---|
103 | +
|
---|
104 | +#endif /*ABSTRACT_FILESYSTEM_FACTORY_H*/
|
---|
105 |
|
---|
106 | Property changes on: /home/david/Projects/scummvm/backends/fs/abstract-fs-factory.h
|
---|
107 | ___________________________________________________________________
|
---|
108 | Name: svn:eol-style
|
---|
109 | + native
|
---|
110 | Name: svn:keywords
|
---|
111 | + Date Rev Author URL Id
|
---|
112 | Name: svn:mime-type
|
---|
113 | + text/plain
|
---|
114 |
|
---|
115 | Index: /home/david/Projects/scummvm/backends/fs/abstract-fs.h
|
---|
116 | ===================================================================
|
---|
117 | --- /home/david/Projects/scummvm/backends/fs/abstract-fs.h (revision 28941)
|
---|
118 | +++ /home/david/Projects/scummvm/backends/fs/abstract-fs.h (working copy)
|
---|
119 | @@ -27,7 +27,6 @@
|
---|
120 |
|
---|
121 | #include "common/array.h"
|
---|
122 | #include "common/str.h"
|
---|
123 | -
|
---|
124 | #include "common/fs.h"
|
---|
125 |
|
---|
126 | class AbstractFilesystemNode;
|
---|
127 | @@ -47,88 +46,106 @@
|
---|
128 | friend class FilesystemNode;
|
---|
129 | typedef Common::String String;
|
---|
130 | typedef FilesystemNode::ListMode ListMode;
|
---|
131 | -
|
---|
132 | - /**
|
---|
133 | - * The parent node of this directory.
|
---|
134 | - * The parent of the root is the root itself.
|
---|
135 | - */
|
---|
136 | - virtual AbstractFilesystemNode *parent() const = 0;
|
---|
137 | -
|
---|
138 | +
|
---|
139 | /**
|
---|
140 | - * The child node with the given name. If no child with this name
|
---|
141 | + * Returns the child node with the given name. If no child with this name
|
---|
142 | * exists, returns 0. When called on a non-directory node, it should
|
---|
143 | * handle this gracefully by returning 0.
|
---|
144 | *
|
---|
145 | + * Example:
|
---|
146 | + * Calling getChild() for a node with path "/foo/bar" using name="file.txt",
|
---|
147 | + * would produce a new node with "/foo/bar/file.txt" as path.
|
---|
148 | + *
|
---|
149 | + * @note This function will append a separator char (\ or /) to the end of the
|
---|
150 | + * path if needed.
|
---|
151 | + *
|
---|
152 | * @note Handling calls on non-dir nodes gracefully makes it possible to
|
---|
153 | * switch to a lazy type detection scheme in the future.
|
---|
154 | + *
|
---|
155 | + * @param name String containing the name of the child to create a new node.
|
---|
156 | */
|
---|
157 | - virtual AbstractFilesystemNode *child(const String &name) const = 0;
|
---|
158 | -
|
---|
159 | + virtual AbstractFilesystemNode *getChild(const String &name) const = 0;
|
---|
160 |
|
---|
161 | /**
|
---|
162 | - * Returns a special node representing the FS root. The starting point for
|
---|
163 | - * any file system browsing.
|
---|
164 | - * On Unix, this will be simply the node for / (the root directory).
|
---|
165 | - * On Windows, it will be a special node which "contains" all drives (C:, D:, E:).
|
---|
166 | + * The parent node of this directory.
|
---|
167 | + * The parent of the root is the root itself.
|
---|
168 | */
|
---|
169 | - static AbstractFilesystemNode *getRoot();
|
---|
170 | + virtual AbstractFilesystemNode *getParent() const = 0;
|
---|
171 |
|
---|
172 | +public:
|
---|
173 | /**
|
---|
174 | - * Returns a node representing the "current directory". If your system does
|
---|
175 | - * not support this concept, you can either try to emulate it or
|
---|
176 | - * simply return some "sensible" default directory node, e.g. the same
|
---|
177 | - * value as getRoot() returns.
|
---|
178 | + * Destructor.
|
---|
179 | + */
|
---|
180 | + virtual ~AbstractFilesystemNode() {}
|
---|
181 | +
|
---|
182 | + /*
|
---|
183 | + * Indicates whether the object referred by this path exists in the filesystem or not.
|
---|
184 | */
|
---|
185 | - static AbstractFilesystemNode *getCurrentDirectory();
|
---|
186 | -
|
---|
187 | + virtual bool exists() const = 0;
|
---|
188 |
|
---|
189 | /**
|
---|
190 | - * Construct a node based on a path; the path is in the same format as it
|
---|
191 | - * would be for calls to fopen().
|
---|
192 | - *
|
---|
193 | - * Furthermore getNodeForPath(oldNode.path()) should create a new node
|
---|
194 | - * identical to oldNode. Hence, we can use the "path" value for persistent
|
---|
195 | - * storage e.g. in the config file.
|
---|
196 | - *
|
---|
197 | - * @todo: This is of course a place where non-portable code easily will sneak
|
---|
198 | - * in, because the format of the path used here is not well-defined.
|
---|
199 | - * So we really should reconsider this API and try to come up with
|
---|
200 | - * something which is more portable but still flexible enough for our
|
---|
201 | - * purposes.
|
---|
202 | + * Return a list of child nodes of this directory node. If called on a node
|
---|
203 | + * that does not represent a directory, false is returned.
|
---|
204 | + *
|
---|
205 | + * @param list List to put the contents of the directory in.
|
---|
206 | + * @param mode Mode to use while listing the directory.
|
---|
207 | + * @param hidden Whether to include hidden files or not in the results.
|
---|
208 | + *
|
---|
209 | + * @return true if succesful, false otherwise (e.g. when the directory does not exist).
|
---|
210 | */
|
---|
211 | - static AbstractFilesystemNode *getNodeForPath(const String &path);
|
---|
212 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const = 0;
|
---|
213 |
|
---|
214 | -
|
---|
215 | -public:
|
---|
216 | - virtual ~AbstractFilesystemNode() {}
|
---|
217 | + /**
|
---|
218 | + * Returns a human readable path string.
|
---|
219 | + *
|
---|
220 | + * @note By default, this method returns the value of getName().
|
---|
221 | + */
|
---|
222 | + virtual String getDisplayName() const { return getName(); }
|
---|
223 |
|
---|
224 | - virtual String name() const = 0;
|
---|
225 | + /**
|
---|
226 | + * Returns a string with an architecture dependent path description.
|
---|
227 | + */
|
---|
228 | + virtual String getName() const = 0;
|
---|
229 |
|
---|
230 | - // By default, we use the actual file name as 'display name'.
|
---|
231 | - virtual String displayName() const { return name(); }
|
---|
232 | -
|
---|
233 | - virtual bool isValid() const = 0;
|
---|
234 | -
|
---|
235 | + /**
|
---|
236 | + * Returns the 'path' of the current node, usable in fopen().
|
---|
237 | + */
|
---|
238 | + virtual String getPath() const = 0;
|
---|
239 | +
|
---|
240 | + /**
|
---|
241 | + * Indicates whether this path refers to a directory or not.
|
---|
242 | + */
|
---|
243 | virtual bool isDirectory() const = 0;
|
---|
244 |
|
---|
245 | /**
|
---|
246 | - * Return the 'path' of the current node, usable in fopen(). See also
|
---|
247 | - * the static getNodeForPath() method.
|
---|
248 | + * Indicates whether the object referred by this path can be read from or not.
|
---|
249 | + *
|
---|
250 | + * If the path refers to a directory, readability implies being able to read
|
---|
251 | + * and list the directory entries.
|
---|
252 | + *
|
---|
253 | + * If the path refers to a file, readability implies being able to read the
|
---|
254 | + * contents of the file.
|
---|
255 | + *
|
---|
256 | + * @return bool true if the object can be read, false otherwise.
|
---|
257 | */
|
---|
258 | - virtual String path() const = 0;
|
---|
259 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const = 0;
|
---|
260 | -
|
---|
261 | + virtual bool isReadable() const = 0;
|
---|
262 | +
|
---|
263 | + /**
|
---|
264 | + * Indicates whether the object referred by this path can be written to or not.
|
---|
265 | + *
|
---|
266 | + * If the path refers to a directory, writability implies being able to modify
|
---|
267 | + * the directory entry (i.e. rename the directory, remove it or write files inside of it).
|
---|
268 | + *
|
---|
269 | + * If the path refers to a file, writability implies being able to write data
|
---|
270 | + * to the file.
|
---|
271 | + *
|
---|
272 | + * @return bool true if the object can be written to, false otherwise.
|
---|
273 | + */
|
---|
274 | + virtual bool isWritable() const = 0;
|
---|
275 |
|
---|
276 | /* TODO:
|
---|
277 | - bool exists();
|
---|
278 | -
|
---|
279 | - bool isDirectory();
|
---|
280 | bool isFile();
|
---|
281 | -
|
---|
282 | - bool isReadable();
|
---|
283 | - bool isWriteable();
|
---|
284 | */
|
---|
285 | };
|
---|
286 |
|
---|
287 | -
|
---|
288 | -#endif
|
---|
289 | +#endif //BACKENDS_ABSTRACT_FS_H
|
---|
290 | Index: /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.cpp
|
---|
291 | ===================================================================
|
---|
292 | --- /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.cpp (revision 0)
|
---|
293 | +++ /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.cpp (revision 0)
|
---|
294 | @@ -0,0 +1,40 @@
|
---|
295 | +/* ScummVM - Graphic Adventure Engine
|
---|
296 | + *
|
---|
297 | + * ScummVM is the legal property of its developers, whose names
|
---|
298 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
299 | + * file distributed with this source distribution.
|
---|
300 | + *
|
---|
301 | + * This program is free software; you can redistribute it and/or
|
---|
302 | + * modify it under the terms of the GNU General Public License
|
---|
303 | + * as published by the Free Software Foundation; either version 2
|
---|
304 | + * of the License, or (at your option) any later version.
|
---|
305 | + *
|
---|
306 | + * This program is distributed in the hope that it will be useful,
|
---|
307 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
308 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
309 | + * GNU General Public License for more details.
|
---|
310 | + *
|
---|
311 | + * You should have received a copy of the GNU General Public License
|
---|
312 | + * along with this program; if not, write to the Free Software
|
---|
313 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
314 | + *
|
---|
315 | + * $URL: $
|
---|
316 | + * $Id: $
|
---|
317 | + */
|
---|
318 | +
|
---|
319 | +#include "backends/fs/amigaos4/amigaos4-fs-factory.h"
|
---|
320 | +#include "backends/fs/amigaos4/amigaos4-fs.cpp"
|
---|
321 | +
|
---|
322 | +DECLARE_SINGLETON(AmigaOSFilesystemFactory);
|
---|
323 | +
|
---|
324 | +AbstractFilesystemNode *AmigaOSFilesystemFactory::makeRootFileNode() const {
|
---|
325 | + return new AmigaOSFilesystemNode();
|
---|
326 | +}
|
---|
327 | +
|
---|
328 | +AbstractFilesystemNode *AmigaOSFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
329 | + return new AmigaOSFilesystemNode();
|
---|
330 | +}
|
---|
331 | +
|
---|
332 | +AbstractFilesystemNode *AmigaOSFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
333 | + return new AmigaOSFilesystemNode(path);
|
---|
334 | +}
|
---|
335 |
|
---|
336 | Property changes on: /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.cpp
|
---|
337 | ___________________________________________________________________
|
---|
338 | Name: svn:eol-style
|
---|
339 | + native
|
---|
340 | Name: svn:keywords
|
---|
341 | + Date Rev Author URL Id
|
---|
342 | Name: svn:mime-type
|
---|
343 | + text/plain
|
---|
344 |
|
---|
345 | Index: /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.h
|
---|
346 | ===================================================================
|
---|
347 | --- /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.h (revision 0)
|
---|
348 | +++ /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.h (revision 0)
|
---|
349 | @@ -0,0 +1,51 @@
|
---|
350 | +/* ScummVM - Graphic Adventure Engine
|
---|
351 | + *
|
---|
352 | + * ScummVM is the legal property of its developers, whose names
|
---|
353 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
354 | + * file distributed with this source distribution.
|
---|
355 | + *
|
---|
356 | + * This program is free software; you can redistribute it and/or
|
---|
357 | + * modify it under the terms of the GNU General Public License
|
---|
358 | + * as published by the Free Software Foundation; either version 2
|
---|
359 | + * of the License, or (at your option) any later version.
|
---|
360 | + *
|
---|
361 | + * This program is distributed in the hope that it will be useful,
|
---|
362 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
363 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
364 | + * GNU General Public License for more details.
|
---|
365 | + *
|
---|
366 | + * You should have received a copy of the GNU General Public License
|
---|
367 | + * along with this program; if not, write to the Free Software
|
---|
368 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
369 | + *
|
---|
370 | + * $URL: $
|
---|
371 | + * $Id: $
|
---|
372 | + */
|
---|
373 | +
|
---|
374 | +#ifndef AMIGAOS_FILESYSTEM_FACTORY_H
|
---|
375 | +#define AMIGAOS_FILESYSTEM_FACTORY_H
|
---|
376 | +
|
---|
377 | +#include "common/singleton.h"
|
---|
378 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
379 | +
|
---|
380 | +/**
|
---|
381 | + * Creates AmigaOSFilesystemNode objects.
|
---|
382 | + *
|
---|
383 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
384 | + */
|
---|
385 | +class AmigaOSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<AmigaOSFilesystemFactory> {
|
---|
386 | +public:
|
---|
387 | + typedef Common::String String;
|
---|
388 | +
|
---|
389 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
390 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
391 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
392 | +
|
---|
393 | +protected:
|
---|
394 | + AmigaOSFilesystemFactory() {};
|
---|
395 | +
|
---|
396 | +private:
|
---|
397 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
398 | +};
|
---|
399 | +
|
---|
400 | +#endif /*AMIGAOS_FILESYSTEM_FACTORY_H*/
|
---|
401 |
|
---|
402 | Property changes on: /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs-factory.h
|
---|
403 | ___________________________________________________________________
|
---|
404 | Name: svn:eol-style
|
---|
405 | + native
|
---|
406 | Name: svn:keywords
|
---|
407 | + Date Rev Author URL Id
|
---|
408 | Name: svn:mime-type
|
---|
409 | + text/plain
|
---|
410 |
|
---|
411 | Index: /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs.cpp
|
---|
412 | ===================================================================
|
---|
413 | --- /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs.cpp (revision 28941)
|
---|
414 | +++ /home/david/Projects/scummvm/backends/fs/amigaos4/amigaos4-fs.cpp (working copy)
|
---|
415 | @@ -38,7 +38,6 @@
|
---|
416 | #include <common/stdafx.h>
|
---|
417 |
|
---|
418 | #include "common/util.h"
|
---|
419 | -
|
---|
420 | #include "engines/engine.h"
|
---|
421 | #include "backends/fs/abstract-fs.h"
|
---|
422 |
|
---|
423 | @@ -45,51 +44,70 @@
|
---|
424 | #define ENTER() /* debug(6, "Enter") */
|
---|
425 | #define LEAVE() /* debug(6, "Leave") */
|
---|
426 |
|
---|
427 | -
|
---|
428 | const uint32 kExAllBufferSize = 40960; // TODO: is this okay for sure?
|
---|
429 |
|
---|
430 | +/**
|
---|
431 | + * Implementation of the ScummVM file system API.
|
---|
432 | + *
|
---|
433 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
434 | + */
|
---|
435 | class AmigaOSFilesystemNode : public AbstractFilesystemNode {
|
---|
436 | - protected:
|
---|
437 | - BPTR _pFileLock;
|
---|
438 | - String _sDisplayName;
|
---|
439 | - bool _bIsDirectory;
|
---|
440 | - bool _bIsValid;
|
---|
441 | - String _sPath;
|
---|
442 | +protected:
|
---|
443 | + BPTR _pFileLock;
|
---|
444 | + String _sDisplayName;
|
---|
445 | + String _sPath;
|
---|
446 | + bool _bIsDirectory;
|
---|
447 | + bool _bIsValid;
|
---|
448 |
|
---|
449 | - public:
|
---|
450 | - AmigaOSFilesystemNode();
|
---|
451 | - AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
|
---|
452 | - AmigaOSFilesystemNode(const String &p);
|
---|
453 | +public:
|
---|
454 | + /**
|
---|
455 | + * Creates a AmigaOSFilesystemNode with the root node as path.
|
---|
456 | + */
|
---|
457 | + AmigaOSFilesystemNode();
|
---|
458 | +
|
---|
459 | + /**
|
---|
460 | + * Creates a AmigaOSFilesystemNode for a given path.
|
---|
461 | + *
|
---|
462 | + * @param path String with the path the new node should point to.
|
---|
463 | + */
|
---|
464 | + AmigaOSFilesystemNode(const String &p);
|
---|
465 | +
|
---|
466 | + /**
|
---|
467 | + * FIXME: document this constructor.
|
---|
468 | + */
|
---|
469 | + AmigaOSFilesystemNode(BPTR pLock, const char *pDisplayName = 0);
|
---|
470 |
|
---|
471 | - // Note: Copy constructor is needed because it duplicates the file lock
|
---|
472 | - AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
|
---|
473 | -
|
---|
474 | - virtual ~AmigaOSFilesystemNode();
|
---|
475 | + /**
|
---|
476 | + * Copy constructor.
|
---|
477 | + *
|
---|
478 | + * @note Needed because it duplicates the file lock
|
---|
479 | + */
|
---|
480 | + AmigaOSFilesystemNode(const AmigaOSFilesystemNode &node);
|
---|
481 | +
|
---|
482 | + /**
|
---|
483 | + * Destructor.
|
---|
484 | + */
|
---|
485 | + virtual ~AmigaOSFilesystemNode();
|
---|
486 |
|
---|
487 | - virtual String displayName() const { return _sDisplayName; };
|
---|
488 | - virtual String name() const { return _sDisplayName; };
|
---|
489 | - virtual bool isValid() const { return _bIsValid; };
|
---|
490 | - virtual bool isDirectory() const { return _bIsDirectory; };
|
---|
491 | - virtual String path() const { return _sPath; };
|
---|
492 | -
|
---|
493 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
494 | - virtual AbstractFSList listVolumes() const;
|
---|
495 | - virtual AbstractFilesystemNode *parent() const;
|
---|
496 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
497 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
498 | + virtual String getDisplayName() const { return _sDisplayName; };
|
---|
499 | + virtual String getName() const { return _sDisplayName; };
|
---|
500 | + virtual String getPath() const { return _sPath; };
|
---|
501 | + virtual bool isDirectory() const { return _bIsDirectory; };
|
---|
502 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
503 | + virtual bool isValid() const { return _bIsValid; };
|
---|
504 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
505 | +
|
---|
506 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
507 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
508 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
509 | +
|
---|
510 | + /**
|
---|
511 | + * Creates a list with all the volumes present in the root node.
|
---|
512 | + */
|
---|
513 | + virtual AbstractFSList listVolumes() const;
|
---|
514 | };
|
---|
515 |
|
---|
516 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
517 | - return AbstractFilesystemNode::getRoot();
|
---|
518 | -}
|
---|
519 | -
|
---|
520 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
521 | - return new AmigaOSFilesystemNode();
|
---|
522 | -}
|
---|
523 | -
|
---|
524 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
525 | - return new AmigaOSFilesystemNode(path);
|
---|
526 | -}
|
---|
527 | -
|
---|
528 | AmigaOSFilesystemNode::AmigaOSFilesystemNode() {
|
---|
529 | ENTER();
|
---|
530 | _sDisplayName = "Available Disks";
|
---|
531 | @@ -100,7 +118,6 @@
|
---|
532 | LEAVE();
|
---|
533 | }
|
---|
534 |
|
---|
535 | -
|
---|
536 | AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) {
|
---|
537 | ENTER();
|
---|
538 |
|
---|
539 | @@ -150,7 +167,6 @@
|
---|
540 | const char c = _sPath.lastChar();
|
---|
541 | if (c != '/' && c != ':')
|
---|
542 | _sPath += '/';
|
---|
543 | -
|
---|
544 | }
|
---|
545 | else {
|
---|
546 | //_bIsDirectory = false;
|
---|
547 | @@ -170,7 +186,7 @@
|
---|
548 | int bufSize = MAXPATHLEN;
|
---|
549 | _pFileLock = 0;
|
---|
550 |
|
---|
551 | - while (1) {
|
---|
552 | + while (true) {
|
---|
553 | char *n = new char[bufSize];
|
---|
554 | if (IDOS->NameFromLock(pLock, (STRPTR)n, bufSize) != DOSFALSE) {
|
---|
555 | _sPath = n;
|
---|
556 | @@ -186,6 +202,7 @@
|
---|
557 | delete [] n;
|
---|
558 | return;
|
---|
559 | }
|
---|
560 | +
|
---|
561 | bufSize *= 2;
|
---|
562 | delete [] n;
|
---|
563 | }
|
---|
564 | @@ -238,9 +255,35 @@
|
---|
565 | LEAVE();
|
---|
566 | }
|
---|
567 |
|
---|
568 | -bool AmigaOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
569 | +AbstractFilesystemNode *AmigaOSFilesystemNode::getChild(const String &n) const {
|
---|
570 | + if (!_bIsDirectory) {
|
---|
571 | + debug(6, "Not a directory");
|
---|
572 | + return 0;
|
---|
573 | + }
|
---|
574 | +
|
---|
575 | + String newPath(_sPath);
|
---|
576 | +
|
---|
577 | + if (_sPath.lastChar() != '/')
|
---|
578 | + newPath += '/';
|
---|
579 | +
|
---|
580 | + newPath += n;
|
---|
581 | + BPTR lock = IDOS->Lock(newPath.c_str(), SHARED_LOCK);
|
---|
582 | +
|
---|
583 | + if (!lock) {
|
---|
584 | + debug(6, "Bad path");
|
---|
585 | + return 0;
|
---|
586 | + }
|
---|
587 | +
|
---|
588 | + IDOS->UnLock(lock);
|
---|
589 | +
|
---|
590 | + return new AmigaOSFilesystemNode(newPath);
|
---|
591 | +}
|
---|
592 | +
|
---|
593 | +bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
594 | ENTER();
|
---|
595 |
|
---|
596 | + //TODO: honor the hidden flag
|
---|
597 | +
|
---|
598 | if (!_bIsValid) {
|
---|
599 | debug(6, "Invalid node");
|
---|
600 | LEAVE();
|
---|
601 | @@ -308,10 +351,11 @@
|
---|
602 | }
|
---|
603 |
|
---|
604 | LEAVE();
|
---|
605 | +
|
---|
606 | return true;
|
---|
607 | }
|
---|
608 |
|
---|
609 | -AbstractFilesystemNode *AmigaOSFilesystemNode::parent() const {
|
---|
610 | +AbstractFilesystemNode *AmigaOSFilesystemNode::getParent() const {
|
---|
611 | ENTER();
|
---|
612 |
|
---|
613 | if (!_bIsDirectory) {
|
---|
614 | @@ -337,35 +381,10 @@
|
---|
615 | node = new AmigaOSFilesystemNode();
|
---|
616 |
|
---|
617 | LEAVE();
|
---|
618 | +
|
---|
619 | return node;
|
---|
620 | }
|
---|
621 |
|
---|
622 | -AbstractFilesystemNode *AmigaOSFilesystemNode::child(const String &n) const {
|
---|
623 | -
|
---|
624 | - if (!_bIsDirectory) {
|
---|
625 | - debug(6, "Not a directory");
|
---|
626 | - return 0;
|
---|
627 | - }
|
---|
628 | -
|
---|
629 | - String newPath(_sPath);
|
---|
630 | -
|
---|
631 | - if (_sPath.lastChar() != '/')
|
---|
632 | - newPath += '/';
|
---|
633 | -
|
---|
634 | - newPath += n;
|
---|
635 | -
|
---|
636 | - BPTR lock = IDOS->Lock(newPath.c_str(), SHARED_LOCK);
|
---|
637 | -
|
---|
638 | - if (!lock) {
|
---|
639 | - debug(6, "Bad path");
|
---|
640 | - return 0;
|
---|
641 | - }
|
---|
642 | -
|
---|
643 | - IDOS->UnLock(lock);
|
---|
644 | -
|
---|
645 | - return new AmigaOSFilesystemNode(newPath);
|
---|
646 | -}
|
---|
647 | -
|
---|
648 | AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
|
---|
649 | ENTER();
|
---|
650 |
|
---|
651 | @@ -431,7 +450,8 @@
|
---|
652 | IDOS->UnLockDosList(kLockFlags);
|
---|
653 |
|
---|
654 | LEAVE();
|
---|
655 | +
|
---|
656 | return myList;
|
---|
657 | }
|
---|
658 |
|
---|
659 | -#endif
|
---|
660 | +#endif //defined(__amigaos4__)
|
---|
661 | Index: /home/david/Projects/scummvm/backends/fs/dc/dc-fs.cpp
|
---|
662 | ===================================================================
|
---|
663 | --- /home/david/Projects/scummvm/backends/fs/dc/dc-fs.cpp (revision 28941)
|
---|
664 | +++ /home/david/Projects/scummvm/backends/fs/dc/dc-fs.cpp (working copy)
|
---|
665 | @@ -25,7 +25,6 @@
|
---|
666 | #if defined(__DC__)
|
---|
667 |
|
---|
668 | #include "common/stdafx.h"
|
---|
669 | -
|
---|
670 | #include "backends/fs/abstract-fs.h"
|
---|
671 |
|
---|
672 | #include <ronin/cdfs.h>
|
---|
673 | @@ -32,33 +31,56 @@
|
---|
674 | #include <stdio.h>
|
---|
675 | #include <unistd.h>
|
---|
676 |
|
---|
677 | -/*
|
---|
678 | - * Implementation of the ScummVM file system API based on ronin.
|
---|
679 | +/**
|
---|
680 | + * Implementation of the ScummVM file system API based on Ronin.
|
---|
681 | + *
|
---|
682 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
683 | */
|
---|
684 | -
|
---|
685 | class RoninCDFilesystemNode : public AbstractFilesystemNode {
|
---|
686 | protected:
|
---|
687 | String _displayName;
|
---|
688 | + String _path;
|
---|
689 | bool _isDirectory;
|
---|
690 | bool _isValid;
|
---|
691 | - String _path;
|
---|
692 |
|
---|
693 | public:
|
---|
694 | + /**
|
---|
695 | + * Creates a RoninCDFilesystemNode with the root node as path.
|
---|
696 | + */
|
---|
697 | RoninCDFilesystemNode();
|
---|
698 | +
|
---|
699 | + /**
|
---|
700 | + * Creates a RoninCDFilesystemNode for a given path.
|
---|
701 | + *
|
---|
702 | + * @param path String with the path the new node should point to.
|
---|
703 | + * @param verify true if the isValid and isDirectory flags should be verified during the construction.
|
---|
704 | + */
|
---|
705 | RoninCDFilesystemNode(const String &path, bool verify);
|
---|
706 |
|
---|
707 | - virtual String displayName() const { return _displayName; }
|
---|
708 | - virtual String name() const { return _displayName; }
|
---|
709 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
710 | + virtual String getDisplayName() const { return _displayName; }
|
---|
711 | + virtual String getName() const { return _displayName; }
|
---|
712 | + virtual String getPath() const { return _path; }
|
---|
713 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
714 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
715 | virtual bool isValid() const { return _isValid; }
|
---|
716 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
717 | - virtual String path() const { return _path; }
|
---|
718 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
719 |
|
---|
720 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
721 | - virtual AbstractFilesystemNode *parent() const;
|
---|
722 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
723 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
724 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
725 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
726 | };
|
---|
727 |
|
---|
728 | -
|
---|
729 | +/**
|
---|
730 | + * Returns the last component of a given path.
|
---|
731 | + *
|
---|
732 | + * Examples:
|
---|
733 | + * /foo/bar.txt would return /bar.txt
|
---|
734 | + * /foo/bar/ would return /bar/
|
---|
735 | + *
|
---|
736 | + * @param str String containing the path.
|
---|
737 | + * @return Pointer to the first char of the last component inside str.
|
---|
738 | + */
|
---|
739 | static const char *lastPathComponent(const Common::String &str) {
|
---|
740 | const char *start = str.c_str();
|
---|
741 | const char *cur = start + str.size() - 2;
|
---|
742 | @@ -70,22 +92,6 @@
|
---|
743 | return cur + 1;
|
---|
744 | }
|
---|
745 |
|
---|
746 | -
|
---|
747 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
748 | - // Since there is no way to _set_ the current directory,
|
---|
749 | - // it will always be /...
|
---|
750 | -
|
---|
751 | - return getRoot();
|
---|
752 | -}
|
---|
753 | -
|
---|
754 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
755 | - return new RoninCDFilesystemNode();
|
---|
756 | -}
|
---|
757 | -
|
---|
758 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
759 | - return new RoninCDFilesystemNode(path, true);
|
---|
760 | -}
|
---|
761 | -
|
---|
762 | RoninCDFilesystemNode::RoninCDFilesystemNode() {
|
---|
763 | // The root dir.
|
---|
764 | _path = "/";
|
---|
765 | @@ -118,10 +124,25 @@
|
---|
766 | }
|
---|
767 | }
|
---|
768 |
|
---|
769 | -bool RoninCDFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
770 | +AbstractFilesystemNode *RoninCDFilesystemNode::getChild(const String &n) const {
|
---|
771 | + // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
772 | + // of, do not check if this is a special node, etc.
|
---|
773 | + assert(_isDirectory);
|
---|
774 | +
|
---|
775 | + String newPath(_path);
|
---|
776 | + if (_path.lastChar() != '/')
|
---|
777 | + newPath += '/';
|
---|
778 | + newPath += n;
|
---|
779 | +
|
---|
780 | + return new RoninCDFilesystemNode(newPath, true);
|
---|
781 | +}
|
---|
782 | +
|
---|
783 | +bool RoninCDFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
784 | assert(_isDirectory);
|
---|
785 | +
|
---|
786 | + //TODO: honor the hidden flag
|
---|
787 | +
|
---|
788 | DIR *dirp = opendir(_path.c_str());
|
---|
789 | -
|
---|
790 | struct dirent *dp;
|
---|
791 |
|
---|
792 | if (dirp == NULL)
|
---|
793 | @@ -150,13 +171,15 @@
|
---|
794 |
|
---|
795 | if (entry._isDirectory)
|
---|
796 | entry._path += "/";
|
---|
797 | +
|
---|
798 | myList.push_back(new RoninCDFilesystemNode(entry));
|
---|
799 | }
|
---|
800 | closedir(dirp);
|
---|
801 | +
|
---|
802 | return true;
|
---|
803 | }
|
---|
804 |
|
---|
805 | -AbstractFilesystemNode *RoninCDFilesystemNode::parent() const {
|
---|
806 | +AbstractFilesystemNode *RoninCDFilesystemNode::getParent() const {
|
---|
807 | if (_path == "/")
|
---|
808 | return 0;
|
---|
809 |
|
---|
810 | @@ -163,22 +186,7 @@
|
---|
811 | const char *start = _path.c_str();
|
---|
812 | const char *end = lastPathComponent(_path);
|
---|
813 |
|
---|
814 | - RoninCDFilesystemNode *p = new RoninCDFilesystemNode(String(start, end - start), false);
|
---|
815 | -
|
---|
816 | - return p;
|
---|
817 | -}
|
---|
818 | -
|
---|
819 | -AbstractFilesystemNode *RoninCDFilesystemNode::child(const String &n) const {
|
---|
820 | - // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
821 | - // of, do not check if this is a special node, etc.
|
---|
822 | - assert(_isDirectory);
|
---|
823 | - String newPath(_path);
|
---|
824 | - if (_path.lastChar() != '/')
|
---|
825 | - newPath += '/';
|
---|
826 | - newPath += n;
|
---|
827 | - RoninCDFilesystemNode *p = new RoninCDFilesystemNode(newPath, true);
|
---|
828 | -
|
---|
829 | - return p;
|
---|
830 | + return new RoninCDFilesystemNode(String(start, end - start), false);
|
---|
831 | }
|
---|
832 |
|
---|
833 | #endif // defined(__DC__)
|
---|
834 | Index: /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.cpp
|
---|
835 | ===================================================================
|
---|
836 | --- /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.cpp (revision 0)
|
---|
837 | +++ /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.cpp (revision 0)
|
---|
838 | @@ -0,0 +1,40 @@
|
---|
839 | +/* ScummVM - Graphic Adventure Engine
|
---|
840 | + *
|
---|
841 | + * ScummVM is the legal property of its developers, whose names
|
---|
842 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
843 | + * file distributed with this source distribution.
|
---|
844 | + *
|
---|
845 | + * This program is free software; you can redistribute it and/or
|
---|
846 | + * modify it under the terms of the GNU General Public License
|
---|
847 | + * as published by the Free Software Foundation; either version 2
|
---|
848 | + * of the License, or (at your option) any later version.
|
---|
849 | + *
|
---|
850 | + * This program is distributed in the hope that it will be useful,
|
---|
851 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
852 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
853 | + * GNU General Public License for more details.
|
---|
854 | + *
|
---|
855 | + * You should have received a copy of the GNU General Public License
|
---|
856 | + * along with this program; if not, write to the Free Software
|
---|
857 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
858 | + *
|
---|
859 | + * $URL: $
|
---|
860 | + * $Id: $
|
---|
861 | + */
|
---|
862 | +
|
---|
863 | +#include "backends/fs/dc/ronincd-fs-factory.h"
|
---|
864 | +#include "backends/fs/dc/dc-fs.cpp"
|
---|
865 | +
|
---|
866 | +DECLARE_SINGLETON(RoninCDFilesystemFactory);
|
---|
867 | +
|
---|
868 | +AbstractFilesystemNode *RoninCDFilesystemFactory::makeRootFileNode() const {
|
---|
869 | + return new RoninCDFilesystemNode();
|
---|
870 | +}
|
---|
871 | +
|
---|
872 | +AbstractFilesystemNode *RoninCDFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
873 | + return new RoninCDFilesystemNode();
|
---|
874 | +}
|
---|
875 | +
|
---|
876 | +AbstractFilesystemNode *RoninCDFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
877 | + return new RoninCDFilesystemNode(path, true);
|
---|
878 | +}
|
---|
879 |
|
---|
880 | Property changes on: /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.cpp
|
---|
881 | ___________________________________________________________________
|
---|
882 | Name: svn:eol-style
|
---|
883 | + native
|
---|
884 | Name: svn:keywords
|
---|
885 | + Date Rev Author URL Id
|
---|
886 | Name: svn:mime-type
|
---|
887 | + text/plain
|
---|
888 |
|
---|
889 | Index: /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.h
|
---|
890 | ===================================================================
|
---|
891 | --- /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.h (revision 0)
|
---|
892 | +++ /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.h (revision 0)
|
---|
893 | @@ -0,0 +1,51 @@
|
---|
894 | +/* ScummVM - Graphic Adventure Engine
|
---|
895 | + *
|
---|
896 | + * ScummVM is the legal property of its developers, whose names
|
---|
897 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
898 | + * file distributed with this source distribution.
|
---|
899 | + *
|
---|
900 | + * This program is free software; you can redistribute it and/or
|
---|
901 | + * modify it under the terms of the GNU General Public License
|
---|
902 | + * as published by the Free Software Foundation; either version 2
|
---|
903 | + * of the License, or (at your option) any later version.
|
---|
904 | + *
|
---|
905 | + * This program is distributed in the hope that it will be useful,
|
---|
906 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
907 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
908 | + * GNU General Public License for more details.
|
---|
909 | + *
|
---|
910 | + * You should have received a copy of the GNU General Public License
|
---|
911 | + * along with this program; if not, write to the Free Software
|
---|
912 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
913 | + *
|
---|
914 | + * $URL: $
|
---|
915 | + * $Id: $
|
---|
916 | + */
|
---|
917 | +
|
---|
918 | +#ifndef RONINCD_FILESYSTEM_FACTORY_H
|
---|
919 | +#define RONINCD_FILESYSTEM_FACTORY_H
|
---|
920 | +
|
---|
921 | +#include "common/singleton.h"
|
---|
922 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
923 | +
|
---|
924 | +/**
|
---|
925 | + * Creates RoninCDFilesystemNode objects.
|
---|
926 | + *
|
---|
927 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
928 | + */
|
---|
929 | +class RoninCDFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<RoninCDFilesystemFactory> {
|
---|
930 | +public:
|
---|
931 | + typedef Common::String String;
|
---|
932 | +
|
---|
933 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
934 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
935 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
936 | +
|
---|
937 | +protected:
|
---|
938 | + RoninCDFilesystemFactory() {};
|
---|
939 | +
|
---|
940 | +private:
|
---|
941 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
942 | +};
|
---|
943 | +
|
---|
944 | +#endif /*RONINCD_FILESYSTEM_FACTORY_H*/
|
---|
945 |
|
---|
946 | Property changes on: /home/david/Projects/scummvm/backends/fs/dc/ronincd-fs-factory.h
|
---|
947 | ___________________________________________________________________
|
---|
948 | Name: svn:eol-style
|
---|
949 | + native
|
---|
950 | Name: svn:keywords
|
---|
951 | + Date Rev Author URL Id
|
---|
952 | Name: svn:mime-type
|
---|
953 | + text/plain
|
---|
954 |
|
---|
955 | Index: /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.cpp
|
---|
956 | ===================================================================
|
---|
957 | --- /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.cpp (revision 0)
|
---|
958 | +++ /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.cpp (revision 0)
|
---|
959 | @@ -0,0 +1,53 @@
|
---|
960 | +/* ScummVM - Graphic Adventure Engine
|
---|
961 | + *
|
---|
962 | + * ScummVM is the legal property of its developers, whose names
|
---|
963 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
964 | + * file distributed with this source distribution.
|
---|
965 | + *
|
---|
966 | + * This program is free software; you can redistribute it and/or
|
---|
967 | + * modify it under the terms of the GNU General Public License
|
---|
968 | + * as published by the Free Software Foundation; either version 2
|
---|
969 | + * of the License, or (at your option) any later version.
|
---|
970 | + *
|
---|
971 | + * This program is distributed in the hope that it will be useful,
|
---|
972 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
973 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
974 | + * GNU General Public License for more details.
|
---|
975 | + *
|
---|
976 | + * You should have received a copy of the GNU General Public License
|
---|
977 | + * along with this program; if not, write to the Free Software
|
---|
978 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
979 | + *
|
---|
980 | + * $URL: $
|
---|
981 | + * $Id: $
|
---|
982 | + */
|
---|
983 | +
|
---|
984 | +#include "backends/fs/ds/ds-fs-factory.h"
|
---|
985 | +#include "backends/fs/ds/ds-fs.cpp"
|
---|
986 | +#include "dsmain.h" //for the isGBAMPAvailable() function
|
---|
987 | +
|
---|
988 | +DECLARE_SINGLETON(DSFilesystemFactory);
|
---|
989 | +
|
---|
990 | +AbstractFilesystemNode *DSFilesystemFactory::makeRootFileNode() const {
|
---|
991 | + if (DS::isGBAMPAvailable()) {
|
---|
992 | + return new DS::GBAMPFileSystemNode();
|
---|
993 | + } else {
|
---|
994 | + return new DS::DSFileSystemNode();
|
---|
995 | + }
|
---|
996 | +}
|
---|
997 | +
|
---|
998 | +AbstractFilesystemNode *DSFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
999 | + if (DS::isGBAMPAvailable()) {
|
---|
1000 | + return new DS::GBAMPFileSystemNode();
|
---|
1001 | + } else {
|
---|
1002 | + return new DS::DSFileSystemNode();
|
---|
1003 | + }
|
---|
1004 | +}
|
---|
1005 | +
|
---|
1006 | +AbstractFilesystemNode *DSFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
1007 | + if (DS::isGBAMPAvailable()) {
|
---|
1008 | + return new DS::GBAMPFileSystemNode(path);
|
---|
1009 | + } else {
|
---|
1010 | + return new DS::DSFileSystemNode(path);
|
---|
1011 | + }
|
---|
1012 | +}
|
---|
1013 |
|
---|
1014 | Property changes on: /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.cpp
|
---|
1015 | ___________________________________________________________________
|
---|
1016 | Name: svn:eol-style
|
---|
1017 | + native
|
---|
1018 | Name: svn:keywords
|
---|
1019 | + Date Rev Author URL Id
|
---|
1020 | Name: svn:mime-type
|
---|
1021 | + text/plain
|
---|
1022 |
|
---|
1023 | Index: /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.h
|
---|
1024 | ===================================================================
|
---|
1025 | --- /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.h (revision 0)
|
---|
1026 | +++ /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.h (revision 0)
|
---|
1027 | @@ -0,0 +1,51 @@
|
---|
1028 | +/* ScummVM - Graphic Adventure Engine
|
---|
1029 | + *
|
---|
1030 | + * ScummVM is the legal property of its developers, whose names
|
---|
1031 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
1032 | + * file distributed with this source distribution.
|
---|
1033 | + *
|
---|
1034 | + * This program is free software; you can redistribute it and/or
|
---|
1035 | + * modify it under the terms of the GNU General Public License
|
---|
1036 | + * as published by the Free Software Foundation; either version 2
|
---|
1037 | + * of the License, or (at your option) any later version.
|
---|
1038 | + *
|
---|
1039 | + * This program is distributed in the hope that it will be useful,
|
---|
1040 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
1041 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
1042 | + * GNU General Public License for more details.
|
---|
1043 | + *
|
---|
1044 | + * You should have received a copy of the GNU General Public License
|
---|
1045 | + * along with this program; if not, write to the Free Software
|
---|
1046 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
1047 | + *
|
---|
1048 | + * $URL: $
|
---|
1049 | + * $Id: $
|
---|
1050 | + */
|
---|
1051 | +
|
---|
1052 | +#ifndef DS_FILESYSTEM_FACTORY_H
|
---|
1053 | +#define DS_FILESYSTEM_FACTORY_H
|
---|
1054 | +
|
---|
1055 | +#include "common/singleton.h"
|
---|
1056 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
1057 | +
|
---|
1058 | +/**
|
---|
1059 | + * Creates DSFilesystemNode objects.
|
---|
1060 | + *
|
---|
1061 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
1062 | + */
|
---|
1063 | +class DSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<DSFilesystemFactory> {
|
---|
1064 | +public:
|
---|
1065 | + typedef Common::String String;
|
---|
1066 | +
|
---|
1067 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
1068 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
1069 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
1070 | +
|
---|
1071 | +protected:
|
---|
1072 | + DSFilesystemFactory() {};
|
---|
1073 | +
|
---|
1074 | +private:
|
---|
1075 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
1076 | +};
|
---|
1077 | +
|
---|
1078 | +#endif /*DS_FILESYSTEM_FACTORY_H*/
|
---|
1079 |
|
---|
1080 | Property changes on: /home/david/Projects/scummvm/backends/fs/ds/ds-fs-factory.h
|
---|
1081 | ___________________________________________________________________
|
---|
1082 | Name: svn:eol-style
|
---|
1083 | + native
|
---|
1084 | Name: svn:keywords
|
---|
1085 | + Date Rev Author URL Id
|
---|
1086 | Name: svn:mime-type
|
---|
1087 | + text/plain
|
---|
1088 |
|
---|
1089 | Index: /home/david/Projects/scummvm/backends/fs/ds/ds-fs.cpp
|
---|
1090 | ===================================================================
|
---|
1091 | --- /home/david/Projects/scummvm/backends/fs/ds/ds-fs.cpp (revision 28941)
|
---|
1092 | +++ /home/david/Projects/scummvm/backends/fs/ds/ds-fs.cpp (working copy)
|
---|
1093 | @@ -20,10 +20,8 @@
|
---|
1094 | *
|
---|
1095 | */
|
---|
1096 |
|
---|
1097 | -
|
---|
1098 | #include "stdafx.h"
|
---|
1099 | #include "str.h"
|
---|
1100 | -#include "fs.h"
|
---|
1101 | #include "common/util.h"
|
---|
1102 | //#include <NDS/ARM9/console.h> //basic print funcionality
|
---|
1103 | #include "ds-fs.h"
|
---|
1104 | @@ -30,14 +28,10 @@
|
---|
1105 | #include "dsmain.h"
|
---|
1106 | #include "gba_nds_fat.h"
|
---|
1107 |
|
---|
1108 | -
|
---|
1109 | namespace DS {
|
---|
1110 |
|
---|
1111 | -
|
---|
1112 | -
|
---|
1113 | -
|
---|
1114 | //////////////////////////////////////////////////////////////
|
---|
1115 | -// DSFileSystemNode - Flash ROM file system using Zip files
|
---|
1116 | +// DSFileSystemNode - Flash ROM file system using Zip files //
|
---|
1117 | //////////////////////////////////////////////////////////////
|
---|
1118 |
|
---|
1119 | ZipFile* DSFileSystemNode::_zipFile = NULL;
|
---|
1120 | @@ -66,7 +60,6 @@
|
---|
1121 | char disp[128];
|
---|
1122 | char* pathStr = (char *) path.c_str();
|
---|
1123 |
|
---|
1124 | -
|
---|
1125 | int lastSlash = 3;
|
---|
1126 | for (int r = 0; r < (int) strlen(pathStr) - 1; r++) {
|
---|
1127 | if (path[r] == '\\') {
|
---|
1128 | @@ -81,8 +74,6 @@
|
---|
1129 | // _isValid = true;
|
---|
1130 | // _isDirectory = false;
|
---|
1131 |
|
---|
1132 | -
|
---|
1133 | -
|
---|
1134 | if (!strncmp(pathStr, "ds:/", 4)) {
|
---|
1135 | pathStr += 4;
|
---|
1136 | }
|
---|
1137 | @@ -87,7 +78,6 @@
|
---|
1138 | pathStr += 4;
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 | -
|
---|
1142 | if (*pathStr == '\0') {
|
---|
1143 | _isValid = true;
|
---|
1144 | _isDirectory = true;
|
---|
1145 | @@ -130,35 +120,10 @@
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | DSFileSystemNode::DSFileSystemNode(const DSFileSystemNode* node) {
|
---|
1149 | -
|
---|
1150 | + //TODO: not implemented?
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | -AbstractFilesystemNode* DSFileSystemNode::parent() const {
|
---|
1154 | -// consolePrintf("parent\n");
|
---|
1155 | - DSFileSystemNode *p;
|
---|
1156 | -
|
---|
1157 | - if (_path != "ds:/") {
|
---|
1158 | - char *path = (char *) _path.c_str();
|
---|
1159 | - int lastSlash = 4;
|
---|
1160 | -
|
---|
1161 | - for (int r = 4; r < (int) strlen((char *) path); r++) {
|
---|
1162 | - if (path[r] == '\\') {
|
---|
1163 | - lastSlash = r;
|
---|
1164 | - }
|
---|
1165 | - }
|
---|
1166 | -
|
---|
1167 | - p = new DSFileSystemNode(String(path, lastSlash));
|
---|
1168 | - ((DSFileSystemNode *) (p))->_isDirectory = true;
|
---|
1169 | - } else {
|
---|
1170 | - p = new DSFileSystemNode();
|
---|
1171 | - }
|
---|
1172 | -
|
---|
1173 | - return p;
|
---|
1174 | -
|
---|
1175 | -}
|
---|
1176 | -
|
---|
1177 | -
|
---|
1178 | -AbstractFilesystemNode *DSFileSystemNode::child(const Common::String& n) const {
|
---|
1179 | +AbstractFilesystemNode *DSFileSystemNode::getChild(const Common::String& n) const {
|
---|
1180 | if (_path.lastChar() == '\\') {
|
---|
1181 | return new DSFileSystemNode(_path + n);
|
---|
1182 | } else {
|
---|
1183 | @@ -168,14 +133,12 @@
|
---|
1184 | return NULL;
|
---|
1185 | }
|
---|
1186 |
|
---|
1187 | -
|
---|
1188 | -bool DSFileSystemNode::listDir(AbstractFSList &dirList, ListMode mode) const {
|
---|
1189 | +bool DSFileSystemNode::getChildren(AbstractFSList &dirList, ListMode mode, bool hidden) const {
|
---|
1190 | // consolePrintf("Listdir\n");
|
---|
1191 | -
|
---|
1192 | -
|
---|
1193 | // consolePrintf("Directory\n");
|
---|
1194 |
|
---|
1195 | -
|
---|
1196 | + //TODO: honor the hidden flag
|
---|
1197 | +
|
---|
1198 | char temp[128];
|
---|
1199 | strcpy(temp, _path.c_str());
|
---|
1200 |
|
---|
1201 | @@ -190,7 +153,8 @@
|
---|
1202 | /* // This is the root dir, so add the RAM folder
|
---|
1203 | DSFileSystemNode* dsfsn = new DSFileSystemNode("ds:/ram");
|
---|
1204 | dsfsn->_isDirectory = true;
|
---|
1205 | - dirList->push_back(wrap(dsfsn));*/
|
---|
1206 | + dirList->push_back(wrap(dsfsn));
|
---|
1207 | +*/
|
---|
1208 | }
|
---|
1209 | } else {
|
---|
1210 | _zipFile->changeDirectory(temp);
|
---|
1211 | @@ -196,8 +160,6 @@
|
---|
1212 | _zipFile->changeDirectory(temp);
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 | -
|
---|
1216 | -
|
---|
1217 | if (_zipFile->restartFile()) {
|
---|
1218 | do {
|
---|
1219 | char n[128];
|
---|
1220 | @@ -218,12 +180,32 @@
|
---|
1221 | return true;
|
---|
1222 | }
|
---|
1223 |
|
---|
1224 | +AbstractFilesystemNode* DSFileSystemNode::getParent() const {
|
---|
1225 | +// consolePrintf("parent\n");
|
---|
1226 | + DSFileSystemNode *p;
|
---|
1227 | +
|
---|
1228 | + if (_path != "ds:/") {
|
---|
1229 | + char *path = (char *) _path.c_str();
|
---|
1230 | + int lastSlash = 4;
|
---|
1231 | +
|
---|
1232 | + for (int r = 4; r < (int) strlen((char *) path); r++) {
|
---|
1233 | + if (path[r] == '\\') {
|
---|
1234 | + lastSlash = r;
|
---|
1235 | + }
|
---|
1236 | + }
|
---|
1237 |
|
---|
1238 | + p = new DSFileSystemNode(String(path, lastSlash));
|
---|
1239 | + ((DSFileSystemNode *) (p))->_isDirectory = true;
|
---|
1240 | + } else {
|
---|
1241 | + p = new DSFileSystemNode();
|
---|
1242 | + }
|
---|
1243 |
|
---|
1244 | + return p;
|
---|
1245 | +}
|
---|
1246 |
|
---|
1247 | -/////////////////////////////////////////////////////////////////////////
|
---|
1248 | -// GBAMPFileSystemNode - File system using GBA Movie Player and CF card
|
---|
1249 | -/////////////////////////////////////////////////////////////////////////
|
---|
1250 | +//////////////////////////////////////////////////////////////////////////
|
---|
1251 | +// GBAMPFileSystemNode - File system using GBA Movie Player and CF card //
|
---|
1252 | +//////////////////////////////////////////////////////////////////////////
|
---|
1253 |
|
---|
1254 | GBAMPFileSystemNode::GBAMPFileSystemNode() {
|
---|
1255 | _displayName = "mp:/";
|
---|
1256 | @@ -290,35 +272,10 @@
|
---|
1257 |
|
---|
1258 |
|
---|
1259 | GBAMPFileSystemNode::GBAMPFileSystemNode(const GBAMPFileSystemNode* node) {
|
---|
1260 | -
|
---|
1261 | + //TODO: not implemented?
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | -
|
---|
1265 | -AbstractFilesystemNode* GBAMPFileSystemNode::parent() const {
|
---|
1266 | -// consolePrintf("parent\n");
|
---|
1267 | - GBAMPFileSystemNode *p;
|
---|
1268 | -
|
---|
1269 | - if (_path != "mp:/") {
|
---|
1270 | - char *path = (char *) _path.c_str();
|
---|
1271 | - int lastSlash = 4;
|
---|
1272 | -
|
---|
1273 | - for (int r = 4; r < (int) strlen((char *) path); r++) {
|
---|
1274 | - if (path[r] == '/') {
|
---|
1275 | - lastSlash = r;
|
---|
1276 | - }
|
---|
1277 | - }
|
---|
1278 | -
|
---|
1279 | - p = new GBAMPFileSystemNode(String(path, lastSlash));
|
---|
1280 | - p->_isDirectory = true;
|
---|
1281 | - } else {
|
---|
1282 | - p = new GBAMPFileSystemNode();
|
---|
1283 | - }
|
---|
1284 | -
|
---|
1285 | - return p;
|
---|
1286 | -
|
---|
1287 | -}
|
---|
1288 | -
|
---|
1289 | -AbstractFilesystemNode *GBAMPFileSystemNode::child(const Common::String& n) const {
|
---|
1290 | +AbstractFilesystemNode *GBAMPFileSystemNode::getChild(const Common::String& n) const {
|
---|
1291 | if (_path.lastChar() == '\\') {
|
---|
1292 | return new DSFileSystemNode(_path + n);
|
---|
1293 | } else {
|
---|
1294 | @@ -328,9 +285,11 @@
|
---|
1295 | return NULL;
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | -bool GBAMPFileSystemNode::listDir(AbstractFSList& dirList, ListMode mode) const {
|
---|
1299 | +bool GBAMPFileSystemNode::getChildren(AbstractFSList& dirList, ListMode mode, bool hidden) const {
|
---|
1300 | // consolePrintf("Listdir\n");
|
---|
1301 |
|
---|
1302 | + //TODO: honor the hidden flag
|
---|
1303 | +
|
---|
1304 | enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 };
|
---|
1305 |
|
---|
1306 | char temp[128], fname[128], *path, *pathTemp;
|
---|
1307 | @@ -346,7 +305,6 @@
|
---|
1308 | pathTemp++;
|
---|
1309 | }
|
---|
1310 |
|
---|
1311 | -
|
---|
1312 | // consolePrintf("This dir: %s\n", path);
|
---|
1313 | FAT_chdir(path);
|
---|
1314 |
|
---|
1315 | @@ -369,8 +327,6 @@
|
---|
1316 | // dsfsn->_isDirectory = entryType == DIR;
|
---|
1317 | dirList.push_back((dsfsn));
|
---|
1318 | }
|
---|
1319 | -
|
---|
1320 | -
|
---|
1321 | } else {
|
---|
1322 | // consolePrintf("Skipping %s\n", fname);
|
---|
1323 | }
|
---|
1324 | @@ -385,6 +341,28 @@
|
---|
1325 | return true;
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | +AbstractFilesystemNode* GBAMPFileSystemNode::getParent() const {
|
---|
1329 | +// consolePrintf("parent\n");
|
---|
1330 | + GBAMPFileSystemNode *p;
|
---|
1331 | +
|
---|
1332 | + if (_path != "mp:/") {
|
---|
1333 | + char *path = (char *) _path.c_str();
|
---|
1334 | + int lastSlash = 4;
|
---|
1335 | +
|
---|
1336 | + for (int r = 4; r < (int) strlen((char *) path); r++) {
|
---|
1337 | + if (path[r] == '/') {
|
---|
1338 | + lastSlash = r;
|
---|
1339 | + }
|
---|
1340 | + }
|
---|
1341 | +
|
---|
1342 | + p = new GBAMPFileSystemNode(String(path, lastSlash));
|
---|
1343 | + p->_isDirectory = true;
|
---|
1344 | + } else {
|
---|
1345 | + p = new GBAMPFileSystemNode();
|
---|
1346 | + }
|
---|
1347 | +
|
---|
1348 | + return p;
|
---|
1349 | +}
|
---|
1350 |
|
---|
1351 | // Stdio replacements
|
---|
1352 | #define MAX_FILE_HANDLES 32
|
---|
1353 | @@ -393,9 +371,6 @@
|
---|
1354 | DS::fileHandle handle[MAX_FILE_HANDLES];
|
---|
1355 |
|
---|
1356 | FILE* std_fopen(const char* name, const char* mode) {
|
---|
1357 | -
|
---|
1358 | -
|
---|
1359 | -
|
---|
1360 | if (!inited) {
|
---|
1361 | for (int r = 0; r < MAX_FILE_HANDLES; r++) {
|
---|
1362 | handle[r].used = false;
|
---|
1363 | @@ -403,9 +378,6 @@
|
---|
1364 | inited = true;
|
---|
1365 | currentDir[0] = '\0';
|
---|
1366 | }
|
---|
1367 | -
|
---|
1368 | -
|
---|
1369 | -
|
---|
1370 |
|
---|
1371 | char* realName = (char *) name;
|
---|
1372 |
|
---|
1373 | @@ -413,7 +385,7 @@
|
---|
1374 | if ((name[0] == 'd') && (name[1] == 's') && (name[2] == ':') && (name[3] == '/')) {
|
---|
1375 | realName += 4;
|
---|
1376 | }
|
---|
1377 | -
|
---|
1378 | +
|
---|
1379 | if ((name[0] == 'm') && (name[1] == 'p') && (name[2] == ':') && (name[3] == '/')) {
|
---|
1380 | realName += 4;
|
---|
1381 | }
|
---|
1382 | @@ -421,7 +393,6 @@
|
---|
1383 | // consolePrintf("Open file:");
|
---|
1384 | // consolePrintf("'%s', [%s]", realName, mode);
|
---|
1385 |
|
---|
1386 | -
|
---|
1387 | if (DS::isGBAMPAvailable()) {
|
---|
1388 | FAT_chdir("/");
|
---|
1389 |
|
---|
1390 | @@ -443,10 +414,9 @@
|
---|
1391 |
|
---|
1392 | return (FILE *) result;
|
---|
1393 | }
|
---|
1394 | -
|
---|
1395 |
|
---|
1396 | // Fail to open file for writing. It's in ROM!
|
---|
1397 | -
|
---|
1398 | +
|
---|
1399 | // Allocate a file handle
|
---|
1400 | int r = 0;
|
---|
1401 | while (handle[r].used) r++;
|
---|
1402 | @@ -459,7 +429,6 @@
|
---|
1403 | handle[r].sramFile = (DSSaveFile *) DSSaveFileManager::instance()->openSavefile(realName, false);
|
---|
1404 | }
|
---|
1405 |
|
---|
1406 | -
|
---|
1407 | if (handle[r].sramFile) {
|
---|
1408 | handle[r].used = true;
|
---|
1409 | handle[r].pos = 0;
|
---|
1410 | @@ -513,6 +482,7 @@
|
---|
1411 | return NULL;
|
---|
1412 | }
|
---|
1413 | }
|
---|
1414 | +
|
---|
1415 | void std_fclose(FILE* handle) {
|
---|
1416 |
|
---|
1417 | if (DS::isGBAMPAvailable()) {
|
---|
1418 | @@ -528,14 +498,9 @@
|
---|
1419 | }
|
---|
1420 |
|
---|
1421 | size_t std_fread(const void* ptr, size_t size, size_t numItems, FILE* handle) {
|
---|
1422 | -
|
---|
1423 | // consolePrintf("fread %d,%d %d ", size, numItems, ptr);
|
---|
1424 | -
|
---|
1425 | -
|
---|
1426 |
|
---|
1427 | if (DS::isGBAMPAvailable()) {
|
---|
1428 | -
|
---|
1429 | -
|
---|
1430 | int bytes = FAT_fread((void *) ptr, size, numItems, (FAT_FILE *) handle);
|
---|
1431 | if (!std_feof(handle)) {
|
---|
1432 | return numItems;
|
---|
1433 | @@ -560,9 +525,8 @@
|
---|
1434 |
|
---|
1435 | }
|
---|
1436 |
|
---|
1437 | - return item;*/
|
---|
1438 | -
|
---|
1439 | -
|
---|
1440 | + return item;
|
---|
1441 | +*/
|
---|
1442 | int items = 0;
|
---|
1443 |
|
---|
1444 | //for (int r = 0; r < numItems; r++) {
|
---|
1445 | @@ -567,9 +531,6 @@
|
---|
1446 |
|
---|
1447 | //for (int r = 0; r < numItems; r++) {
|
---|
1448 | if (!std_feof(handle)) {
|
---|
1449 | -
|
---|
1450 | -
|
---|
1451 | -
|
---|
1452 | /* for (int t = 0; t < size; t++) {
|
---|
1453 | if (feof(handle)) eof = true;
|
---|
1454 | *(((char *) (ptr)) + r * size + t) = getc(handle);
|
---|
1455 | @@ -576,6 +537,7 @@
|
---|
1456 | }*/
|
---|
1457 | int left = size * numItems;
|
---|
1458 | int bytesRead = -1;
|
---|
1459 | +
|
---|
1460 | while ((left > 0) && (!FAT_feof((FAT_FILE *) handle))) {
|
---|
1461 | int amount = left > 8192? 8192: left;
|
---|
1462 | // do {
|
---|
1463 | @@ -580,7 +542,7 @@
|
---|
1464 | int amount = left > 8192? 8192: left;
|
---|
1465 | // do {
|
---|
1466 | bytesRead = FAT_fread((void *) ptr, 1, amount, (FAT_FILE *) handle);
|
---|
1467 | - /* if (bytesRead == 0) {
|
---|
1468 | +/* if (bytesRead == 0) {
|
---|
1469 | consolePrintf("Pos:%d items:%d num:%d amount:%d read:%d\n", ftell(handle), items, numItems, amount, bytesRead);
|
---|
1470 | left++;
|
---|
1471 |
|
---|
1472 | @@ -592,8 +554,10 @@
|
---|
1473 | fread(ptr, 1024, 1, handle);
|
---|
1474 | swiWaitForVBlank();
|
---|
1475 | //while (true);
|
---|
1476 | - }*/
|
---|
1477 | - //} while (bytesRead == 0);
|
---|
1478 | + }
|
---|
1479 | +
|
---|
1480 | + } while (bytesRead == 0);
|
---|
1481 | +*/
|
---|
1482 | left -= bytesRead;
|
---|
1483 | ptr = ((char *) (ptr)) + bytesRead;
|
---|
1484 | }
|
---|
1485 | @@ -599,15 +563,11 @@
|
---|
1486 | }
|
---|
1487 |
|
---|
1488 | items = numItems - (left / size);
|
---|
1489 | -
|
---|
1490 | -
|
---|
1491 | -
|
---|
1492 | -
|
---|
1493 | +
|
---|
1494 | // FAT_fread((void *) ptr, size, 1, ((int) (handle)) - 1);
|
---|
1495 | - // ptr = ((char *) (ptr)) + size;
|
---|
1496 | -
|
---|
1497 | +// ptr = ((char *) (ptr)) + size;
|
---|
1498 | }
|
---|
1499 | - //}
|
---|
1500 | +// }
|
---|
1501 |
|
---|
1502 | // consolePrintf("...done %d \n", items)
|
---|
1503 |
|
---|
1504 | @@ -612,7 +572,6 @@
|
---|
1505 | // consolePrintf("...done %d \n", items)
|
---|
1506 |
|
---|
1507 | return items;
|
---|
1508 | -
|
---|
1509 | }
|
---|
1510 |
|
---|
1511 | if (handle->sramFile) {
|
---|
1512 | @@ -630,7 +589,6 @@
|
---|
1513 | return bytes / size;
|
---|
1514 | }
|
---|
1515 |
|
---|
1516 | -
|
---|
1517 | if (handle->pos + size * numItems > handle->size) {
|
---|
1518 | numItems = (handle->size - handle->pos) / size;
|
---|
1519 | if (numItems < 0) numItems = 0;
|
---|
1520 | @@ -639,10 +597,8 @@
|
---|
1521 | // consolePrintf("read %d ", size * numItems);
|
---|
1522 |
|
---|
1523 | memcpy((void *) ptr, handle->data + handle->pos, size * numItems);
|
---|
1524 | -
|
---|
1525 | handle->pos += size * numItems;
|
---|
1526 |
|
---|
1527 | -
|
---|
1528 | return numItems;
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | @@ -657,7 +613,6 @@
|
---|
1532 | //consolePrintf("fwrite size=%d\n", size * numItems);
|
---|
1533 |
|
---|
1534 | if (DS::isGBAMPAvailable()) {
|
---|
1535 | -
|
---|
1536 | FAT_fwrite(((char *) (ptr)), size, numItems, (FAT_FILE *) handle);
|
---|
1537 | return numItems;
|
---|
1538 |
|
---|
1539 | @@ -675,7 +630,6 @@
|
---|
1540 | return numItems;
|
---|
1541 | }
|
---|
1542 |
|
---|
1543 | -
|
---|
1544 | if (handle->sramFile) {
|
---|
1545 | handle->sramFile->write(ptr, size);
|
---|
1546 | return size;
|
---|
1547 | @@ -704,6 +658,7 @@
|
---|
1548 | }
|
---|
1549 |
|
---|
1550 | void std_fflush(FILE* handle) {
|
---|
1551 | + //FIXME: not implemented?
|
---|
1552 | // consolePrintf("fflush ");
|
---|
1553 | }
|
---|
1554 |
|
---|
1555 | @@ -711,7 +666,6 @@
|
---|
1556 | // consolePrintf("fgets file=%d ", file);
|
---|
1557 |
|
---|
1558 | if (DS::isGBAMPAvailable()) {
|
---|
1559 | -
|
---|
1560 | char* s = str;
|
---|
1561 | while ((*s++ = std_getc(file)) >= 32) {
|
---|
1562 | // consolePrintf("%d ", *s);
|
---|
1563 | @@ -723,7 +677,6 @@
|
---|
1564 | return str;
|
---|
1565 | }
|
---|
1566 |
|
---|
1567 | -
|
---|
1568 | if (file->sramFile) {
|
---|
1569 | file->pos--;
|
---|
1570 | int p = -1;
|
---|
1571 | @@ -743,7 +696,6 @@
|
---|
1572 | }
|
---|
1573 |
|
---|
1574 | long int std_ftell(FILE* handle) {
|
---|
1575 | -
|
---|
1576 | if (DS::isGBAMPAvailable()) {
|
---|
1577 | return FAT_ftell((FAT_FILE *) handle);
|
---|
1578 | }
|
---|
1579 | @@ -758,28 +710,19 @@
|
---|
1580 | return FAT_fseek((FAT_FILE *) handle, offset, whence);
|
---|
1581 | }
|
---|
1582 |
|
---|
1583 | -
|
---|
1584 | switch (whence) {
|
---|
1585 | - case SEEK_CUR: {
|
---|
1586 | + case SEEK_CUR:
|
---|
1587 | handle->pos += offset;
|
---|
1588 | break;
|
---|
1589 | - }
|
---|
1590 | -
|
---|
1591 | - case SEEK_SET: {
|
---|
1592 | + case SEEK_SET:
|
---|
1593 | handle->pos = offset;
|
---|
1594 | break;
|
---|
1595 | - }
|
---|
1596 | -
|
---|
1597 | - case SEEK_END: {
|
---|
1598 | + case SEEK_END:
|
---|
1599 | handle->pos = handle->size + offset;
|
---|
1600 | break;
|
---|
1601 | - }
|
---|
1602 | -
|
---|
1603 | - default: {
|
---|
1604 | + default:
|
---|
1605 | handle->pos = offset;
|
---|
1606 | break;
|
---|
1607 | - }
|
---|
1608 | -
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | return 0;
|
---|
1612 | @@ -786,6 +729,7 @@
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | void std_clearerr(FILE* handle) {
|
---|
1616 | + //FIXME: not implemented?
|
---|
1617 | // consolePrintf("clearerr ");
|
---|
1618 | }
|
---|
1619 |
|
---|
1620 | @@ -790,7 +734,6 @@
|
---|
1621 | }
|
---|
1622 |
|
---|
1623 | int std_getc(FILE* handle) {
|
---|
1624 | -
|
---|
1625 | if (DS::isGBAMPAvailable()) {
|
---|
1626 | char c;
|
---|
1627 | FAT_fread(&c, 1, 1, (FAT_FILE *) handle);
|
---|
1628 | @@ -852,24 +795,3 @@
|
---|
1629 | }
|
---|
1630 |
|
---|
1631 | } // namespace DS
|
---|
1632 | -
|
---|
1633 | -// These functions are added to AbstractFileSystemNode and are therefore outside
|
---|
1634 | -// the DS namespace.
|
---|
1635 | -
|
---|
1636 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
1637 | -// consolePrintf("New node");
|
---|
1638 | -
|
---|
1639 | - if (DS::isGBAMPAvailable()) {
|
---|
1640 | - return new DS::GBAMPFileSystemNode();
|
---|
1641 | - } else {
|
---|
1642 | - return new DS::DSFileSystemNode();
|
---|
1643 | - }
|
---|
1644 | -}
|
---|
1645 | -
|
---|
1646 | -AbstractFilesystemNode* AbstractFilesystemNode::getNodeForPath(const String& path) {
|
---|
1647 | - if (DS::isGBAMPAvailable()) {
|
---|
1648 | - return new DS::GBAMPFileSystemNode(path);
|
---|
1649 | - } else {
|
---|
1650 | - return new DS::DSFileSystemNode(path);
|
---|
1651 | - }
|
---|
1652 | -}
|
---|
1653 | Index: /home/david/Projects/scummvm/backends/fs/ds/ds-fs.h
|
---|
1654 | ===================================================================
|
---|
1655 | --- /home/david/Projects/scummvm/backends/fs/ds/ds-fs.h (revision 28941)
|
---|
1656 | +++ /home/david/Projects/scummvm/backends/fs/ds/ds-fs.h (working copy)
|
---|
1657 | @@ -23,8 +23,6 @@
|
---|
1658 | #ifndef _DS_FS_H
|
---|
1659 | #define _DS_FS_H
|
---|
1660 |
|
---|
1661 | -
|
---|
1662 | -
|
---|
1663 | //#include <NDS/ARM9/console.h>
|
---|
1664 | #include "fs.h"
|
---|
1665 | #include "zipreader.h"
|
---|
1666 | @@ -32,7 +30,6 @@
|
---|
1667 | #include "scummconsole.h"
|
---|
1668 | #include "gba_nds_fat.h"
|
---|
1669 | #include "backends/fs/abstract-fs.h"
|
---|
1670 | -//#include "backends/fs/fs.h"
|
---|
1671 |
|
---|
1672 | namespace DS {
|
---|
1673 |
|
---|
1674 | @@ -37,42 +34,78 @@
|
---|
1675 | namespace DS {
|
---|
1676 |
|
---|
1677 | /**
|
---|
1678 | + * Implementation of the ScummVM file system API.
|
---|
1679 | * This class is used when a Flash cart is in use.
|
---|
1680 | + *
|
---|
1681 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
1682 | */
|
---|
1683 | class DSFileSystemNode : public AbstractFilesystemNode {
|
---|
1684 | protected:
|
---|
1685 | - static ZipFile* _zipFile;
|
---|
1686 | -
|
---|
1687 | typedef class Common::String String;
|
---|
1688 |
|
---|
1689 | + static ZipFile* _zipFile;
|
---|
1690 | +
|
---|
1691 | String _displayName;
|
---|
1692 | + String _path;
|
---|
1693 | bool _isDirectory;
|
---|
1694 | bool _isValid;
|
---|
1695 | - String _path;
|
---|
1696 | int _refCountVal;
|
---|
1697 |
|
---|
1698 | public:
|
---|
1699 | + /**
|
---|
1700 | + * Creates a DSFilesystemNode with the root node as path.
|
---|
1701 | + */
|
---|
1702 | DSFileSystemNode();
|
---|
1703 | +
|
---|
1704 | + /**
|
---|
1705 | + * Creates a DSFilesystemNode for a given path.
|
---|
1706 | + *
|
---|
1707 | + * @param path String with the path the new node should point to.
|
---|
1708 | + */
|
---|
1709 | DSFileSystemNode(const String &path);
|
---|
1710 | - DSFileSystemNode(const DSFileSystemNode *node);
|
---|
1711 | +
|
---|
1712 | + /**
|
---|
1713 | + * Creates a DSFilesystemNode for a given path.
|
---|
1714 | + *
|
---|
1715 | + * @param path String with the path the new node should point to.
|
---|
1716 | + * @param path true if path is a directory, false otherwise.
|
---|
1717 | + */
|
---|
1718 | DSFileSystemNode(const String& path, bool isDir);
|
---|
1719 |
|
---|
1720 | - virtual String displayName() const { return _displayName; }
|
---|
1721 | - virtual String name() const { return _displayName; }
|
---|
1722 | - virtual bool isValid() const { return _isValid; }
|
---|
1723 | + /**
|
---|
1724 | + * Copy constructor.
|
---|
1725 | + */
|
---|
1726 | + DSFileSystemNode(const DSFileSystemNode *node);
|
---|
1727 | +
|
---|
1728 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
1729 | + virtual String getDisplayName() const { return _displayName; }
|
---|
1730 | + virtual String getName() const { return _displayName; }
|
---|
1731 | + virtual String getPath() const { return _path; }
|
---|
1732 | virtual bool isDirectory() const { return _isDirectory; }
|
---|
1733 | - virtual String path() const { return _path; }
|
---|
1734 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
1735 | + virtual bool isValid() const { return _isValid; }
|
---|
1736 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
1737 |
|
---|
1738 | - virtual bool listDir(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
|
---|
1739 | - virtual AbstractFilesystemNode *parent() const;
|
---|
1740 | + /**
|
---|
1741 | + * Returns a copy of this node.
|
---|
1742 | + */
|
---|
1743 | virtual AbstractFilesystemNode *clone() const { return new DSFileSystemNode(this); }
|
---|
1744 | - virtual AbstractFilesystemNode *child(const Common::String& name) const;
|
---|
1745 | + virtual AbstractFilesystemNode *getChild(const Common::String& name) const;
|
---|
1746 | + virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly, bool hidden) const;
|
---|
1747 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
1748 | +
|
---|
1749 | + /**
|
---|
1750 | + * Returns the zip file this node points to.
|
---|
1751 | + * TODO: check this documentation.
|
---|
1752 | + */
|
---|
1753 | static ZipFile* getZip() { return _zipFile; }
|
---|
1754 | };
|
---|
1755 |
|
---|
1756 | -
|
---|
1757 | -/**
|
---|
1758 | + /**
|
---|
1759 | + * Implementation of the ScummVM file system API.
|
---|
1760 | * This class is used when the GBAMP (GBA Movie Player) is used with a CompactFlash card.
|
---|
1761 | + *
|
---|
1762 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
1763 | */
|
---|
1764 | class GBAMPFileSystemNode : public AbstractFilesystemNode {
|
---|
1765 | protected:
|
---|
1766 | @@ -79,34 +112,55 @@
|
---|
1767 | typedef class Common::String String;
|
---|
1768 |
|
---|
1769 | String _displayName;
|
---|
1770 | + String _path;
|
---|
1771 | bool _isDirectory;
|
---|
1772 | bool _isValid;
|
---|
1773 | - String _path;
|
---|
1774 | -
|
---|
1775 | int _refCountVal;
|
---|
1776 |
|
---|
1777 | public:
|
---|
1778 | + /**
|
---|
1779 | + * Creates a GBAMPFilesystemNode with the root node as path.
|
---|
1780 | + */
|
---|
1781 | GBAMPFileSystemNode();
|
---|
1782 | +
|
---|
1783 | + /**
|
---|
1784 | + * Creates a GBAMPFilesystemNode for a given path.
|
---|
1785 | + *
|
---|
1786 | + * @param path String with the path the new node should point to.
|
---|
1787 | + */
|
---|
1788 | GBAMPFileSystemNode(const String &path);
|
---|
1789 | +
|
---|
1790 | + /**
|
---|
1791 | + * Creates a DSFilesystemNode for a given path.
|
---|
1792 | + *
|
---|
1793 | + * @param path String with the path the new node should point to.
|
---|
1794 | + * @param path true if path is a directory, false otherwise.
|
---|
1795 | + */
|
---|
1796 | GBAMPFileSystemNode(const String &path, bool isDirectory);
|
---|
1797 | +
|
---|
1798 | + /**
|
---|
1799 | + * Copy constructor.
|
---|
1800 | + */
|
---|
1801 | GBAMPFileSystemNode(const GBAMPFileSystemNode *node);
|
---|
1802 |
|
---|
1803 | - virtual String displayName() const { return _displayName; }
|
---|
1804 | - virtual String name() const { return _displayName; }
|
---|
1805 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
1806 | + virtual String getDisplayName() const { return _displayName; }
|
---|
1807 | + virtual String getName() const { return _displayName; }
|
---|
1808 | + virtual String getPath() const { return _path; }
|
---|
1809 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
1810 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
1811 | + virtual bool isValid() const { return _isValid; }
|
---|
1812 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
1813 |
|
---|
1814 | - virtual bool isValid() const { return _isValid; }
|
---|
1815 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
1816 | - virtual String path() const { return _path; }
|
---|
1817 | - virtual bool listDir(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly) const;
|
---|
1818 | - virtual AbstractFilesystemNode *parent() const;
|
---|
1819 | + /**
|
---|
1820 | + * Returns a copy of this node.
|
---|
1821 | + */
|
---|
1822 | virtual AbstractFilesystemNode *clone() const { return new GBAMPFileSystemNode(this); }
|
---|
1823 | - virtual AbstractFilesystemNode *child(const Common::String& name) const;
|
---|
1824 | -
|
---|
1825 | + virtual AbstractFilesystemNode *getChild(const Common::String& name) const;
|
---|
1826 | + virtual bool getChildren(AbstractFSList &list, ListMode mode = FilesystemNode::kListDirectoriesOnly, bool hidden) const;
|
---|
1827 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
1828 | };
|
---|
1829 |
|
---|
1830 | -
|
---|
1831 | -
|
---|
1832 | -
|
---|
1833 | struct fileHandle {
|
---|
1834 | int pos;
|
---|
1835 | bool used;
|
---|
1836 | @@ -116,7 +170,6 @@
|
---|
1837 | DSSaveFile* sramFile;
|
---|
1838 | };
|
---|
1839 |
|
---|
1840 | -
|
---|
1841 | #undef stderr
|
---|
1842 | #undef stdout
|
---|
1843 | #undef stdin
|
---|
1844 | @@ -140,6 +193,6 @@
|
---|
1845 | void std_cwd(char* dir);
|
---|
1846 | void std_fflush(FILE* handle);
|
---|
1847 |
|
---|
1848 | -}
|
---|
1849 | +} //namespace DS
|
---|
1850 |
|
---|
1851 | -#endif
|
---|
1852 | +#endif //_DS_FS_H
|
---|
1853 | Index: /home/david/Projects/scummvm/backends/fs/fs-factory-maker.cpp
|
---|
1854 | ===================================================================
|
---|
1855 | --- /home/david/Projects/scummvm/backends/fs/fs-factory-maker.cpp (revision 0)
|
---|
1856 | +++ /home/david/Projects/scummvm/backends/fs/fs-factory-maker.cpp (revision 0)
|
---|
1857 | @@ -0,0 +1,87 @@
|
---|
1858 | +/* ScummVM - Graphic Adventure Engine
|
---|
1859 | + *
|
---|
1860 | + * ScummVM is the legal property of its developers, whose names
|
---|
1861 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
1862 | + * file distributed with this source distribution.
|
---|
1863 | + *
|
---|
1864 | + * This program is free software; you can redistribute it and/or
|
---|
1865 | + * modify it under the terms of the GNU General Public License
|
---|
1866 | + * as published by the Free Software Foundation; either version 2
|
---|
1867 | + * of the License, or (at your option) any later version.
|
---|
1868 | + *
|
---|
1869 | + * This program is distributed in the hope that it will be useful,
|
---|
1870 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
1871 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
1872 | + * GNU General Public License for more details.
|
---|
1873 | + *
|
---|
1874 | + * You should have received a copy of the GNU General Public License
|
---|
1875 | + * along with this program; if not, write to the Free Software
|
---|
1876 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
1877 | + *
|
---|
1878 | + * $URL: $
|
---|
1879 | + * $Id: $
|
---|
1880 | + */
|
---|
1881 | +
|
---|
1882 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
1883 | +
|
---|
1884 | +/*
|
---|
1885 | + * All the following includes choose, at compile time, which specific backend will be used
|
---|
1886 | + * during the execution of the ScummVM.
|
---|
1887 | + *
|
---|
1888 | + * It has to be done this way because not all the necessary libraries will be available in
|
---|
1889 | + * all build environments. Additionally, this results in smaller binaries.
|
---|
1890 | + */
|
---|
1891 | +#if defined(__amigaos4__)
|
---|
1892 | + #include "backends/fs/amigaos4/amigaos4-fs-factory.cpp"
|
---|
1893 | +#elif defined(__DC__)
|
---|
1894 | + #include "backends/fs/dc/ronincd-fs-factory.cpp"
|
---|
1895 | +#elif defined(__DS__)
|
---|
1896 | + #include "backends/fs/ds/ds-fs-factory.cpp"
|
---|
1897 | +#elif defined(__GP32__)
|
---|
1898 | + #include "backends/fs/gp32/gp32-fs-factory.cpp"
|
---|
1899 | +#elif defined(__MORPHOS__)
|
---|
1900 | + #include "backends/fs/morphos/abox-fs-factory.cpp"
|
---|
1901 | +#elif defined(PALMOS_MODE)
|
---|
1902 | + #include "backends/fs/palmos/palmos-fs-factory.cpp"
|
---|
1903 | +#elif defined(__PLAYSTATION2__)
|
---|
1904 | + #include "backends/fs/ps2/ps2-fs-factory.cpp"
|
---|
1905 | +#elif defined(__PSP__)
|
---|
1906 | + #include "backends/fs/psp/psp-fs-factory.cpp"
|
---|
1907 | +#elif defined(__SYMBIAN32__)
|
---|
1908 | + #include "backends/fs/symbian/symbian-fs-factory.cpp"
|
---|
1909 | +#elif defined(UNIX)
|
---|
1910 | + #include "backends/fs/posix/posix-fs-factory.cpp"
|
---|
1911 | +#elif defined(WIN32)
|
---|
1912 | + #include "backends/fs/windows/windows-fs-factory.cpp"
|
---|
1913 | +#endif
|
---|
1914 | +
|
---|
1915 | +/**
|
---|
1916 | + * Creates concrete FilesystemFactory objects depending on the current architecture.
|
---|
1917 | + *
|
---|
1918 | + * @return AbstractFilesystemFactory* The specific factory for the current architecture.
|
---|
1919 | + */
|
---|
1920 | +static AbstractFilesystemFactory *makeFSFactory() {
|
---|
1921 | + #if defined(__amigaos4__)
|
---|
1922 | + return &AmigaOSFilesystemFactory::instance();
|
---|
1923 | + #elif defined(__DC__)
|
---|
1924 | + return &RoninCDFilesystemFactory::instance();
|
---|
1925 | + #elif defined(__DS__)
|
---|
1926 | + return &DSFilesystemFactory::instance();
|
---|
1927 | + #elif defined(__GP32__)
|
---|
1928 | + return &GP32FilesystemFactory::instance();
|
---|
1929 | + #elif defined(__MORPHOS__)
|
---|
1930 | + return &ABoxFilesystemFactory::instance();
|
---|
1931 | + #elif defined(PALMOS_MODE)
|
---|
1932 | + return &PalmOSFilesystemFactory::instance();
|
---|
1933 | + #elif defined(__PLAYSTATION2__)
|
---|
1934 | + return &Ps2FilesystemFactory::instance();
|
---|
1935 | + #elif defined(__PSP__)
|
---|
1936 | + return &PSPFilesystemFactory::instance();
|
---|
1937 | + #elif defined(__SYMBIAN32__)
|
---|
1938 | + return &SymbianFilesystemFactory::instance();
|
---|
1939 | + #elif defined(UNIX)
|
---|
1940 | + return &POSIXFilesystemFactory::instance();
|
---|
1941 | + #elif defined(WIN32)
|
---|
1942 | + return &WindowsFilesystemFactory::instance();
|
---|
1943 | + #endif
|
---|
1944 | +}
|
---|
1945 |
|
---|
1946 | Property changes on: /home/david/Projects/scummvm/backends/fs/fs-factory-maker.cpp
|
---|
1947 | ___________________________________________________________________
|
---|
1948 | Name: svn:eol-style
|
---|
1949 | + native
|
---|
1950 | Name: svn:keywords
|
---|
1951 | + Date Rev Author URL Id
|
---|
1952 | Name: svn:mime-type
|
---|
1953 | + text/plain
|
---|
1954 |
|
---|
1955 | Index: /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.cpp
|
---|
1956 | ===================================================================
|
---|
1957 | --- /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.cpp (revision 0)
|
---|
1958 | +++ /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.cpp (revision 0)
|
---|
1959 | @@ -0,0 +1,40 @@
|
---|
1960 | +/* ScummVM - Graphic Adventure Engine
|
---|
1961 | + *
|
---|
1962 | + * ScummVM is the legal property of its developers, whose names
|
---|
1963 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
1964 | + * file distributed with this source distribution.
|
---|
1965 | + *
|
---|
1966 | + * This program is free software; you can redistribute it and/or
|
---|
1967 | + * modify it under the terms of the GNU General Public License
|
---|
1968 | + * as published by the Free Software Foundation; either version 2
|
---|
1969 | + * of the License, or (at your option) any later version.
|
---|
1970 | + *
|
---|
1971 | + * This program is distributed in the hope that it will be useful,
|
---|
1972 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
1973 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
1974 | + * GNU General Public License for more details.
|
---|
1975 | + *
|
---|
1976 | + * You should have received a copy of the GNU General Public License
|
---|
1977 | + * along with this program; if not, write to the Free Software
|
---|
1978 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
1979 | + *
|
---|
1980 | + * $URL: $
|
---|
1981 | + * $Id: $
|
---|
1982 | + */
|
---|
1983 | +
|
---|
1984 | +#include "backends/fs/gp32/gp32-fs-factory.h"
|
---|
1985 | +#include "backends/fs/gp32/gp32-fs.cpp"
|
---|
1986 | +
|
---|
1987 | +DECLARE_SINGLETON(GP32FilesystemFactory);
|
---|
1988 | +
|
---|
1989 | +AbstractFilesystemNode *GP32FilesystemFactory::makeRootFileNode() const {
|
---|
1990 | + return new GP32FilesystemNode();
|
---|
1991 | +}
|
---|
1992 | +
|
---|
1993 | +AbstractFilesystemNode *GP32FilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
1994 | + return new GP32FilesystemNode();
|
---|
1995 | +}
|
---|
1996 | +
|
---|
1997 | +AbstractFilesystemNode *GP32FilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
1998 | + return new GP32FilesystemNode(path);
|
---|
1999 | +}
|
---|
2000 |
|
---|
2001 | Property changes on: /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.cpp
|
---|
2002 | ___________________________________________________________________
|
---|
2003 | Name: svn:eol-style
|
---|
2004 | + native
|
---|
2005 | Name: svn:keywords
|
---|
2006 | + Date Rev Author URL Id
|
---|
2007 | Name: svn:mime-type
|
---|
2008 | + text/plain
|
---|
2009 |
|
---|
2010 | Index: /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.h
|
---|
2011 | ===================================================================
|
---|
2012 | --- /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.h (revision 0)
|
---|
2013 | +++ /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.h (revision 0)
|
---|
2014 | @@ -0,0 +1,51 @@
|
---|
2015 | +/* ScummVM - Graphic Adventure Engine
|
---|
2016 | + *
|
---|
2017 | + * ScummVM is the legal property of its developers, whose names
|
---|
2018 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
2019 | + * file distributed with this source distribution.
|
---|
2020 | + *
|
---|
2021 | + * This program is free software; you can redistribute it and/or
|
---|
2022 | + * modify it under the terms of the GNU General Public License
|
---|
2023 | + * as published by the Free Software Foundation; either version 2
|
---|
2024 | + * of the License, or (at your option) any later version.
|
---|
2025 | + *
|
---|
2026 | + * This program is distributed in the hope that it will be useful,
|
---|
2027 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
2028 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
2029 | + * GNU General Public License for more details.
|
---|
2030 | + *
|
---|
2031 | + * You should have received a copy of the GNU General Public License
|
---|
2032 | + * along with this program; if not, write to the Free Software
|
---|
2033 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
2034 | + *
|
---|
2035 | + * $URL: $
|
---|
2036 | + * $Id: $
|
---|
2037 | + */
|
---|
2038 | +
|
---|
2039 | +#ifndef GP32_FILESYSTEM_FACTORY_H
|
---|
2040 | +#define GP32_FILESYSTEM_FACTORY_H
|
---|
2041 | +
|
---|
2042 | +#include "common/singleton.h"
|
---|
2043 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
2044 | +
|
---|
2045 | +/**
|
---|
2046 | + * Creates GP32FilesystemNode objects.
|
---|
2047 | + *
|
---|
2048 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
2049 | + */
|
---|
2050 | +class GP32FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<GP32FilesystemFactory> {
|
---|
2051 | +public:
|
---|
2052 | + typedef Common::String String;
|
---|
2053 | +
|
---|
2054 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
2055 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
2056 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
2057 | +
|
---|
2058 | +protected:
|
---|
2059 | + GP32FilesystemFactory() {};
|
---|
2060 | +
|
---|
2061 | +private:
|
---|
2062 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
2063 | +};
|
---|
2064 | +
|
---|
2065 | +#endif /*GP32_FILESYSTEM_FACTORY_H*/
|
---|
2066 |
|
---|
2067 | Property changes on: /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs-factory.h
|
---|
2068 | ___________________________________________________________________
|
---|
2069 | Name: svn:eol-style
|
---|
2070 | + native
|
---|
2071 | Name: svn:keywords
|
---|
2072 | + Date Rev Author URL Id
|
---|
2073 | Name: svn:mime-type
|
---|
2074 | + text/plain
|
---|
2075 |
|
---|
2076 | Index: /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs.cpp
|
---|
2077 | ===================================================================
|
---|
2078 | --- /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs.cpp (revision 28941)
|
---|
2079 | +++ /home/david/Projects/scummvm/backends/fs/gp32/gp32-fs.cpp (working copy)
|
---|
2080 | @@ -24,38 +24,81 @@
|
---|
2081 | */
|
---|
2082 |
|
---|
2083 | #include "stdafx.h"
|
---|
2084 | +#include "backends/fs/abstract-fs.h"
|
---|
2085 |
|
---|
2086 | -#include "backends/fs/abstract-fs.h"
|
---|
2087 | +#define MAX_PATH_SIZE 256
|
---|
2088 |
|
---|
2089 | +/**
|
---|
2090 | + * Implementation of the ScummVM file system API.
|
---|
2091 | + *
|
---|
2092 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
2093 | + */
|
---|
2094 | class GP32FilesystemNode : public AbstractFilesystemNode {
|
---|
2095 | protected:
|
---|
2096 | String _displayName;
|
---|
2097 | + String _path;
|
---|
2098 | bool _isDirectory;
|
---|
2099 | bool _isRoot;
|
---|
2100 | - String _path;
|
---|
2101 |
|
---|
2102 | public:
|
---|
2103 | + /**
|
---|
2104 | + * Creates a GP32FilesystemNode with the root node as path.
|
---|
2105 | + */
|
---|
2106 | GP32FilesystemNode();
|
---|
2107 | +
|
---|
2108 | + /**
|
---|
2109 | + * Creates a GP32FilesystemNode for a given path.
|
---|
2110 | + *
|
---|
2111 | + * @param path String with the path the new node should point to.
|
---|
2112 | + */
|
---|
2113 | GP32FilesystemNode(const String &path);
|
---|
2114 |
|
---|
2115 | - virtual String displayName() const { return _displayName; }
|
---|
2116 | - virtual String name() const { return _displayName; }
|
---|
2117 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
2118 | + virtual String getDisplayName() const { return _displayName; }
|
---|
2119 | + virtual String getName() const { return _displayName; }
|
---|
2120 | + virtual String getPath() const { return _path; }
|
---|
2121 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
2122 | // FIXME: isValid should return false if this Node can't be used!
|
---|
2123 | - // client code can rely on the return value.
|
---|
2124 | + // so client code can rely on the return value.
|
---|
2125 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
2126 | virtual bool isValid() const { return true; }
|
---|
2127 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
2128 | - virtual String path() const { return _path; }
|
---|
2129 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
2130 |
|
---|
2131 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
2132 | - virtual AbstractFilesystemNode *parent() const;
|
---|
2133 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
2134 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
2135 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
2136 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
2137 | };
|
---|
2138 |
|
---|
2139 | -#define MAX_PATH_SIZE 256
|
---|
2140 | -
|
---|
2141 | const char gpRootPath[] = "gp:\\";
|
---|
2142 | //char gpCurrentPath[MAX_PATH_SIZE] = "gp:\\"; // must end with '\'
|
---|
2143 |
|
---|
2144 | +/**
|
---|
2145 | + * Returns the last component of a given path.
|
---|
2146 | + *
|
---|
2147 | + * Examples:
|
---|
2148 | + * gp:\foo\bar.txt would return "\bar.txt"
|
---|
2149 | + * gp:\foo\bar\ would return "\bar\"
|
---|
2150 | + *
|
---|
2151 | + * @param str Path to obtain the last component from.
|
---|
2152 | + * @return Pointer to the first char of the last component inside str.
|
---|
2153 | + */
|
---|
2154 | +static const char *lastPathComponent(const Common::String &str) {
|
---|
2155 | + const char *start = str.c_str();
|
---|
2156 | + const char *cur = start + str.size() - 2;
|
---|
2157 | +
|
---|
2158 | + while (cur >= start && *cur != '\\') {
|
---|
2159 | + --cur;
|
---|
2160 | + }
|
---|
2161 | +
|
---|
2162 | + return cur + 1;
|
---|
2163 | +}
|
---|
2164 | +
|
---|
2165 | +/**
|
---|
2166 | + * FIXME: document this function.
|
---|
2167 | + *
|
---|
2168 | + * @param path
|
---|
2169 | + * @param convPath
|
---|
2170 | + */
|
---|
2171 | int gpMakePath(const char *path, char *convPath) {
|
---|
2172 | // copy root or current directory
|
---|
2173 | const char *p;
|
---|
2174 | @@ -106,18 +149,6 @@
|
---|
2175 | return 0;
|
---|
2176 | }
|
---|
2177 |
|
---|
2178 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
2179 | - return AbstractFilesystemNode::getRoot();
|
---|
2180 | -}
|
---|
2181 | -
|
---|
2182 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
2183 | - return new GP32FilesystemNode();
|
---|
2184 | -}
|
---|
2185 | -
|
---|
2186 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
2187 | - return new GP32FilesystemNode(path);
|
---|
2188 | -}
|
---|
2189 | -
|
---|
2190 | GP32FilesystemNode::GP32FilesystemNode() {
|
---|
2191 | _isDirectory = true;
|
---|
2192 | _isRoot = true;
|
---|
2193 | @@ -132,8 +163,8 @@
|
---|
2194 | gpMakePath(path.c_str(), convPath);
|
---|
2195 |
|
---|
2196 | _path = convPath;
|
---|
2197 | -
|
---|
2198 | pos = convPath;
|
---|
2199 | +
|
---|
2200 | while (*pos)
|
---|
2201 | if (*pos++ == '\\')
|
---|
2202 | dsplName = pos;
|
---|
2203 | @@ -150,14 +181,27 @@
|
---|
2204 | _isDirectory = true;
|
---|
2205 | }
|
---|
2206 |
|
---|
2207 | -bool GP32FilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
2208 | +AbstractFilesystemNode *GP32FilesystemNode::getChild(const String &n) const {
|
---|
2209 | + // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
2210 | + // of, do not check if this is a special node, etc.
|
---|
2211 | assert(_isDirectory);
|
---|
2212 | +
|
---|
2213 | + String newPath(_path);
|
---|
2214 | + if (_path.lastChar() != '\\')
|
---|
2215 | + newPath += '\\';
|
---|
2216 | + newPath += n;
|
---|
2217 | +
|
---|
2218 | + return new GP32FilesystemNode(newPath);
|
---|
2219 | +}
|
---|
2220 | +
|
---|
2221 | +bool GP32FilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
2222 | + assert(_isDirectory);
|
---|
2223 | +
|
---|
2224 | + //TODO: honor the hidden flag
|
---|
2225 |
|
---|
2226 | GPDIRENTRY dirEntry;
|
---|
2227 | GPFILEATTR attr;
|
---|
2228 | -
|
---|
2229 | GP32FilesystemNode entry;
|
---|
2230 | -
|
---|
2231 | uint32 read;
|
---|
2232 |
|
---|
2233 | if (mode == FilesystemNode::kListAll)
|
---|
2234 | @@ -168,9 +212,11 @@
|
---|
2235 | int startIdx = 0; // current file
|
---|
2236 | String listDir(_path);
|
---|
2237 | //listDir += "/";
|
---|
2238 | +
|
---|
2239 | while (GpDirEnumList(listDir.c_str(), startIdx++, 1, &dirEntry, &read) == SM_OK) {
|
---|
2240 | if (dirEntry.name[0] == '.')
|
---|
2241 | continue;
|
---|
2242 | +
|
---|
2243 | entry._displayName = dirEntry.name;
|
---|
2244 | entry._path = _path;
|
---|
2245 | entry._path += dirEntry.name;
|
---|
2246 | @@ -194,18 +240,7 @@
|
---|
2247 | return true;
|
---|
2248 | }
|
---|
2249 |
|
---|
2250 | -static const char *lastPathComponent(const Common::String &str) {
|
---|
2251 | - const char *start = str.c_str();
|
---|
2252 | - const char *cur = start + str.size() - 2;
|
---|
2253 | -
|
---|
2254 | - while (cur >= start && *cur != '\\') {
|
---|
2255 | - --cur;
|
---|
2256 | - }
|
---|
2257 | -
|
---|
2258 | - return cur + 1;
|
---|
2259 | -}
|
---|
2260 | -
|
---|
2261 | -AbstractFilesystemNode *GP32FilesystemNode::parent() const {
|
---|
2262 | +AbstractFilesystemNode *GP32FilesystemNode::getParent() const {
|
---|
2263 | if(_isRoot)
|
---|
2264 | return 0;
|
---|
2265 |
|
---|
2266 | @@ -218,16 +253,3 @@
|
---|
2267 |
|
---|
2268 | return p;
|
---|
2269 | }
|
---|
2270 | -
|
---|
2271 | -AbstractFilesystemNode *GP32FilesystemNode::child(const String &n) const {
|
---|
2272 | - // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
2273 | - // of, do not check if this is a special node, etc.
|
---|
2274 | - assert(_isDirectory);
|
---|
2275 | - String newPath(_path);
|
---|
2276 | - if (_path.lastChar() != '\\')
|
---|
2277 | - newPath += '\\';
|
---|
2278 | - newPath += n;
|
---|
2279 | - GP32FilesystemNode *p = new GP32FilesystemNode(newPath);
|
---|
2280 | -
|
---|
2281 | - return p;
|
---|
2282 | -}
|
---|
2283 | Index: /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.cpp
|
---|
2284 | ===================================================================
|
---|
2285 | --- /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.cpp (revision 0)
|
---|
2286 | +++ /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.cpp (revision 0)
|
---|
2287 | @@ -0,0 +1,40 @@
|
---|
2288 | +/* ScummVM - Graphic Adventure Engine
|
---|
2289 | + *
|
---|
2290 | + * ScummVM is the legal property of its developers, whose names
|
---|
2291 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
2292 | + * file distributed with this source distribution.
|
---|
2293 | + *
|
---|
2294 | + * This program is free software; you can redistribute it and/or
|
---|
2295 | + * modify it under the terms of the GNU General Public License
|
---|
2296 | + * as published by the Free Software Foundation; either version 2
|
---|
2297 | + * of the License, or (at your option) any later version.
|
---|
2298 | + *
|
---|
2299 | + * This program is distributed in the hope that it will be useful,
|
---|
2300 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
2301 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
2302 | + * GNU General Public License for more details.
|
---|
2303 | + *
|
---|
2304 | + * You should have received a copy of the GNU General Public License
|
---|
2305 | + * along with this program; if not, write to the Free Software
|
---|
2306 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
2307 | + *
|
---|
2308 | + * $URL: $
|
---|
2309 | + * $Id: $
|
---|
2310 | + */
|
---|
2311 | +
|
---|
2312 | +#include "backends/fs/morphos/abox-fs-factory.h"
|
---|
2313 | +#include "backends/fs/morphos/abox-fs.cpp"
|
---|
2314 | +
|
---|
2315 | +DECLARE_SINGLETON(ABoxFilesystemFactory);
|
---|
2316 | +
|
---|
2317 | +AbstractFilesystemNode *ABoxFilesystemFactory::makeRootFileNode() const {
|
---|
2318 | + return new ABoxFilesystemNode();
|
---|
2319 | +}
|
---|
2320 | +
|
---|
2321 | +AbstractFilesystemNode *ABoxFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
2322 | + return new ABoxFilesystemNode();
|
---|
2323 | +}
|
---|
2324 | +
|
---|
2325 | +AbstractFilesystemNode *ABoxFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
2326 | + return new ABoxFilesystemNode(path);
|
---|
2327 | +}
|
---|
2328 |
|
---|
2329 | Property changes on: /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.cpp
|
---|
2330 | ___________________________________________________________________
|
---|
2331 | Name: svn:eol-style
|
---|
2332 | + native
|
---|
2333 | Name: svn:keywords
|
---|
2334 | + Date Rev Author URL Id
|
---|
2335 | Name: svn:mime-type
|
---|
2336 | + text/plain
|
---|
2337 |
|
---|
2338 | Index: /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.h
|
---|
2339 | ===================================================================
|
---|
2340 | --- /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.h (revision 0)
|
---|
2341 | +++ /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.h (revision 0)
|
---|
2342 | @@ -0,0 +1,51 @@
|
---|
2343 | +/* ScummVM - Graphic Adventure Engine
|
---|
2344 | + *
|
---|
2345 | + * ScummVM is the legal property of its developers, whose names
|
---|
2346 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
2347 | + * file distributed with this source distribution.
|
---|
2348 | + *
|
---|
2349 | + * This program is free software; you can redistribute it and/or
|
---|
2350 | + * modify it under the terms of the GNU General Public License
|
---|
2351 | + * as published by the Free Software Foundation; either version 2
|
---|
2352 | + * of the License, or (at your option) any later version.
|
---|
2353 | + *
|
---|
2354 | + * This program is distributed in the hope that it will be useful,
|
---|
2355 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
2356 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
2357 | + * GNU General Public License for more details.
|
---|
2358 | + *
|
---|
2359 | + * You should have received a copy of the GNU General Public License
|
---|
2360 | + * along with this program; if not, write to the Free Software
|
---|
2361 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
2362 | + *
|
---|
2363 | + * $URL: $
|
---|
2364 | + * $Id: $
|
---|
2365 | + */
|
---|
2366 | +
|
---|
2367 | +#ifndef ABOX_FILESYSTEM_FACTORY_H
|
---|
2368 | +#define ABOX_FILESYSTEM_FACTORY_H
|
---|
2369 | +
|
---|
2370 | +#include "common/singleton.h"
|
---|
2371 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
2372 | +
|
---|
2373 | +/**
|
---|
2374 | + * Creates ABoxFilesystemNode objects.
|
---|
2375 | + *
|
---|
2376 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
2377 | + */
|
---|
2378 | +class ABoxFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<ABoxFilesystemFactory> {
|
---|
2379 | +public:
|
---|
2380 | + typedef Common::String String;
|
---|
2381 | +
|
---|
2382 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
2383 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
2384 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
2385 | +
|
---|
2386 | +protected:
|
---|
2387 | + ABoxFilesystemFactory() {};
|
---|
2388 | +
|
---|
2389 | +private:
|
---|
2390 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
2391 | +};
|
---|
2392 | +
|
---|
2393 | +#endif /*ABOX_FILESYSTEM_FACTORY_H*/
|
---|
2394 |
|
---|
2395 | Property changes on: /home/david/Projects/scummvm/backends/fs/morphos/abox-fs-factory.h
|
---|
2396 | ___________________________________________________________________
|
---|
2397 | Name: svn:eol-style
|
---|
2398 | + native
|
---|
2399 | Name: svn:keywords
|
---|
2400 | + Date Rev Author URL Id
|
---|
2401 | Name: svn:mime-type
|
---|
2402 | + text/plain
|
---|
2403 |
|
---|
2404 | Index: /home/david/Projects/scummvm/backends/fs/morphos/abox-fs.cpp
|
---|
2405 | ===================================================================
|
---|
2406 | --- /home/david/Projects/scummvm/backends/fs/morphos/abox-fs.cpp (revision 28941)
|
---|
2407 | +++ /home/david/Projects/scummvm/backends/fs/morphos/abox-fs.cpp (working copy)
|
---|
2408 | @@ -35,52 +35,66 @@
|
---|
2409 | #include "base/engine.h"
|
---|
2410 | #include "backends/fs/abstract-fs.h"
|
---|
2411 |
|
---|
2412 | -/*
|
---|
2413 | +/**
|
---|
2414 | * Implementation of the ScummVM file system API based on the MorphOS A-Box API.
|
---|
2415 | + *
|
---|
2416 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
2417 | */
|
---|
2418 | -
|
---|
2419 | class ABoxFilesystemNode : public AbstractFilesystemNode {
|
---|
2420 | - protected:
|
---|
2421 | - BPTR _lock;
|
---|
2422 | - String _displayName;
|
---|
2423 | - bool _isDirectory;
|
---|
2424 | - bool _isValid;
|
---|
2425 | - String _path;
|
---|
2426 | +protected:
|
---|
2427 | + BPTR _lock;
|
---|
2428 | + String _displayName;
|
---|
2429 | + String _path;
|
---|
2430 | + bool _isDirectory;
|
---|
2431 | + bool _isValid;
|
---|
2432 |
|
---|
2433 | - public:
|
---|
2434 | - ABoxFilesystemNode();
|
---|
2435 | - ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name = NULL);
|
---|
2436 | - ABoxFilesystemNode(const String &p);
|
---|
2437 | - ABoxFilesystemNode(const ABoxFilesystemNode &node);
|
---|
2438 | +public:
|
---|
2439 | + /**
|
---|
2440 | + * Creates a ABoxFilesystemNode with the root node as path.
|
---|
2441 | + */
|
---|
2442 | + ABoxFilesystemNode();
|
---|
2443 | +
|
---|
2444 | + /**
|
---|
2445 | + * Creates a ABoxFilesystemNode for a given path.
|
---|
2446 | + *
|
---|
2447 | + * @param path String with the path the new node should point to.
|
---|
2448 | + */
|
---|
2449 | + ABoxFilesystemNode(const String &p);
|
---|
2450 | +
|
---|
2451 | + /**
|
---|
2452 | + * FIXME: document this constructor.
|
---|
2453 | + */
|
---|
2454 | + ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name = NULL);
|
---|
2455 | +
|
---|
2456 | + /**
|
---|
2457 | + * Copy constructor.
|
---|
2458 | + */
|
---|
2459 | + ABoxFilesystemNode(const ABoxFilesystemNode &node);
|
---|
2460 |
|
---|
2461 | - ~ABoxFilesystemNode();
|
---|
2462 | + /**
|
---|
2463 | + * Destructor.
|
---|
2464 | + */
|
---|
2465 | + ~ABoxFilesystemNode();
|
---|
2466 |
|
---|
2467 | - virtual String displayName() const { return _displayName; }
|
---|
2468 | - virtual String name() const { return _displayName; };
|
---|
2469 | - virtual bool isValid() const { return _isValid; }
|
---|
2470 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
2471 | - virtual String path() const { return _path; }
|
---|
2472 | -
|
---|
2473 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
2474 | - static AbstractFSList listRoot();
|
---|
2475 | - virtual AbstractFilesystemNode *parent() const;
|
---|
2476 | - virtual AbstractFilesystemNode *child(const String &name) const;
|
---|
2477 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
2478 | + virtual String getDisplayName() const { return _displayName; }
|
---|
2479 | + virtual String getName() const { return _displayName; };
|
---|
2480 | + virtual String getPath() const { return _path; }
|
---|
2481 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
2482 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
2483 | + virtual bool isValid() const { return _isValid; }
|
---|
2484 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
2485 | +
|
---|
2486 | + virtual AbstractFilesystemNode *getChild(const String &name) const;
|
---|
2487 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
2488 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
2489 | +
|
---|
2490 | + /**
|
---|
2491 | + * Return the list of child nodes for the root node.
|
---|
2492 | + */
|
---|
2493 | + static AbstractFSList getRootChildren();
|
---|
2494 | };
|
---|
2495 |
|
---|
2496 | -
|
---|
2497 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
2498 | - return AbstractFilesystemNode::getRoot();
|
---|
2499 | -}
|
---|
2500 | -
|
---|
2501 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
2502 | - return new ABoxFilesystemNode(path);
|
---|
2503 | -}
|
---|
2504 | -
|
---|
2505 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot()
|
---|
2506 | -{
|
---|
2507 | - return new ABoxFilesystemNode();
|
---|
2508 | -}
|
---|
2509 | -
|
---|
2510 | ABoxFilesystemNode::ABoxFilesystemNode()
|
---|
2511 | {
|
---|
2512 | _displayName = "Mounted Volumes";
|
---|
2513 | @@ -90,57 +104,6 @@
|
---|
2514 | _lock = NULL;
|
---|
2515 | }
|
---|
2516 |
|
---|
2517 | -ABoxFilesystemNode::ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name)
|
---|
2518 | -{
|
---|
2519 | - int bufsize = 256;
|
---|
2520 | -
|
---|
2521 | - _lock = NULL;
|
---|
2522 | - for (;;)
|
---|
2523 | - {
|
---|
2524 | - char name[bufsize];
|
---|
2525 | - if (NameFromLock(lock, name, bufsize) != DOSFALSE)
|
---|
2526 | - {
|
---|
2527 | - _path = name;
|
---|
2528 | - _displayName = display_name ? display_name : FilePart(name);
|
---|
2529 | - break;
|
---|
2530 | - }
|
---|
2531 | - if (IoErr() != ERROR_LINE_TOO_LONG)
|
---|
2532 | - {
|
---|
2533 | - _isValid = false;
|
---|
2534 | - debug(6, "Error while retrieving path name: %ld", IoErr());
|
---|
2535 | - return;
|
---|
2536 | - }
|
---|
2537 | - bufsize *= 2;
|
---|
2538 | - }
|
---|
2539 | -
|
---|
2540 | - _isDirectory = false;
|
---|
2541 | - _isValid = false;
|
---|
2542 | -
|
---|
2543 | - FileInfoBlock *fib = (FileInfoBlock*) AllocDosObject(DOS_FIB, NULL);
|
---|
2544 | - if (fib == NULL)
|
---|
2545 | - {
|
---|
2546 | - debug(6, "Failed to allocate memory for FileInfoBlock");
|
---|
2547 | - return;
|
---|
2548 | - }
|
---|
2549 | -
|
---|
2550 | - if (Examine(lock, fib) != DOSFALSE)
|
---|
2551 | - {
|
---|
2552 | - _isDirectory = fib->fib_EntryType > 0;
|
---|
2553 | - if (_isDirectory)
|
---|
2554 | - {
|
---|
2555 | - if (fib->fib_EntryType != ST_ROOT)
|
---|
2556 | - _path += "/";
|
---|
2557 | - _lock = DupLock(lock);
|
---|
2558 | - _isValid = (_lock != NULL);
|
---|
2559 | - }
|
---|
2560 | - else
|
---|
2561 | - {
|
---|
2562 | - _isValid = true;
|
---|
2563 | - }
|
---|
2564 | - }
|
---|
2565 | - FreeDosObject(DOS_FIB, fib);
|
---|
2566 | -}
|
---|
2567 | -
|
---|
2568 | ABoxFilesystemNode::ABoxFilesystemNode(const String &p) {
|
---|
2569 | int len = 0, offset = p.size();
|
---|
2570 |
|
---|
2571 | @@ -168,7 +131,6 @@
|
---|
2572 | }
|
---|
2573 |
|
---|
2574 | // Check whether the node exists and if it is a directory
|
---|
2575 | -
|
---|
2576 | BPTR pLock = Lock((STRPTR)_path.c_str(), SHARED_LOCK);
|
---|
2577 | if (pLock)
|
---|
2578 | {
|
---|
2579 | @@ -198,6 +160,58 @@
|
---|
2580 | FreeDosObject(DOS_FIB, fib);
|
---|
2581 | }
|
---|
2582 |
|
---|
2583 | +ABoxFilesystemNode::ABoxFilesystemNode(BPTR lock, CONST_STRPTR display_name)
|
---|
2584 | +{
|
---|
2585 | + int bufsize = 256;
|
---|
2586 | +
|
---|
2587 | + _lock = NULL;
|
---|
2588 | + for (;;)
|
---|
2589 | + {
|
---|
2590 | + char name[bufsize];
|
---|
2591 | + if (NameFromLock(lock, name, bufsize) != DOSFALSE)
|
---|
2592 | + {
|
---|
2593 | + _path = name;
|
---|
2594 | + _displayName = display_name ? display_name : FilePart(name);
|
---|
2595 | + break;
|
---|
2596 | + }
|
---|
2597 | + if (IoErr() != ERROR_LINE_TOO_LONG)
|
---|
2598 | + {
|
---|
2599 | + _isValid = false;
|
---|
2600 | + debug(6, "Error while retrieving path name: %ld", IoErr());
|
---|
2601 | + return;
|
---|
2602 | + }
|
---|
2603 | + bufsize *= 2;
|
---|
2604 | + }
|
---|
2605 | +
|
---|
2606 | + _isDirectory = false;
|
---|
2607 | + _isValid = false;
|
---|
2608 | +
|
---|
2609 | + FileInfoBlock *fib = (FileInfoBlock*) AllocDosObject(DOS_FIB, NULL);
|
---|
2610 | + if (fib == NULL)
|
---|
2611 | + {
|
---|
2612 | + debug(6, "Failed to allocate memory for FileInfoBlock");
|
---|
2613 | + return;
|
---|
2614 | + }
|
---|
2615 | +
|
---|
2616 | + if (Examine(lock, fib) != DOSFALSE)
|
---|
2617 | + {
|
---|
2618 | + _isDirectory = fib->fib_EntryType > 0;
|
---|
2619 | + if (_isDirectory)
|
---|
2620 | + {
|
---|
2621 | + if (fib->fib_EntryType != ST_ROOT)
|
---|
2622 | + _path += "/";
|
---|
2623 | + _lock = DupLock(lock);
|
---|
2624 | + _isValid = (_lock != NULL);
|
---|
2625 | + }
|
---|
2626 | + else
|
---|
2627 | + {
|
---|
2628 | + _isValid = true;
|
---|
2629 | + }
|
---|
2630 | + }
|
---|
2631 | +
|
---|
2632 | + FreeDosObject(DOS_FIB, fib);
|
---|
2633 | +}
|
---|
2634 | +
|
---|
2635 | ABoxFilesystemNode::ABoxFilesystemNode(const ABoxFilesystemNode& node)
|
---|
2636 | {
|
---|
2637 | _displayName = node._displayName;
|
---|
2638 | @@ -216,8 +230,30 @@
|
---|
2639 | }
|
---|
2640 | }
|
---|
2641 |
|
---|
2642 | -bool ABoxFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const
|
---|
2643 | +AbstractFilesystemNode *ABoxFilesystemNode::getChild(const String &name) const {
|
---|
2644 | + assert(_isDirectory);
|
---|
2645 | + String newPath(_path);
|
---|
2646 | +
|
---|
2647 | + if (_path.lastChar() != '/')
|
---|
2648 | + newPath += '/';
|
---|
2649 | + newPath += name;
|
---|
2650 | +
|
---|
2651 | + BPTR lock = Lock(newPath.c_str(), SHARED_LOCK);
|
---|
2652 | +
|
---|
2653 | + if (!lock)
|
---|
2654 | + {
|
---|
2655 | + return 0;
|
---|
2656 | + }
|
---|
2657 | +
|
---|
2658 | + UnLock(lock);
|
---|
2659 | +
|
---|
2660 | + return new ABoxFilesystemNode(newPath);
|
---|
2661 | +}
|
---|
2662 | +
|
---|
2663 | +bool ABoxFilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const
|
---|
2664 | {
|
---|
2665 | + //TODO: honor the hidden flag
|
---|
2666 | +
|
---|
2667 | if (!_isValid)
|
---|
2668 | {
|
---|
2669 | debug(6, "listDir() called on invalid node");
|
---|
2670 | @@ -232,7 +268,7 @@
|
---|
2671 | if (_lock == NULL)
|
---|
2672 | {
|
---|
2673 | /* This is the root node */
|
---|
2674 | - myList = listRoot();
|
---|
2675 | + list = getRootChildren();
|
---|
2676 | return true;
|
---|
2677 | }
|
---|
2678 |
|
---|
2679 | @@ -266,7 +302,7 @@
|
---|
2680 | if (entry)
|
---|
2681 | {
|
---|
2682 | if (entry->isValid())
|
---|
2683 | - myList.push_back(entry);
|
---|
2684 | + list.push_back(entry);
|
---|
2685 | else
|
---|
2686 | delete entry;
|
---|
2687 | }
|
---|
2688 | @@ -284,7 +320,7 @@
|
---|
2689 | return true;
|
---|
2690 | }
|
---|
2691 |
|
---|
2692 | -AbstractFilesystemNode *ABoxFilesystemNode::parent() const
|
---|
2693 | +AbstractFilesystemNode *ABoxFilesystemNode::getParent() const
|
---|
2694 | {
|
---|
2695 | AbstractFilesystemNode *node = NULL;
|
---|
2696 |
|
---|
2697 | @@ -309,29 +345,9 @@
|
---|
2698 | return node;
|
---|
2699 | }
|
---|
2700 |
|
---|
2701 | -AbstractFilesystemNode *ABoxFilesystemNode::child(const String &name) const {
|
---|
2702 | - assert(_isDirectory);
|
---|
2703 | - String newPath(_path);
|
---|
2704 | -
|
---|
2705 | - if (_path.lastChar() != '/')
|
---|
2706 | - newPath += '/';
|
---|
2707 | - newPath += name;
|
---|
2708 | -
|
---|
2709 | - BPTR lock = Lock(newPath.c_str(), SHARED_LOCK);
|
---|
2710 | -
|
---|
2711 | - if (!lock)
|
---|
2712 | - {
|
---|
2713 | - return 0;
|
---|
2714 | - }
|
---|
2715 | -
|
---|
2716 | - UnLock(lock);
|
---|
2717 | -
|
---|
2718 | - return new ABoxFilesystemNode(newPath);
|
---|
2719 | -}
|
---|
2720 | -
|
---|
2721 | -AbstractFSList ABoxFilesystemNode::listRoot()
|
---|
2722 | +AbstractFSList ABoxFilesystemNode::getRootChildren()
|
---|
2723 | {
|
---|
2724 | - AbstractFSList myList;
|
---|
2725 | + AbstractFSList list;
|
---|
2726 | DosList *dosList;
|
---|
2727 | CONST ULONG lockDosListFlags = LDF_READ | LDF_VOLUMES;
|
---|
2728 | char name[256];
|
---|
2729 | @@ -339,7 +355,7 @@
|
---|
2730 | dosList = LockDosList(lockDosListFlags);
|
---|
2731 | if (dosList == NULL)
|
---|
2732 | {
|
---|
2733 | - return myList;
|
---|
2734 | + return list;
|
---|
2735 | }
|
---|
2736 |
|
---|
2737 | dosList = NextDosEntry(dosList, LDF_VOLUMES);
|
---|
2738 | @@ -345,9 +361,9 @@
|
---|
2739 | dosList = NextDosEntry(dosList, LDF_VOLUMES);
|
---|
2740 | while (dosList)
|
---|
2741 | {
|
---|
2742 | - if (dosList->dol_Type == DLT_VOLUME && // Should always be true, but ...
|
---|
2743 | - dosList->dol_Name && // Same here
|
---|
2744 | - dosList->dol_Task // Will be NULL if volume is removed from drive but still in use by some program
|
---|
2745 | + if (dosList->dol_Type == DLT_VOLUME && // Should always be true, but ...
|
---|
2746 | + dosList->dol_Name && // Same here
|
---|
2747 | + dosList->dol_Task // Will be NULL if volume is removed from drive but still in use by some program
|
---|
2748 | )
|
---|
2749 | {
|
---|
2750 | ABoxFilesystemNode *entry;
|
---|
2751 | @@ -365,7 +381,7 @@
|
---|
2752 | if (entry)
|
---|
2753 | {
|
---|
2754 | if (entry->isValid())
|
---|
2755 | - myList.push_back(entry);
|
---|
2756 | + list.push_back(entry);
|
---|
2757 | else
|
---|
2758 | delete entry;
|
---|
2759 | }
|
---|
2760 | @@ -377,9 +393,7 @@
|
---|
2761 |
|
---|
2762 | UnLockDosList(lockDosListFlags);
|
---|
2763 |
|
---|
2764 | - return myList;
|
---|
2765 | + return list;
|
---|
2766 | }
|
---|
2767 |
|
---|
2768 | #endif // defined(__MORPHOS__)
|
---|
2769 | -
|
---|
2770 | -
|
---|
2771 | Index: /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.cpp
|
---|
2772 | ===================================================================
|
---|
2773 | --- /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.cpp (revision 0)
|
---|
2774 | +++ /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.cpp (revision 0)
|
---|
2775 | @@ -0,0 +1,40 @@
|
---|
2776 | +/* ScummVM - Graphic Adventure Engine
|
---|
2777 | + *
|
---|
2778 | + * ScummVM is the legal property of its developers, whose names
|
---|
2779 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
2780 | + * file distributed with this source distribution.
|
---|
2781 | + *
|
---|
2782 | + * This program is free software; you can redistribute it and/or
|
---|
2783 | + * modify it under the terms of the GNU General Public License
|
---|
2784 | + * as published by the Free Software Foundation; either version 2
|
---|
2785 | + * of the License, or (at your option) any later version.
|
---|
2786 | + *
|
---|
2787 | + * This program is distributed in the hope that it will be useful,
|
---|
2788 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
2789 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
2790 | + * GNU General Public License for more details.
|
---|
2791 | + *
|
---|
2792 | + * You should have received a copy of the GNU General Public License
|
---|
2793 | + * along with this program; if not, write to the Free Software
|
---|
2794 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
2795 | + *
|
---|
2796 | + * $URL: $
|
---|
2797 | + * $Id: $
|
---|
2798 | + */
|
---|
2799 | +
|
---|
2800 | +#include "backends/fs/palmos/palmos-fs-factory.h"
|
---|
2801 | +#include "backends/fs/palmos/palmos-fs.cpp"
|
---|
2802 | +
|
---|
2803 | +DECLARE_SINGLETON(PalmOSFilesystemFactory);
|
---|
2804 | +
|
---|
2805 | +AbstractFilesystemNode *PalmOSFilesystemFactory::makeRootFileNode() const {
|
---|
2806 | + return new PalmOSFilesystemNode();
|
---|
2807 | +}
|
---|
2808 | +
|
---|
2809 | +AbstractFilesystemNode *PalmOSFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
2810 | + return new PalmOSFilesystemNode();
|
---|
2811 | +}
|
---|
2812 | +
|
---|
2813 | +AbstractFilesystemNode *PalmOSFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
2814 | + return new PalmOSFilesystemNode(path);
|
---|
2815 | +}
|
---|
2816 |
|
---|
2817 | Property changes on: /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.cpp
|
---|
2818 | ___________________________________________________________________
|
---|
2819 | Name: svn:eol-style
|
---|
2820 | + native
|
---|
2821 | Name: svn:keywords
|
---|
2822 | + Date Rev Author URL Id
|
---|
2823 | Name: svn:mime-type
|
---|
2824 | + text/plain
|
---|
2825 |
|
---|
2826 | Index: /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.h
|
---|
2827 | ===================================================================
|
---|
2828 | --- /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.h (revision 0)
|
---|
2829 | +++ /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.h (revision 0)
|
---|
2830 | @@ -0,0 +1,51 @@
|
---|
2831 | +/* ScummVM - Graphic Adventure Engine
|
---|
2832 | + *
|
---|
2833 | + * ScummVM is the legal property of its developers, whose names
|
---|
2834 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
2835 | + * file distributed with this source distribution.
|
---|
2836 | + *
|
---|
2837 | + * This program is free software; you can redistribute it and/or
|
---|
2838 | + * modify it under the terms of the GNU General Public License
|
---|
2839 | + * as published by the Free Software Foundation; either version 2
|
---|
2840 | + * of the License, or (at your option) any later version.
|
---|
2841 | + *
|
---|
2842 | + * This program is distributed in the hope that it will be useful,
|
---|
2843 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
2844 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
2845 | + * GNU General Public License for more details.
|
---|
2846 | + *
|
---|
2847 | + * You should have received a copy of the GNU General Public License
|
---|
2848 | + * along with this program; if not, write to the Free Software
|
---|
2849 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
2850 | + *
|
---|
2851 | + * $URL: $
|
---|
2852 | + * $Id: $
|
---|
2853 | + */
|
---|
2854 | +
|
---|
2855 | +#ifndef PALMOS_FILESYSTEM_FACTORY_H
|
---|
2856 | +#define PALMOS_FILESYSTEM_FACTORY_H
|
---|
2857 | +
|
---|
2858 | +#include "common/singleton.h"
|
---|
2859 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
2860 | +
|
---|
2861 | +/**
|
---|
2862 | + * Creates PalmOSFilesystemNode objects.
|
---|
2863 | + *
|
---|
2864 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
2865 | + */
|
---|
2866 | +class PalmOSFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PalmOSFilesystemFactory> {
|
---|
2867 | +public:
|
---|
2868 | + typedef Common::String String;
|
---|
2869 | +
|
---|
2870 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
2871 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
2872 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
2873 | +
|
---|
2874 | +protected:
|
---|
2875 | + PalmOSFilesystemFactory() {};
|
---|
2876 | +
|
---|
2877 | +private:
|
---|
2878 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
2879 | +};
|
---|
2880 | +
|
---|
2881 | +#endif /*PALMOS_FILESYSTEM_FACTORY_H*/
|
---|
2882 |
|
---|
2883 | Property changes on: /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs-factory.h
|
---|
2884 | ___________________________________________________________________
|
---|
2885 | Name: svn:eol-style
|
---|
2886 | + native
|
---|
2887 | Name: svn:keywords
|
---|
2888 | + Date Rev Author URL Id
|
---|
2889 | Name: svn:mime-type
|
---|
2890 | + text/plain
|
---|
2891 |
|
---|
2892 | Index: /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs.cpp
|
---|
2893 | ===================================================================
|
---|
2894 | --- /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs.cpp (revision 28941)
|
---|
2895 | +++ /home/david/Projects/scummvm/backends/fs/palmos/palmos-fs.cpp (working copy)
|
---|
2896 | @@ -30,36 +30,68 @@
|
---|
2897 | #include "common/stdafx.h"
|
---|
2898 | #include "backends/fs/abstract-fs.h"
|
---|
2899 |
|
---|
2900 | -/*
|
---|
2901 | +/**
|
---|
2902 | * Implementation of the ScummVM file system API based on PalmOS VFS API.
|
---|
2903 | + *
|
---|
2904 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
2905 | */
|
---|
2906 | -
|
---|
2907 | class PalmOSFilesystemNode : public AbstractFilesystemNode {
|
---|
2908 | protected:
|
---|
2909 | String _displayName;
|
---|
2910 | + String _path;
|
---|
2911 | bool _isDirectory;
|
---|
2912 | bool _isValid;
|
---|
2913 | bool _isPseudoRoot;
|
---|
2914 | - String _path;
|
---|
2915 |
|
---|
2916 | public:
|
---|
2917 | + /**
|
---|
2918 | + * Creates a PalmOSFilesystemNode with the root node as path.
|
---|
2919 | + */
|
---|
2920 | PalmOSFilesystemNode();
|
---|
2921 | +
|
---|
2922 | + /**
|
---|
2923 | + * Creates a POSIXFilesystemNode for a given path.
|
---|
2924 | + *
|
---|
2925 | + * @param path String with the path the new node should point to.
|
---|
2926 | + */
|
---|
2927 | PalmOSFilesystemNode(const String &p);
|
---|
2928 |
|
---|
2929 | - virtual String displayName() const { return _displayName; }
|
---|
2930 | - virtual String name() const { return _displayName; }
|
---|
2931 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
2932 | + virtual String getDisplayName() const { return _displayName; }
|
---|
2933 | + virtual String getName() const { return _displayName; }
|
---|
2934 | + virtual String getPath() const { return _path; }
|
---|
2935 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
2936 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
2937 | virtual bool isValid() const { return _isValid; }
|
---|
2938 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
2939 | - virtual String path() const { return _path; }
|
---|
2940 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
2941 |
|
---|
2942 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
2943 | - virtual AbstractFilesystemNode *parent() const;
|
---|
2944 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
2945 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
2946 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
2947 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
2948 |
|
---|
2949 | private:
|
---|
2950 | - static void addFile (AbstractFSList &list, ListMode mode, const Char *base, FileInfoType* find_data);
|
---|
2951 | + /**
|
---|
2952 | + * Adds a single WindowsFilesystemNode to a given list.
|
---|
2953 | + * This method is used by getChildren() to populate the directory entries list.
|
---|
2954 | + *
|
---|
2955 | + * @param list List to put the file entry node in.
|
---|
2956 | + * @param mode Mode to use while adding the file entry to the list.
|
---|
2957 | + * @param base String with the directory being listed.
|
---|
2958 | + * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find.
|
---|
2959 | + */
|
---|
2960 | + static void addFile(AbstractFSList &list, ListMode mode, const Char *base, FileInfoType* find_data);
|
---|
2961 | };
|
---|
2962 |
|
---|
2963 | +/**
|
---|
2964 | + * Returns the last component of a given path.
|
---|
2965 | + *
|
---|
2966 | + * Examples:
|
---|
2967 | + * /foo/bar.txt would return /bar.txt
|
---|
2968 | + * /foo/bar/ would return /bar/
|
---|
2969 | + *
|
---|
2970 | + * @param str String containing the path.
|
---|
2971 | + * @return Pointer to the first char of the last component inside str.
|
---|
2972 | + */
|
---|
2973 | static const char *lastPathComponent(const Common::String &str) {
|
---|
2974 | const char *start = str.c_str();
|
---|
2975 | const char *cur = start + str.size() - 2;
|
---|
2976 | @@ -95,19 +127,6 @@
|
---|
2977 | list.push_back(new PalmOSFilesystemNode(entry));
|
---|
2978 | }
|
---|
2979 |
|
---|
2980 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
2981 | - return AbstractFilesystemNode::getRoot();
|
---|
2982 | -}
|
---|
2983 | -
|
---|
2984 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
2985 | - return new PalmOSFilesystemNode();
|
---|
2986 | -}
|
---|
2987 | -
|
---|
2988 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
2989 | - return new PalmOSFilesystemNode(path);
|
---|
2990 | -}
|
---|
2991 | -
|
---|
2992 | -
|
---|
2993 | PalmOSFilesystemNode::PalmOSFilesystemNode() {
|
---|
2994 | _isDirectory = true;
|
---|
2995 | _displayName = "Root";
|
---|
2996 | @@ -122,13 +141,13 @@
|
---|
2997 |
|
---|
2998 | UInt32 attr;
|
---|
2999 | FileRef handle;
|
---|
3000 | - Err e = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
|
---|
3001 | - if (!e) {
|
---|
3002 | - e = VFSFileGetAttributes(handle, &attr);
|
---|
3003 | + Err error = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
|
---|
3004 | + if (!error) {
|
---|
3005 | + error = VFSFileGetAttributes(handle, &attr);
|
---|
3006 | VFSFileClose(handle);
|
---|
3007 | }
|
---|
3008 |
|
---|
3009 | - if (e) {
|
---|
3010 | + if (error) {
|
---|
3011 | _isValid = false;
|
---|
3012 | _isDirectory = false;
|
---|
3013 |
|
---|
3014 | @@ -139,8 +158,33 @@
|
---|
3015 | _isPseudoRoot = false;
|
---|
3016 | }
|
---|
3017 |
|
---|
3018 | -bool PalmOSFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
3019 | - Err e;
|
---|
3020 | +AbstractFilesystemNode *PalmOSFilesystemNode::getChild(const String &n) const {
|
---|
3021 | + assert(_isDirectory);
|
---|
3022 | +
|
---|
3023 | + String newPath(_path);
|
---|
3024 | + if (_path.lastChar() != '/')
|
---|
3025 | + newPath += '/';
|
---|
3026 | + newPath += n;
|
---|
3027 | +
|
---|
3028 | + FileRef handle;
|
---|
3029 | + UInt32 attr;
|
---|
3030 | + Err error = VFSFileOpen(gVars->VFS.volRefNum, newPath.c_str(), vfsModeRead, &handle);
|
---|
3031 | + if (error)
|
---|
3032 | + return 0;
|
---|
3033 | +
|
---|
3034 | + error = VFSFileGetAttributes(handle, &attr);
|
---|
3035 | + VFSFileClose(handle);
|
---|
3036 | +
|
---|
3037 | + if (error || !(attr & vfsFileAttrDirectory))
|
---|
3038 | + return 0;
|
---|
3039 | +
|
---|
3040 | + return new PalmOSFilesystemNode(newPath);
|
---|
3041 | +}
|
---|
3042 | +
|
---|
3043 | +bool PalmOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
3044 | + //TODO: honor the hidden flag
|
---|
3045 | +
|
---|
3046 | + Err error;
|
---|
3047 | Char nameP[256];
|
---|
3048 | FileInfoType desc;
|
---|
3049 | FileRef handle;
|
---|
3050 | @@ -148,14 +192,14 @@
|
---|
3051 |
|
---|
3052 | desc.nameP = nameP;
|
---|
3053 | desc.nameBufLen = 256;
|
---|
3054 | - e = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
|
---|
3055 | + error = VFSFileOpen(gVars->VFS.volRefNum, _path.c_str(), vfsModeRead, &handle);
|
---|
3056 |
|
---|
3057 | - if (e)
|
---|
3058 | + if (error)
|
---|
3059 | return false;
|
---|
3060 |
|
---|
3061 | while(dirIterator != expIteratorStop) {
|
---|
3062 | - e = VFSDirEntryEnumerate(handle, &dirIterator, &desc);
|
---|
3063 | - if (!e) {
|
---|
3064 | + error = VFSDirEntryEnumerate(handle, &dirIterator, &desc);
|
---|
3065 | + if (!error) {
|
---|
3066 | addFile(myList, mode, _path.c_str(), &desc);
|
---|
3067 | }
|
---|
3068 | }
|
---|
3069 | @@ -165,8 +209,7 @@
|
---|
3070 | return true;
|
---|
3071 | }
|
---|
3072 |
|
---|
3073 | -
|
---|
3074 | -AbstractFilesystemNode *PalmOSFilesystemNode::parent() const {
|
---|
3075 | +AbstractFilesystemNode *PalmOSFilesystemNode::getParent() const {
|
---|
3076 | PalmOSFilesystemNode *p = 0;
|
---|
3077 |
|
---|
3078 | if (!_isPseudoRoot) {
|
---|
3079 | @@ -180,31 +223,7 @@
|
---|
3080 | p->_displayName = lastPathComponent(p->_path);
|
---|
3081 | p->_isPseudoRoot =(p->_path == "/");
|
---|
3082 | }
|
---|
3083 | - return p;
|
---|
3084 | -}
|
---|
3085 | -
|
---|
3086 | -
|
---|
3087 | -AbstractFilesystemNode *PalmOSFilesystemNode::child(const String &n) const {
|
---|
3088 | - assert(_isDirectory);
|
---|
3089 | - String newPath(_path);
|
---|
3090 | -
|
---|
3091 | - if (_path.lastChar() != '/')
|
---|
3092 | - newPath += '/';
|
---|
3093 | - newPath += n;
|
---|
3094 | -
|
---|
3095 | - FileRef handle;
|
---|
3096 | - UInt32 attr;
|
---|
3097 | - Err e = VFSFileOpen(gVars->VFS.volRefNum, newPath.c_str(), vfsModeRead, &handle);
|
---|
3098 | - if (e)
|
---|
3099 | - return 0;
|
---|
3100 |
|
---|
3101 | - e = VFSFileGetAttributes(handle, &attr);
|
---|
3102 | - VFSFileClose(handle);
|
---|
3103 | -
|
---|
3104 | - if (e || !(attr & vfsFileAttrDirectory))
|
---|
3105 | - return 0;
|
---|
3106 | -
|
---|
3107 | - PalmOSFilesystemNode *p = new PalmOSFilesystemNode(newPath);
|
---|
3108 | return p;
|
---|
3109 | }
|
---|
3110 |
|
---|
3111 | Index: /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.cpp
|
---|
3112 | ===================================================================
|
---|
3113 | --- /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.cpp (revision 0)
|
---|
3114 | +++ /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.cpp (revision 0)
|
---|
3115 | @@ -0,0 +1,42 @@
|
---|
3116 | +/* ScummVM - Graphic Adventure Engine
|
---|
3117 | + *
|
---|
3118 | + * ScummVM is the legal property of its developers, whose names
|
---|
3119 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
3120 | + * file distributed with this source distribution.
|
---|
3121 | + *
|
---|
3122 | + * This program is free software; you can redistribute it and/or
|
---|
3123 | + * modify it under the terms of the GNU General Public License
|
---|
3124 | + * as published by the Free Software Foundation; either version 2
|
---|
3125 | + * of the License, or (at your option) any later version.
|
---|
3126 | + *
|
---|
3127 | + * This program is distributed in the hope that it will be useful,
|
---|
3128 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
3129 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
3130 | + * GNU General Public License for more details.
|
---|
3131 | + *
|
---|
3132 | + * You should have received a copy of the GNU General Public License
|
---|
3133 | + * along with this program; if not, write to the Free Software
|
---|
3134 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
3135 | + *
|
---|
3136 | + * $URL: $
|
---|
3137 | + * $Id: $
|
---|
3138 | + */
|
---|
3139 | +
|
---|
3140 | +#include "backends/fs/posix/posix-fs-factory.h"
|
---|
3141 | +#include "backends/fs/posix/posix-fs.cpp"
|
---|
3142 | +
|
---|
3143 | +DECLARE_SINGLETON(POSIXFilesystemFactory);
|
---|
3144 | +
|
---|
3145 | +AbstractFilesystemNode *POSIXFilesystemFactory::makeRootFileNode() const {
|
---|
3146 | + return new POSIXFilesystemNode();
|
---|
3147 | +}
|
---|
3148 | +
|
---|
3149 | +AbstractFilesystemNode *POSIXFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
3150 | + char buf[MAXPATHLEN];
|
---|
3151 | + getcwd(buf, MAXPATHLEN);
|
---|
3152 | + return new POSIXFilesystemNode(buf, true);
|
---|
3153 | +}
|
---|
3154 | +
|
---|
3155 | +AbstractFilesystemNode *POSIXFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
3156 | + return new POSIXFilesystemNode(path, true);
|
---|
3157 | +}
|
---|
3158 |
|
---|
3159 | Property changes on: /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.cpp
|
---|
3160 | ___________________________________________________________________
|
---|
3161 | Name: svn:eol-style
|
---|
3162 | + native
|
---|
3163 | Name: svn:keywords
|
---|
3164 | + Date Rev Author URL Id
|
---|
3165 | Name: svn:mime-type
|
---|
3166 | + text/plain
|
---|
3167 |
|
---|
3168 | Index: /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.h
|
---|
3169 | ===================================================================
|
---|
3170 | --- /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.h (revision 0)
|
---|
3171 | +++ /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.h (revision 0)
|
---|
3172 | @@ -0,0 +1,51 @@
|
---|
3173 | +/* ScummVM - Graphic Adventure Engine
|
---|
3174 | + *
|
---|
3175 | + * ScummVM is the legal property of its developers, whose names
|
---|
3176 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
3177 | + * file distributed with this source distribution.
|
---|
3178 | + *
|
---|
3179 | + * This program is free software; you can redistribute it and/or
|
---|
3180 | + * modify it under the terms of the GNU General Public License
|
---|
3181 | + * as published by the Free Software Foundation; either version 2
|
---|
3182 | + * of the License, or (at your option) any later version.
|
---|
3183 | + *
|
---|
3184 | + * This program is distributed in the hope that it will be useful,
|
---|
3185 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
3186 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
3187 | + * GNU General Public License for more details.
|
---|
3188 | + *
|
---|
3189 | + * You should have received a copy of the GNU General Public License
|
---|
3190 | + * along with this program; if not, write to the Free Software
|
---|
3191 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
3192 | + *
|
---|
3193 | + * $URL: $
|
---|
3194 | + * $Id: $
|
---|
3195 | + */
|
---|
3196 | +
|
---|
3197 | +#ifndef POSIX_FILESYSTEM_FACTORY_H
|
---|
3198 | +#define POSIX_FILESYSTEM_FACTORY_H
|
---|
3199 | +
|
---|
3200 | +#include "common/singleton.h"
|
---|
3201 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
3202 | +
|
---|
3203 | +/**
|
---|
3204 | + * Creates POSIXFilesystemNode objects.
|
---|
3205 | + *
|
---|
3206 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
3207 | + */
|
---|
3208 | +class POSIXFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<POSIXFilesystemFactory> {
|
---|
3209 | +public:
|
---|
3210 | + typedef Common::String String;
|
---|
3211 | +
|
---|
3212 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
3213 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
3214 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
3215 | +
|
---|
3216 | +protected:
|
---|
3217 | + POSIXFilesystemFactory() {};
|
---|
3218 | +
|
---|
3219 | +private:
|
---|
3220 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
3221 | +};
|
---|
3222 | +
|
---|
3223 | +#endif /*POSIX_FILESYSTEM_FACTORY_H*/
|
---|
3224 |
|
---|
3225 | Property changes on: /home/david/Projects/scummvm/backends/fs/posix/posix-fs-factory.h
|
---|
3226 | ___________________________________________________________________
|
---|
3227 | Name: svn:eol-style
|
---|
3228 | + native
|
---|
3229 | Name: svn:keywords
|
---|
3230 | + Date Rev Author URL Id
|
---|
3231 | Name: svn:mime-type
|
---|
3232 | + text/plain
|
---|
3233 |
|
---|
3234 | Index: /home/david/Projects/scummvm/backends/fs/posix/posix-fs.cpp
|
---|
3235 | ===================================================================
|
---|
3236 | --- /home/david/Projects/scummvm/backends/fs/posix/posix-fs.cpp (revision 28941)
|
---|
3237 | +++ /home/david/Projects/scummvm/backends/fs/posix/posix-fs.cpp (working copy)
|
---|
3238 | @@ -25,7 +25,6 @@
|
---|
3239 | #if defined(UNIX)
|
---|
3240 |
|
---|
3241 | #include "common/stdafx.h"
|
---|
3242 | -
|
---|
3243 | #include "backends/fs/abstract-fs.h"
|
---|
3244 |
|
---|
3245 | #ifdef MACOSX
|
---|
3246 | @@ -37,33 +36,61 @@
|
---|
3247 | #include <stdio.h>
|
---|
3248 | #include <unistd.h>
|
---|
3249 |
|
---|
3250 | -/*
|
---|
3251 | +/**
|
---|
3252 | * Implementation of the ScummVM file system API based on POSIX.
|
---|
3253 | + *
|
---|
3254 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
3255 | */
|
---|
3256 | -
|
---|
3257 | class POSIXFilesystemNode : public AbstractFilesystemNode {
|
---|
3258 | protected:
|
---|
3259 | String _displayName;
|
---|
3260 | + String _path;
|
---|
3261 | bool _isDirectory;
|
---|
3262 | bool _isValid;
|
---|
3263 | - String _path;
|
---|
3264 |
|
---|
3265 | public:
|
---|
3266 | + /**
|
---|
3267 | + * Creates a POSIXFilesystemNode with the root node as path.
|
---|
3268 | + */
|
---|
3269 | POSIXFilesystemNode();
|
---|
3270 | +
|
---|
3271 | + /**
|
---|
3272 | + * Creates a POSIXFilesystemNode for a given path.
|
---|
3273 | + *
|
---|
3274 | + * @param path String with the path the new node should point to.
|
---|
3275 | + * @param verify true if the isValid and isDirectory flags should be verified during the construction.
|
---|
3276 | + */
|
---|
3277 | POSIXFilesystemNode(const String &path, bool verify);
|
---|
3278 | -
|
---|
3279 | - virtual String displayName() const { return _displayName; }
|
---|
3280 | - virtual String name() const { return _displayName; }
|
---|
3281 | - virtual bool isValid() const { return _isValid; }
|
---|
3282 | +
|
---|
3283 | + virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; }
|
---|
3284 | + virtual String getDisplayName() const { return _displayName; }
|
---|
3285 | + virtual String getName() const { return _displayName; }
|
---|
3286 | + virtual String getPath() const { return _path; }
|
---|
3287 | virtual bool isDirectory() const { return _isDirectory; }
|
---|
3288 | - virtual String path() const { return _path; }
|
---|
3289 | -
|
---|
3290 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
3291 | - virtual AbstractFilesystemNode *parent() const;
|
---|
3292 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
3293 | + virtual bool isReadable() const { return access(_path.c_str(), R_OK) == 0; }
|
---|
3294 | + virtual bool isWritable() const { return access(_path.c_str(), W_OK) == 0; }
|
---|
3295 | +
|
---|
3296 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
3297 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
3298 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
3299 | +
|
---|
3300 | +private:
|
---|
3301 | + /**
|
---|
3302 | + * Tests and sets the _isValid and _isDirectory flags, using the stat() function.
|
---|
3303 | + */
|
---|
3304 | + virtual void setFlags();
|
---|
3305 | };
|
---|
3306 |
|
---|
3307 | -
|
---|
3308 | +/**
|
---|
3309 | + * Returns the last component of a given path.
|
---|
3310 | + *
|
---|
3311 | + * Examples:
|
---|
3312 | + * /foo/bar.txt would return /bar.txt
|
---|
3313 | + * /foo/bar/ would return /bar/
|
---|
3314 | + *
|
---|
3315 | + * @param str String containing the path.
|
---|
3316 | + * @return Pointer to the first char of the last component inside str.
|
---|
3317 | + */
|
---|
3318 | static const char *lastPathComponent(const Common::String &str) {
|
---|
3319 | const char *start = str.c_str();
|
---|
3320 | const char *cur = start + str.size() - 2;
|
---|
3321 | @@ -75,18 +102,11 @@
|
---|
3322 | return cur + 1;
|
---|
3323 | }
|
---|
3324 |
|
---|
3325 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
3326 | - char buf[MAXPATHLEN];
|
---|
3327 | - getcwd(buf, MAXPATHLEN);
|
---|
3328 | - return new POSIXFilesystemNode(buf, true);
|
---|
3329 | -}
|
---|
3330 | -
|
---|
3331 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
3332 | - return new POSIXFilesystemNode();
|
---|
3333 | -}
|
---|
3334 | -
|
---|
3335 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
3336 | - return new POSIXFilesystemNode(path, true);
|
---|
3337 | +void POSIXFilesystemNode::setFlags() {
|
---|
3338 | + struct stat st;
|
---|
3339 | +
|
---|
3340 | + _isValid = (0 == stat(_path.c_str(), &st));
|
---|
3341 | + _isDirectory = _isValid ? S_ISDIR(st.st_mode) : false;
|
---|
3342 | }
|
---|
3343 |
|
---|
3344 | POSIXFilesystemNode::POSIXFilesystemNode() {
|
---|
3345 | @@ -123,20 +143,29 @@
|
---|
3346 |
|
---|
3347 | _path = p;
|
---|
3348 | _displayName = lastPathComponent(_path);
|
---|
3349 | - _isValid = true;
|
---|
3350 | - _isDirectory = true;
|
---|
3351 |
|
---|
3352 | if (verify) {
|
---|
3353 | - struct stat st;
|
---|
3354 | - _isValid = (0 == stat(_path.c_str(), &st));
|
---|
3355 | - _isDirectory = _isValid ? S_ISDIR(st.st_mode) : false;
|
---|
3356 | + setFlags();
|
---|
3357 | }
|
---|
3358 | }
|
---|
3359 |
|
---|
3360 | -bool POSIXFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
3361 | +AbstractFilesystemNode *POSIXFilesystemNode::getChild(const String &n) const {
|
---|
3362 | + // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
3363 | + // of, do not check if this is a special node, etc.
|
---|
3364 | + assert(_isDirectory);
|
---|
3365 | +
|
---|
3366 | + String newPath(_path);
|
---|
3367 | + if (_path.lastChar() != '/')
|
---|
3368 | + newPath += '/';
|
---|
3369 | + newPath += n;
|
---|
3370 | +
|
---|
3371 | + return new POSIXFilesystemNode(newPath, true);
|
---|
3372 | +}
|
---|
3373 | +
|
---|
3374 | +bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
3375 | assert(_isDirectory);
|
---|
3376 | +
|
---|
3377 | DIR *dirp = opendir(_path.c_str());
|
---|
3378 | -
|
---|
3379 | struct dirent *dp;
|
---|
3380 |
|
---|
3381 | if (dirp == NULL)
|
---|
3382 | @@ -142,11 +171,16 @@
|
---|
3383 | if (dirp == NULL)
|
---|
3384 | return false;
|
---|
3385 |
|
---|
3386 | - // ... loop over dir entries using readdir
|
---|
3387 | + // loop over dir entries using readdir
|
---|
3388 | while ((dp = readdir(dirp)) != NULL) {
|
---|
3389 | - // Skip 'invisible' files
|
---|
3390 | - if (dp->d_name[0] == '.')
|
---|
3391 | + // Skip 'invisible' files if necessary
|
---|
3392 | + if (dp->d_name[0] == '.' && !hidden) {
|
---|
3393 | continue;
|
---|
3394 | + }
|
---|
3395 | + // Skip '.' and '..' to avoid cycles
|
---|
3396 | + if((dp->d_name[0] == '.' && dp->d_name[1] == 0) || (dp->d_name[0] == '.' && dp->d_name[1] == '.')) {
|
---|
3397 | + continue;
|
---|
3398 | + }
|
---|
3399 |
|
---|
3400 | String newPath(_path);
|
---|
3401 | if (newPath.lastChar() != '/')
|
---|
3402 | @@ -156,18 +190,18 @@
|
---|
3403 | POSIXFilesystemNode entry(newPath, false);
|
---|
3404 |
|
---|
3405 | #if defined(SYSTEM_NOT_SUPPORTING_D_TYPE)
|
---|
3406 | - // TODO: d_type is not part of POSIX, so it might not be supported
|
---|
3407 | - // on some of our targets. For those systems where it isn't supported,
|
---|
3408 | - // add this #elif case, which tries to use stat() instead.
|
---|
3409 | - struct stat st;
|
---|
3410 | - entry._isValid = (0 == stat(entry._path.c_str(), &st));
|
---|
3411 | - entry._isDirectory = entry._isValid ? S_ISDIR(st.st_mode) : false;
|
---|
3412 | + /* TODO: d_type is not part of POSIX, so it might not be supported
|
---|
3413 | + * on some of our targets. For those systems where it isn't supported,
|
---|
3414 | + * add this #elif case, which tries to use stat() instead.
|
---|
3415 | + *
|
---|
3416 | + * The d_type method is used to avoid costly recurrent stat() calls in big
|
---|
3417 | + * directories.
|
---|
3418 | + */
|
---|
3419 | + entry.setFlags();
|
---|
3420 | #else
|
---|
3421 | if (dp->d_type == DT_UNKNOWN) {
|
---|
3422 | // Fall back to stat()
|
---|
3423 | - struct stat st;
|
---|
3424 | - entry._isValid = (0 == stat(entry._path.c_str(), &st));
|
---|
3425 | - entry._isDirectory = entry._isValid ? S_ISDIR(st.st_mode) : false;
|
---|
3426 | + entry.setFlags();
|
---|
3427 | } else {
|
---|
3428 | entry._isValid = (dp->d_type == DT_DIR) || (dp->d_type == DT_REG) || (dp->d_type == DT_LNK);
|
---|
3429 | if (dp->d_type == DT_LNK) {
|
---|
3430 | @@ -194,13 +228,15 @@
|
---|
3431 |
|
---|
3432 | if (entry._isDirectory)
|
---|
3433 | entry._path += "/";
|
---|
3434 | +
|
---|
3435 | myList.push_back(new POSIXFilesystemNode(entry));
|
---|
3436 | }
|
---|
3437 | closedir(dirp);
|
---|
3438 | +
|
---|
3439 | return true;
|
---|
3440 | }
|
---|
3441 |
|
---|
3442 | -AbstractFilesystemNode *POSIXFilesystemNode::parent() const {
|
---|
3443 | +AbstractFilesystemNode *POSIXFilesystemNode::getParent() const {
|
---|
3444 | if (_path == "/")
|
---|
3445 | return 0;
|
---|
3446 |
|
---|
3447 | @@ -207,22 +243,7 @@
|
---|
3448 | const char *start = _path.c_str();
|
---|
3449 | const char *end = lastPathComponent(_path);
|
---|
3450 |
|
---|
3451 | - POSIXFilesystemNode *p = new POSIXFilesystemNode(String(start, end - start), false);
|
---|
3452 | -
|
---|
3453 | - return p;
|
---|
3454 | -}
|
---|
3455 | -
|
---|
3456 | -AbstractFilesystemNode *POSIXFilesystemNode::child(const String &n) const {
|
---|
3457 | - // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
3458 | - // of, do not check if this is a special node, etc.
|
---|
3459 | - assert(_isDirectory);
|
---|
3460 | - String newPath(_path);
|
---|
3461 | - if (_path.lastChar() != '/')
|
---|
3462 | - newPath += '/';
|
---|
3463 | - newPath += n;
|
---|
3464 | - POSIXFilesystemNode *p = new POSIXFilesystemNode(newPath, true);
|
---|
3465 | -
|
---|
3466 | - return p;
|
---|
3467 | + return new POSIXFilesystemNode(String(start, end - start), true);
|
---|
3468 | }
|
---|
3469 |
|
---|
3470 | -#endif // defined(UNIX)
|
---|
3471 | +#endif //#if defined(UNIX)
|
---|
3472 | Index: /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.cpp
|
---|
3473 | ===================================================================
|
---|
3474 | --- /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.cpp (revision 0)
|
---|
3475 | +++ /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.cpp (revision 0)
|
---|
3476 | @@ -0,0 +1,40 @@
|
---|
3477 | +/* ScummVM - Graphic Adventure Engine
|
---|
3478 | + *
|
---|
3479 | + * ScummVM is the legal property of its developers, whose names
|
---|
3480 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
3481 | + * file distributed with this source distribution.
|
---|
3482 | + *
|
---|
3483 | + * This program is free software; you can redistribute it and/or
|
---|
3484 | + * modify it under the terms of the GNU General Public License
|
---|
3485 | + * as published by the Free Software Foundation; either version 2
|
---|
3486 | + * of the License, or (at your option) any later version.
|
---|
3487 | + *
|
---|
3488 | + * This program is distributed in the hope that it will be useful,
|
---|
3489 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
3490 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
3491 | + * GNU General Public License for more details.
|
---|
3492 | + *
|
---|
3493 | + * You should have received a copy of the GNU General Public License
|
---|
3494 | + * along with this program; if not, write to the Free Software
|
---|
3495 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
3496 | + *
|
---|
3497 | + * $URL: $
|
---|
3498 | + * $Id: $
|
---|
3499 | + */
|
---|
3500 | +
|
---|
3501 | +#include "backends/fs/ps2/ps2-fs-factory.h"
|
---|
3502 | +#include "backends/fs/ps2/ps2-fs.cpp"
|
---|
3503 | +
|
---|
3504 | +DECLARE_SINGLETON(Ps2FilesystemFactory);
|
---|
3505 | +
|
---|
3506 | +AbstractFilesystemNode *Ps2FilesystemFactory::makeRootFileNode() const {
|
---|
3507 | + return new Ps2FilesystemNode();
|
---|
3508 | +}
|
---|
3509 | +
|
---|
3510 | +AbstractFilesystemNode *Ps2FilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
3511 | + return new Ps2FilesystemNode();
|
---|
3512 | +}
|
---|
3513 | +
|
---|
3514 | +AbstractFilesystemNode *Ps2FilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
3515 | + return new Ps2FilesystemNode(path);
|
---|
3516 | +}
|
---|
3517 |
|
---|
3518 | Property changes on: /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.cpp
|
---|
3519 | ___________________________________________________________________
|
---|
3520 | Name: svn:eol-style
|
---|
3521 | + native
|
---|
3522 | Name: svn:keywords
|
---|
3523 | + Date Rev Author URL Id
|
---|
3524 | Name: svn:mime-type
|
---|
3525 | + text/plain
|
---|
3526 |
|
---|
3527 | Index: /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.h
|
---|
3528 | ===================================================================
|
---|
3529 | --- /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.h (revision 0)
|
---|
3530 | +++ /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.h (revision 0)
|
---|
3531 | @@ -0,0 +1,51 @@
|
---|
3532 | +/* ScummVM - Graphic Adventure Engine
|
---|
3533 | + *
|
---|
3534 | + * ScummVM is the legal property of its developers, whose names
|
---|
3535 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
3536 | + * file distributed with this source distribution.
|
---|
3537 | + *
|
---|
3538 | + * This program is free software; you can redistribute it and/or
|
---|
3539 | + * modify it under the terms of the GNU General Public License
|
---|
3540 | + * as published by the Free Software Foundation; either version 2
|
---|
3541 | + * of the License, or (at your option) any later version.
|
---|
3542 | + *
|
---|
3543 | + * This program is distributed in the hope that it will be useful,
|
---|
3544 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
3545 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
3546 | + * GNU General Public License for more details.
|
---|
3547 | + *
|
---|
3548 | + * You should have received a copy of the GNU General Public License
|
---|
3549 | + * along with this program; if not, write to the Free Software
|
---|
3550 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
3551 | + *
|
---|
3552 | + * $URL: $
|
---|
3553 | + * $Id: $
|
---|
3554 | + */
|
---|
3555 | +
|
---|
3556 | +#ifndef PS2_FILESYSTEM_FACTORY_H
|
---|
3557 | +#define PS2_FILESYSTEM_FACTORY_H
|
---|
3558 | +
|
---|
3559 | +#include "common/singleton.h"
|
---|
3560 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
3561 | +
|
---|
3562 | +/**
|
---|
3563 | + * Creates PS2FilesystemNode objects.
|
---|
3564 | + *
|
---|
3565 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
3566 | + */
|
---|
3567 | +class Ps2FilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<Ps2FilesystemFactory> {
|
---|
3568 | +public:
|
---|
3569 | + typedef Common::String String;
|
---|
3570 | +
|
---|
3571 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
3572 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
3573 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
3574 | +
|
---|
3575 | +protected:
|
---|
3576 | + Ps2FilesystemFactory() {};
|
---|
3577 | +
|
---|
3578 | +private:
|
---|
3579 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
3580 | +};
|
---|
3581 | +
|
---|
3582 | +#endif /*PS2_FILESYSTEM_FACTORY_H*/
|
---|
3583 |
|
---|
3584 | Property changes on: /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs-factory.h
|
---|
3585 | ___________________________________________________________________
|
---|
3586 | Name: svn:eol-style
|
---|
3587 | + native
|
---|
3588 | Name: svn:keywords
|
---|
3589 | + Date Rev Author URL Id
|
---|
3590 | Name: svn:mime-type
|
---|
3591 | + text/plain
|
---|
3592 |
|
---|
3593 | Index: /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs.cpp
|
---|
3594 | ===================================================================
|
---|
3595 | --- /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs.cpp (revision 28941)
|
---|
3596 | +++ /home/david/Projects/scummvm/backends/fs/ps2/ps2-fs.cpp (working copy)
|
---|
3597 | @@ -32,44 +32,52 @@
|
---|
3598 | extern AsyncFio fio;
|
---|
3599 | extern OSystem_PS2 *g_systemPs2;
|
---|
3600 |
|
---|
3601 | +/**
|
---|
3602 | + * Implementation of the ScummVM file system API based on the Ps2SDK.
|
---|
3603 | + *
|
---|
3604 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
3605 | + */
|
---|
3606 | class Ps2FilesystemNode : public AbstractFilesystemNode {
|
---|
3607 | protected:
|
---|
3608 | String _displayName;
|
---|
3609 | + String _path;
|
---|
3610 | bool _isDirectory;
|
---|
3611 | bool _isRoot;
|
---|
3612 | - String _path;
|
---|
3613 |
|
---|
3614 | public:
|
---|
3615 | - Ps2FilesystemNode(void);
|
---|
3616 | + /**
|
---|
3617 | + * Creates a PS2FilesystemNode with the root node as path.
|
---|
3618 | + */
|
---|
3619 | + Ps2FilesystemNode();
|
---|
3620 | +
|
---|
3621 | + /**
|
---|
3622 | + * Creates a PS2FilesystemNode for a given path.
|
---|
3623 | + *
|
---|
3624 | + * @param path String with the path the new node should point to.
|
---|
3625 | + */
|
---|
3626 | + Ps2FilesystemNode(const String &path);
|
---|
3627 | +
|
---|
3628 | + /**
|
---|
3629 | + * Copy constructor.
|
---|
3630 | + */
|
---|
3631 | Ps2FilesystemNode(const Ps2FilesystemNode *node);
|
---|
3632 | - Ps2FilesystemNode(const String &path);
|
---|
3633 |
|
---|
3634 | - virtual String displayName() const { return _displayName; }
|
---|
3635 | - virtual String name() const { return _displayName; }
|
---|
3636 | - virtual bool isValid() const { return !_isRoot; }
|
---|
3637 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
3638 | + virtual String getDisplayName() const { return _displayName; }
|
---|
3639 | + virtual String getName() const { return _displayName; }
|
---|
3640 | + virtual String getPath() const { return _path; }
|
---|
3641 | virtual bool isDirectory() const { return _isDirectory; }
|
---|
3642 | - virtual String path() const { return _path; }
|
---|
3643 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
3644 | + virtual bool isValid() const { return !_isRoot; }
|
---|
3645 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
3646 |
|
---|
3647 | - //virtual FSList listDir(ListMode) const;
|
---|
3648 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
3649 | - virtual AbstractFilesystemNode *parent() const;
|
---|
3650 | virtual AbstractFilesystemNode *clone() const { return new Ps2FilesystemNode(this); }
|
---|
3651 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
3652 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
3653 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
3654 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
3655 | };
|
---|
3656 |
|
---|
3657 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
3658 | - return AbstractFilesystemNode::getRoot();
|
---|
3659 | -}
|
---|
3660 | -
|
---|
3661 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot(void) {
|
---|
3662 | - return new Ps2FilesystemNode();
|
---|
3663 | -}
|
---|
3664 | -
|
---|
3665 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
3666 | - return new Ps2FilesystemNode(path);
|
---|
3667 | -}
|
---|
3668 | -
|
---|
3669 | -Ps2FilesystemNode::Ps2FilesystemNode(void) {
|
---|
3670 | +Ps2FilesystemNode::Ps2FilesystemNode() {
|
---|
3671 | _isDirectory = true;
|
---|
3672 | _isRoot = true;
|
---|
3673 | _displayName = "PlayStation 2";
|
---|
3674 | @@ -108,7 +116,43 @@
|
---|
3675 | _isRoot = node->_isRoot;
|
---|
3676 | }
|
---|
3677 |
|
---|
3678 | -bool Ps2FilesystemNode::listDir(AbstractFSList &list, ListMode mode) const {
|
---|
3679 | +AbstractFilesystemNode *Ps2FilesystemNode::getChild(const String &n) const {
|
---|
3680 | + if (!_isDirectory)
|
---|
3681 | + return NULL;
|
---|
3682 | +
|
---|
3683 | + char listDir[256];
|
---|
3684 | + sprintf(listDir, "%s/", _path.c_str());
|
---|
3685 | + int fd = fio.dopen(listDir);
|
---|
3686 | +
|
---|
3687 | + if (fd >= 0) {
|
---|
3688 | + iox_dirent_t dirent;
|
---|
3689 | +
|
---|
3690 | + while (fio.dread(fd, &dirent) > 0) {
|
---|
3691 | + if (strcmp(n.c_str(), dirent.name) == 0) {
|
---|
3692 | + Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
|
---|
3693 | +
|
---|
3694 | + dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
|
---|
3695 | + dirEntry->_isRoot = false;
|
---|
3696 | +
|
---|
3697 | + dirEntry->_path = _path;
|
---|
3698 | + dirEntry->_path += "/";
|
---|
3699 | + dirEntry->_path += dirent.name;
|
---|
3700 | +
|
---|
3701 | + dirEntry->_displayName = dirent.name;
|
---|
3702 | +
|
---|
3703 | + fio.dclose(fd);
|
---|
3704 | + return dirEntry;
|
---|
3705 | + }
|
---|
3706 | + }
|
---|
3707 | + fio.dclose(fd);
|
---|
3708 | + }
|
---|
3709 | +
|
---|
3710 | + return NULL;
|
---|
3711 | +}
|
---|
3712 | +
|
---|
3713 | +bool Ps2FilesystemNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
|
---|
3714 | + //TODO: honor the hidden flag
|
---|
3715 | +
|
---|
3716 | if (!_isDirectory)
|
---|
3717 | return false;
|
---|
3718 |
|
---|
3719 | @@ -135,6 +179,7 @@
|
---|
3720 | } else {
|
---|
3721 | char listDir[256];
|
---|
3722 | int fd;
|
---|
3723 | +
|
---|
3724 | if (_path.lastChar() == '/')
|
---|
3725 | fd = fio.dopen(_path.c_str());
|
---|
3726 | else {
|
---|
3727 | @@ -173,7 +218,7 @@
|
---|
3728 | }
|
---|
3729 | }
|
---|
3730 |
|
---|
3731 | -AbstractFilesystemNode *Ps2FilesystemNode::parent() const {
|
---|
3732 | +AbstractFilesystemNode *Ps2FilesystemNode::getParent() const {
|
---|
3733 | if (_isRoot)
|
---|
3734 | return new Ps2FilesystemNode(this);
|
---|
3735 |
|
---|
3736 | @@ -191,36 +236,3 @@
|
---|
3737 | else
|
---|
3738 | return new Ps2FilesystemNode();
|
---|
3739 | }
|
---|
3740 | -
|
---|
3741 | -AbstractFilesystemNode *Ps2FilesystemNode::child(const String &n) const {
|
---|
3742 | - if (!_isDirectory)
|
---|
3743 | - return NULL;
|
---|
3744 | -
|
---|
3745 | - char listDir[256];
|
---|
3746 | - sprintf(listDir, "%s/", _path.c_str());
|
---|
3747 | - int fd = fio.dopen(listDir);
|
---|
3748 | -
|
---|
3749 | - if (fd >= 0) {
|
---|
3750 | - iox_dirent_t dirent;
|
---|
3751 | -
|
---|
3752 | - while (fio.dread(fd, &dirent) > 0) {
|
---|
3753 | - if (strcmp(n.c_str(), dirent.name) == 0) {
|
---|
3754 | - Ps2FilesystemNode *dirEntry = new Ps2FilesystemNode();
|
---|
3755 | -
|
---|
3756 | - dirEntry->_isDirectory = (bool)(dirent.stat.mode & FIO_S_IFDIR);
|
---|
3757 | - dirEntry->_isRoot = false;
|
---|
3758 | -
|
---|
3759 | - dirEntry->_path = _path;
|
---|
3760 | - dirEntry->_path += "/";
|
---|
3761 | - dirEntry->_path += dirent.name;
|
---|
3762 | -
|
---|
3763 | - dirEntry->_displayName = dirent.name;
|
---|
3764 | -
|
---|
3765 | - fio.dclose(fd);
|
---|
3766 | - return dirEntry;
|
---|
3767 | - }
|
---|
3768 | - }
|
---|
3769 | - fio.dclose(fd);
|
---|
3770 | - }
|
---|
3771 | - return NULL;
|
---|
3772 | -}
|
---|
3773 | Index: /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.cpp
|
---|
3774 | ===================================================================
|
---|
3775 | --- /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.cpp (revision 0)
|
---|
3776 | +++ /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.cpp (revision 0)
|
---|
3777 | @@ -0,0 +1,40 @@
|
---|
3778 | +/* ScummVM - Graphic Adventure Engine
|
---|
3779 | + *
|
---|
3780 | + * ScummVM is the legal property of its developers, whose names
|
---|
3781 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
3782 | + * file distributed with this source distribution.
|
---|
3783 | + *
|
---|
3784 | + * This program is free software; you can redistribute it and/or
|
---|
3785 | + * modify it under the terms of the GNU General Public License
|
---|
3786 | + * as published by the Free Software Foundation; either version 2
|
---|
3787 | + * of the License, or (at your option) any later version.
|
---|
3788 | + *
|
---|
3789 | + * This program is distributed in the hope that it will be useful,
|
---|
3790 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
3791 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
3792 | + * GNU General Public License for more details.
|
---|
3793 | + *
|
---|
3794 | + * You should have received a copy of the GNU General Public License
|
---|
3795 | + * along with this program; if not, write to the Free Software
|
---|
3796 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
3797 | + *
|
---|
3798 | + * $URL: $
|
---|
3799 | + * $Id: $
|
---|
3800 | + */
|
---|
3801 | +
|
---|
3802 | +#include "backends/fs/psp/psp-fs-factory.h"
|
---|
3803 | +#include "backends/fs/psp/psp_fs.cpp"
|
---|
3804 | +
|
---|
3805 | +DECLARE_SINGLETON(PSPFilesystemFactory);
|
---|
3806 | +
|
---|
3807 | +AbstractFilesystemNode *PSPFilesystemFactory::makeRootFileNode() const {
|
---|
3808 | + return new PSPFilesystemNode();
|
---|
3809 | +}
|
---|
3810 | +
|
---|
3811 | +AbstractFilesystemNode *PSPFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
3812 | + return new PSPFilesystemNode();
|
---|
3813 | +}
|
---|
3814 | +
|
---|
3815 | +AbstractFilesystemNode *PSPFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
3816 | + return new PSPFilesystemNode(path, true);
|
---|
3817 | +}
|
---|
3818 |
|
---|
3819 | Property changes on: /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.cpp
|
---|
3820 | ___________________________________________________________________
|
---|
3821 | Name: svn:eol-style
|
---|
3822 | + native
|
---|
3823 | Name: svn:keywords
|
---|
3824 | + Date Rev Author URL Id
|
---|
3825 | Name: svn:mime-type
|
---|
3826 | + text/plain
|
---|
3827 |
|
---|
3828 | Index: /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.h
|
---|
3829 | ===================================================================
|
---|
3830 | --- /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.h (revision 0)
|
---|
3831 | +++ /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.h (revision 0)
|
---|
3832 | @@ -0,0 +1,51 @@
|
---|
3833 | +/* ScummVM - Graphic Adventure Engine
|
---|
3834 | + *
|
---|
3835 | + * ScummVM is the legal property of its developers, whose names
|
---|
3836 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
3837 | + * file distributed with this source distribution.
|
---|
3838 | + *
|
---|
3839 | + * This program is free software; you can redistribute it and/or
|
---|
3840 | + * modify it under the terms of the GNU General Public License
|
---|
3841 | + * as published by the Free Software Foundation; either version 2
|
---|
3842 | + * of the License, or (at your option) any later version.
|
---|
3843 | + *
|
---|
3844 | + * This program is distributed in the hope that it will be useful,
|
---|
3845 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
3846 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
3847 | + * GNU General Public License for more details.
|
---|
3848 | + *
|
---|
3849 | + * You should have received a copy of the GNU General Public License
|
---|
3850 | + * along with this program; if not, write to the Free Software
|
---|
3851 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
3852 | + *
|
---|
3853 | + * $URL: $
|
---|
3854 | + * $Id: $
|
---|
3855 | + */
|
---|
3856 | +
|
---|
3857 | +#ifndef PSP_FILESYSTEM_FACTORY_H
|
---|
3858 | +#define PSP_FILESYSTEM_FACTORY_H
|
---|
3859 | +
|
---|
3860 | +#include "common/singleton.h"
|
---|
3861 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
3862 | +
|
---|
3863 | +/**
|
---|
3864 | + * Creates PSPFilesystemNode objects.
|
---|
3865 | + *
|
---|
3866 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
3867 | + */
|
---|
3868 | +class PSPFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<PSPFilesystemFactory> {
|
---|
3869 | +public:
|
---|
3870 | + typedef Common::String String;
|
---|
3871 | +
|
---|
3872 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
3873 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
3874 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
3875 | +
|
---|
3876 | +protected:
|
---|
3877 | + PSPFilesystemFactory() {};
|
---|
3878 | +
|
---|
3879 | +private:
|
---|
3880 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
3881 | +};
|
---|
3882 | +
|
---|
3883 | +#endif /*PSP_FILESYSTEM_FACTORY_H*/
|
---|
3884 |
|
---|
3885 | Property changes on: /home/david/Projects/scummvm/backends/fs/psp/psp-fs-factory.h
|
---|
3886 | ___________________________________________________________________
|
---|
3887 | Name: svn:eol-style
|
---|
3888 | + native
|
---|
3889 | Name: svn:keywords
|
---|
3890 | + Date Rev Author URL Id
|
---|
3891 | Name: svn:mime-type
|
---|
3892 | + text/plain
|
---|
3893 |
|
---|
3894 | Index: /home/david/Projects/scummvm/backends/fs/psp/psp_fs.cpp
|
---|
3895 | ===================================================================
|
---|
3896 | --- /home/david/Projects/scummvm/backends/fs/psp/psp_fs.cpp (revision 28941)
|
---|
3897 | +++ /home/david/Projects/scummvm/backends/fs/psp/psp_fs.cpp (working copy)
|
---|
3898 | @@ -23,8 +23,8 @@
|
---|
3899 | */
|
---|
3900 |
|
---|
3901 | #ifdef __PSP__
|
---|
3902 | +
|
---|
3903 | #include "engines/engine.h"
|
---|
3904 | -
|
---|
3905 | #include "backends/fs/abstract-fs.h"
|
---|
3906 |
|
---|
3907 | #include <sys/stat.h>
|
---|
3908 | @@ -32,39 +32,65 @@
|
---|
3909 |
|
---|
3910 | #define ROOT_PATH "ms0:/"
|
---|
3911 |
|
---|
3912 | -
|
---|
3913 | -/*
|
---|
3914 | +/**
|
---|
3915 | * Implementation of the ScummVM file system API based on PSPSDK API.
|
---|
3916 | + *
|
---|
3917 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
3918 | */
|
---|
3919 | -
|
---|
3920 | class PSPFilesystemNode : public AbstractFilesystemNode {
|
---|
3921 | protected:
|
---|
3922 | String _displayName;
|
---|
3923 | + String _path;
|
---|
3924 | bool _isDirectory;
|
---|
3925 | bool _isValid;
|
---|
3926 | - String _path;
|
---|
3927 |
|
---|
3928 | public:
|
---|
3929 | + /**
|
---|
3930 | + * Creates a PSPFilesystemNode with the root node as path.
|
---|
3931 | + */
|
---|
3932 | PSPFilesystemNode();
|
---|
3933 | +
|
---|
3934 | + /**
|
---|
3935 | + * Creates a PSPFilesystemNode for a given path.
|
---|
3936 | + *
|
---|
3937 | + * @param path String with the path the new node should point to.
|
---|
3938 | + * @param verify true if the isValid and isDirectory flags should be verified during the construction.
|
---|
3939 | + */
|
---|
3940 | PSPFilesystemNode(const Common::String &p, bool verify);
|
---|
3941 |
|
---|
3942 | - virtual String displayName() const { return _displayName; }
|
---|
3943 | - virtual String name() const { return _displayName; }
|
---|
3944 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
3945 | + virtual String getDisplayName() const { return _displayName; }
|
---|
3946 | + virtual String getName() const { return _displayName; }
|
---|
3947 | + virtual String getPath() const { return _path; }
|
---|
3948 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
3949 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
3950 | virtual bool isValid() const { return _isValid; }
|
---|
3951 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
3952 | - virtual String path() const { return _path; }
|
---|
3953 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
3954 |
|
---|
3955 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
3956 | - virtual AbstractFilesystemNode *parent() const;
|
---|
3957 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
3958 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
3959 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
3960 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
3961 | };
|
---|
3962 |
|
---|
3963 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
3964 | - return AbstractFilesystemNode::getRoot();
|
---|
3965 | -}
|
---|
3966 | +/**
|
---|
3967 | + * Returns the last component of a given path.
|
---|
3968 | + *
|
---|
3969 | + * Examples:
|
---|
3970 | + * /foo/bar.txt would return /bar.txt
|
---|
3971 | + * /foo/bar/ would return /bar/
|
---|
3972 | + *
|
---|
3973 | + * @param str String containing the path.
|
---|
3974 | + * @return Pointer to the first char of the last component inside str.
|
---|
3975 | + */
|
---|
3976 | +static const char *lastPathComponent(const Common::String &str) {
|
---|
3977 | + const char *start = str.c_str();
|
---|
3978 | + const char *cur = start + str.size() - 2;
|
---|
3979 |
|
---|
3980 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
3981 | - return new PSPFilesystemNode();
|
---|
3982 | + while (cur >= start && *cur != '/') {
|
---|
3983 | + --cur;
|
---|
3984 | + }
|
---|
3985 | +
|
---|
3986 | + return cur + 1;
|
---|
3987 | }
|
---|
3988 |
|
---|
3989 | PSPFilesystemNode::PSPFilesystemNode() {
|
---|
3990 | @@ -89,13 +115,23 @@
|
---|
3991 | }
|
---|
3992 | }
|
---|
3993 |
|
---|
3994 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
3995 | - return new PSPFilesystemNode(path, true);
|
---|
3996 | +AbstractFilesystemNode *PSPFilesystemNode::getChild(const String &n) const {
|
---|
3997 | + // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
3998 | + // of, do not check if this is a special node, etc.
|
---|
3999 | + assert(_isDirectory);
|
---|
4000 | +
|
---|
4001 | + String newPath(_path);
|
---|
4002 | + if (_path.lastChar() != '/')
|
---|
4003 | + newPath += '/';
|
---|
4004 | + newPath += n;
|
---|
4005 | +
|
---|
4006 | + return new PSPFilesystemNode(newPath, true);
|
---|
4007 | }
|
---|
4008 |
|
---|
4009 | +bool PSPFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
4010 | + assert(_isDirectory);
|
---|
4011 |
|
---|
4012 | -bool PSPFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
4013 | - assert(_isDirectory);
|
---|
4014 | + //TODO: honor the hidden flag
|
---|
4015 |
|
---|
4016 | int dfd = sceIoDopen(_path.c_str());
|
---|
4017 | if (dfd > 0) {
|
---|
4018 | @@ -133,18 +169,7 @@
|
---|
4019 | }
|
---|
4020 | }
|
---|
4021 |
|
---|
4022 | -static const char *lastPathComponent(const Common::String &str) {
|
---|
4023 | - const char *start = str.c_str();
|
---|
4024 | - const char *cur = start + str.size() - 2;
|
---|
4025 | -
|
---|
4026 | - while (cur >= start && *cur != '/') {
|
---|
4027 | - --cur;
|
---|
4028 | - }
|
---|
4029 | -
|
---|
4030 | - return cur + 1;
|
---|
4031 | -}
|
---|
4032 | -
|
---|
4033 | -AbstractFilesystemNode *PSPFilesystemNode::parent() const {
|
---|
4034 | +AbstractFilesystemNode *PSPFilesystemNode::getParent() const {
|
---|
4035 | assert(_isValid);
|
---|
4036 |
|
---|
4037 | if (_path == ROOT_PATH)
|
---|
4038 | @@ -153,22 +178,7 @@
|
---|
4039 | const char *start = _path.c_str();
|
---|
4040 | const char *end = lastPathComponent(_path);
|
---|
4041 |
|
---|
4042 | - PSPFilesystemNode *p = new PSPFilesystemNode(String(start, end - start), false);
|
---|
4043 | -
|
---|
4044 | - return p;
|
---|
4045 | + return new PSPFilesystemNode(String(start, end - start), false);
|
---|
4046 | }
|
---|
4047 |
|
---|
4048 | -AbstractFilesystemNode *PSPFilesystemNode::child(const String &n) const {
|
---|
4049 | - // FIXME: Pretty lame implementation! We do no error checking to speak
|
---|
4050 | - // of, do not check if this is a special node, etc.
|
---|
4051 | - assert(_isDirectory);
|
---|
4052 | - String newPath(_path);
|
---|
4053 | - if (_path.lastChar() != '/')
|
---|
4054 | - newPath += '/';
|
---|
4055 | - newPath += n;
|
---|
4056 | - PSPFilesystemNode *p = new PSPFilesystemNode(newPath, true);
|
---|
4057 | -
|
---|
4058 | - return p;
|
---|
4059 | -}
|
---|
4060 | -
|
---|
4061 | -#endif // PSP
|
---|
4062 | +#endif //#ifdef __PSP__
|
---|
4063 | Index: /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.cpp
|
---|
4064 | ===================================================================
|
---|
4065 | --- /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.cpp (revision 0)
|
---|
4066 | +++ /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.cpp (revision 0)
|
---|
4067 | @@ -0,0 +1,42 @@
|
---|
4068 | +/* ScummVM - Graphic Adventure Engine
|
---|
4069 | + *
|
---|
4070 | + * ScummVM is the legal property of its developers, whose names
|
---|
4071 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
4072 | + * file distributed with this source distribution.
|
---|
4073 | + *
|
---|
4074 | + * This program is free software; you can redistribute it and/or
|
---|
4075 | + * modify it under the terms of the GNU General Public License
|
---|
4076 | + * as published by the Free Software Foundation; either version 2
|
---|
4077 | + * of the License, or (at your option) any later version.
|
---|
4078 | + *
|
---|
4079 | + * This program is distributed in the hope that it will be useful,
|
---|
4080 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
4081 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
4082 | + * GNU General Public License for more details.
|
---|
4083 | + *
|
---|
4084 | + * You should have received a copy of the GNU General Public License
|
---|
4085 | + * along with this program; if not, write to the Free Software
|
---|
4086 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
4087 | + *
|
---|
4088 | + * $URL: $
|
---|
4089 | + * $Id: $
|
---|
4090 | + */
|
---|
4091 | +
|
---|
4092 | +#include "backends/fs/symbian/symbian-fs-factory.h"
|
---|
4093 | +#include "backends/fs/symbian/symbian-fs.cpp"
|
---|
4094 | +
|
---|
4095 | +DECLARE_SINGLETON(SymbianFilesystemFactory);
|
---|
4096 | +
|
---|
4097 | +AbstractFilesystemNode *SymbianFilesystemFactory::makeRootFileNode() const {
|
---|
4098 | + return new SymbianFilesystemNode(true);
|
---|
4099 | +}
|
---|
4100 | +
|
---|
4101 | +AbstractFilesystemNode *SymbianFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
4102 | + char path[MAXPATHLEN];
|
---|
4103 | + getcwd(path, MAXPATHLEN);
|
---|
4104 | + return new SymbianFilesystemNode(path);
|
---|
4105 | +}
|
---|
4106 | +
|
---|
4107 | +AbstractFilesystemNode *SymbianFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
4108 | + return new SymbianFilesystemNode(path);
|
---|
4109 | +}
|
---|
4110 |
|
---|
4111 | Property changes on: /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.cpp
|
---|
4112 | ___________________________________________________________________
|
---|
4113 | Name: svn:eol-style
|
---|
4114 | + native
|
---|
4115 | Name: svn:keywords
|
---|
4116 | + Date Rev Author URL Id
|
---|
4117 | Name: svn:mime-type
|
---|
4118 | + text/plain
|
---|
4119 |
|
---|
4120 | Index: /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.h
|
---|
4121 | ===================================================================
|
---|
4122 | --- /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.h (revision 0)
|
---|
4123 | +++ /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.h (revision 0)
|
---|
4124 | @@ -0,0 +1,51 @@
|
---|
4125 | +/* ScummVM - Graphic Adventure Engine
|
---|
4126 | + *
|
---|
4127 | + * ScummVM is the legal property of its developers, whose names
|
---|
4128 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
4129 | + * file distributed with this source distribution.
|
---|
4130 | + *
|
---|
4131 | + * This program is free software; you can redistribute it and/or
|
---|
4132 | + * modify it under the terms of the GNU General Public License
|
---|
4133 | + * as published by the Free Software Foundation; either version 2
|
---|
4134 | + * of the License, or (at your option) any later version.
|
---|
4135 | + *
|
---|
4136 | + * This program is distributed in the hope that it will be useful,
|
---|
4137 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
4138 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
4139 | + * GNU General Public License for more details.
|
---|
4140 | + *
|
---|
4141 | + * You should have received a copy of the GNU General Public License
|
---|
4142 | + * along with this program; if not, write to the Free Software
|
---|
4143 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
4144 | + *
|
---|
4145 | + * $URL: $
|
---|
4146 | + * $Id: $
|
---|
4147 | + */
|
---|
4148 | +
|
---|
4149 | +#ifndef SYMBIAN_FILESYSTEM_FACTORY_H
|
---|
4150 | +#define SYMBIAN_FILESYSTEM_FACTORY_H
|
---|
4151 | +
|
---|
4152 | +#include "common/singleton.h"
|
---|
4153 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
4154 | +
|
---|
4155 | +/**
|
---|
4156 | + * Creates SymbianFilesystemNode objects.
|
---|
4157 | + *
|
---|
4158 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
4159 | + */
|
---|
4160 | +class SymbianFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<SymbianFilesystemFactory> {
|
---|
4161 | +public:
|
---|
4162 | + typedef Common::String String;
|
---|
4163 | +
|
---|
4164 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
4165 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
4166 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
4167 | +
|
---|
4168 | +protected:
|
---|
4169 | + SymbianFilesystemFactory() {};
|
---|
4170 | +
|
---|
4171 | +private:
|
---|
4172 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
4173 | +};
|
---|
4174 | +
|
---|
4175 | +#endif /*SYMBIAN_FILESYSTEM_FACTORY_H*/
|
---|
4176 |
|
---|
4177 | Property changes on: /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs-factory.h
|
---|
4178 | ___________________________________________________________________
|
---|
4179 | Name: svn:eol-style
|
---|
4180 | + native
|
---|
4181 | Name: svn:keywords
|
---|
4182 | + Date Rev Author URL Id
|
---|
4183 | Name: svn:mime-type
|
---|
4184 | + text/plain
|
---|
4185 |
|
---|
4186 | Index: /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs.cpp
|
---|
4187 | ===================================================================
|
---|
4188 | --- /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs.cpp (revision 28941)
|
---|
4189 | +++ /home/david/Projects/scummvm/backends/fs/symbian/symbian-fs.cpp (working copy)
|
---|
4190 | @@ -31,33 +31,58 @@
|
---|
4191 | #include <f32file.h>
|
---|
4192 | #include <bautils.h>
|
---|
4193 |
|
---|
4194 | -/*
|
---|
4195 | +/**
|
---|
4196 | * Implementation of the ScummVM file system API based on POSIX.
|
---|
4197 | + *
|
---|
4198 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
4199 | */
|
---|
4200 | -
|
---|
4201 | class SymbianFilesystemNode : public AbstractFilesystemNode {
|
---|
4202 | protected:
|
---|
4203 | String _displayName;
|
---|
4204 | + String _path;
|
---|
4205 | bool _isDirectory;
|
---|
4206 | bool _isValid;
|
---|
4207 | - String _path;
|
---|
4208 | bool _isPseudoRoot;
|
---|
4209 |
|
---|
4210 | public:
|
---|
4211 | + /**
|
---|
4212 | + * Creates a SymbianFilesystemNode with the root node as path.
|
---|
4213 | + *
|
---|
4214 | + * @param aIsRoot true if the node will be a pseudo root, false otherwise.
|
---|
4215 | + */
|
---|
4216 | SymbianFilesystemNode(bool aIsRoot);
|
---|
4217 | +
|
---|
4218 | + /**
|
---|
4219 | + * Creates a SymbianFilesystemNode for a given path.
|
---|
4220 | + *
|
---|
4221 | + * @param path String with the path the new node should point to.
|
---|
4222 | + */
|
---|
4223 | SymbianFilesystemNode(const String &path);
|
---|
4224 | - virtual String displayName() const { return _displayName; }
|
---|
4225 | - virtual String name() const { return _displayName; }
|
---|
4226 | +
|
---|
4227 | + virtual bool exists() const { return true; } //FIXME: this is just a stub
|
---|
4228 | + virtual String getDisplayName() const { return _displayName; }
|
---|
4229 | + virtual String getName() const { return _displayName; }
|
---|
4230 | + virtual String getPath() const { return _path; }
|
---|
4231 | + virtual bool isDirectory() const { return _isDirectory; }
|
---|
4232 | + virtual bool isReadable() const { return true; } //FIXME: this is just a stub
|
---|
4233 | virtual bool isValid() const { return _isValid; }
|
---|
4234 | - virtual bool isDirectory() const { return _isDirectory; }
|
---|
4235 | - virtual String path() const { return _path; }
|
---|
4236 | + virtual bool isWritable() const { return true; } //FIXME: this is just a stub
|
---|
4237 |
|
---|
4238 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
4239 | - virtual AbstractFilesystemNode *parent() const;
|
---|
4240 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
4241 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
4242 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
4243 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
4244 | };
|
---|
4245 |
|
---|
4246 | -
|
---|
4247 | +/**
|
---|
4248 | + * Returns the last component of a given path.
|
---|
4249 | + *
|
---|
4250 | + * Examples:
|
---|
4251 | + * c:\foo\bar.txt would return "\bar.txt"
|
---|
4252 | + * c:\foo\bar\ would return "\bar\"
|
---|
4253 | + *
|
---|
4254 | + * @param str Path to obtain the last component from.
|
---|
4255 | + * @return Pointer to the first char of the last component inside str.
|
---|
4256 | + */
|
---|
4257 | static const char *lastPathComponent(const Common::String &str) {
|
---|
4258 | const char *start = str.c_str();
|
---|
4259 | const char *cur = start + str.size() - 2;
|
---|
4260 | @@ -69,6 +94,11 @@
|
---|
4261 | return cur + 1;
|
---|
4262 | }
|
---|
4263 |
|
---|
4264 | +/**
|
---|
4265 | + * Fixes the path by changing all slashes to backslashes.
|
---|
4266 | + *
|
---|
4267 | + * @param path String with the path to be fixed.
|
---|
4268 | + */
|
---|
4269 | static void fixFilePath(Common::String& path) {
|
---|
4270 | TInt len = path.size();
|
---|
4271 |
|
---|
4272 | @@ -79,20 +109,6 @@
|
---|
4273 | }
|
---|
4274 | }
|
---|
4275 |
|
---|
4276 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
4277 | - char path[MAXPATHLEN];
|
---|
4278 | - getcwd(path, MAXPATHLEN);
|
---|
4279 | - return new SymbianFilesystemNode(path);
|
---|
4280 | -}
|
---|
4281 | -
|
---|
4282 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
4283 | - return new SymbianFilesystemNode(true);
|
---|
4284 | -}
|
---|
4285 | -
|
---|
4286 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
4287 | - return new SymbianFilesystemNode(path);
|
---|
4288 | -}
|
---|
4289 | -
|
---|
4290 | SymbianFilesystemNode::SymbianFilesystemNode(bool aIsRoot) {
|
---|
4291 | _path = "";
|
---|
4292 | _isValid = true;
|
---|
4293 | @@ -128,8 +144,29 @@
|
---|
4294 | }
|
---|
4295 | }
|
---|
4296 |
|
---|
4297 | -bool SymbianFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
4298 | +AbstractFilesystemNode *SymbianFilesystemNode::getChild(const String &n) const {
|
---|
4299 | assert(_isDirectory);
|
---|
4300 | + String newPath(_path);
|
---|
4301 | +
|
---|
4302 | + if (_path.lastChar() != '\\')
|
---|
4303 | + newPath += '\\';
|
---|
4304 | + newPath += n;
|
---|
4305 | +
|
---|
4306 | + TPtrC8 ptr((const unsigned char*) newPath.c_str(), newPath.size());
|
---|
4307 | + TFileName fname;
|
---|
4308 | + fname.Copy(ptr);
|
---|
4309 | + TBool isFolder = EFalse;
|
---|
4310 | + BaflUtils::IsFolder(CEikonEnv::Static()->FsSession(), fname, isFolder);
|
---|
4311 | + if(!isFolder)
|
---|
4312 | + return 0;
|
---|
4313 | +
|
---|
4314 | + return new SymbianFilesystemNode(newPath);
|
---|
4315 | +}
|
---|
4316 | +
|
---|
4317 | +bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
4318 | + assert(_isDirectory);
|
---|
4319 | +
|
---|
4320 | + //TODO: honor the hidden flag
|
---|
4321 |
|
---|
4322 | if (_isPseudoRoot) {
|
---|
4323 | // Drives enumeration
|
---|
4324 | @@ -199,12 +236,12 @@
|
---|
4325 | }
|
---|
4326 | CleanupStack::PopAndDestroy(dirPtr);
|
---|
4327 | }
|
---|
4328 | -
|
---|
4329 | }
|
---|
4330 | +
|
---|
4331 | return true;
|
---|
4332 | }
|
---|
4333 |
|
---|
4334 | -AbstractFilesystemNode *SymbianFilesystemNode::parent() const {
|
---|
4335 | +AbstractFilesystemNode *SymbianFilesystemNode::getParent() const {
|
---|
4336 | SymbianFilesystemNode *p =NULL;
|
---|
4337 |
|
---|
4338 | // Root node is its own parent. Still we can't just return this
|
---|
4339 | @@ -210,7 +247,7 @@
|
---|
4340 | // Root node is its own parent. Still we can't just return this
|
---|
4341 | // as the GUI code will call delete on the old node.
|
---|
4342 | if (!_isPseudoRoot && _path.size() > 3) {
|
---|
4343 | - p=new SymbianFilesystemNode(false);
|
---|
4344 | + p = new SymbianFilesystemNode(false);
|
---|
4345 | const char *start = _path.c_str();
|
---|
4346 | const char *end = lastPathComponent(_path);
|
---|
4347 |
|
---|
4348 | @@ -221,29 +258,10 @@
|
---|
4349 | }
|
---|
4350 | else
|
---|
4351 | {
|
---|
4352 | - p=new SymbianFilesystemNode(true);
|
---|
4353 | + p = new SymbianFilesystemNode(true);
|
---|
4354 | }
|
---|
4355 | - return p;
|
---|
4356 | -}
|
---|
4357 | -
|
---|
4358 | -AbstractFilesystemNode *SymbianFilesystemNode::child(const String &n) const {
|
---|
4359 | - assert(_isDirectory);
|
---|
4360 | - String newPath(_path);
|
---|
4361 | -
|
---|
4362 | - if (_path.lastChar() != '\\')
|
---|
4363 | - newPath += '\\';
|
---|
4364 | - newPath += n;
|
---|
4365 | -
|
---|
4366 | - TPtrC8 ptr((const unsigned char*) newPath.c_str(), newPath.size());
|
---|
4367 | - TFileName fname;
|
---|
4368 | - fname.Copy(ptr);
|
---|
4369 | - TBool isFolder = EFalse;
|
---|
4370 | - BaflUtils::IsFolder(CEikonEnv::Static()->FsSession(), fname, isFolder);
|
---|
4371 | - if(!isFolder)
|
---|
4372 | - return 0;
|
---|
4373 | -
|
---|
4374 | - SymbianFilesystemNode *p = new SymbianFilesystemNode(newPath);
|
---|
4375 | +
|
---|
4376 | return p;
|
---|
4377 | }
|
---|
4378 |
|
---|
4379 | -#endif // defined(__SYMBIAN32__)
|
---|
4380 | +#endif //#if defined (__SYMBIAN32__)
|
---|
4381 | Index: /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.cpp
|
---|
4382 | ===================================================================
|
---|
4383 | --- /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.cpp (revision 0)
|
---|
4384 | +++ /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.cpp (revision 0)
|
---|
4385 | @@ -0,0 +1,40 @@
|
---|
4386 | +/* ScummVM - Graphic Adventure Engine
|
---|
4387 | + *
|
---|
4388 | + * ScummVM is the legal property of its developers, whose names
|
---|
4389 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
4390 | + * file distributed with this source distribution.
|
---|
4391 | + *
|
---|
4392 | + * This program is free software; you can redistribute it and/or
|
---|
4393 | + * modify it under the terms of the GNU General Public License
|
---|
4394 | + * as published by the Free Software Foundation; either version 2
|
---|
4395 | + * of the License, or (at your option) any later version.
|
---|
4396 | + *
|
---|
4397 | + * This program is distributed in the hope that it will be useful,
|
---|
4398 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
4399 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
4400 | + * GNU General Public License for more details.
|
---|
4401 | + *
|
---|
4402 | + * You should have received a copy of the GNU General Public License
|
---|
4403 | + * along with this program; if not, write to the Free Software
|
---|
4404 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
4405 | + *
|
---|
4406 | + * $URL: $
|
---|
4407 | + * $Id: $
|
---|
4408 | + */
|
---|
4409 | +
|
---|
4410 | +#include "backends/fs/windows/windows-fs-factory.h"
|
---|
4411 | +#include "backends/fs/windows/windows-fs.cpp"
|
---|
4412 | +
|
---|
4413 | +DECLARE_SINGLETON(WindowsFilesystemFactory);
|
---|
4414 | +
|
---|
4415 | +AbstractFilesystemNode *WindowsFilesystemFactory::makeRootFileNode() const {
|
---|
4416 | + return new WindowsFilesystemNode();
|
---|
4417 | +}
|
---|
4418 | +
|
---|
4419 | +AbstractFilesystemNode *WindowsFilesystemFactory::makeCurrentDirectoryFileNode() const {
|
---|
4420 | + return new WindowsFilesystemNode("", true);
|
---|
4421 | +}
|
---|
4422 | +
|
---|
4423 | +AbstractFilesystemNode *WindowsFilesystemFactory::makeFileNodePath(const String &path) const {
|
---|
4424 | + return new WindowsFilesystemNode(path, false);
|
---|
4425 | +}
|
---|
4426 |
|
---|
4427 | Property changes on: /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.cpp
|
---|
4428 | ___________________________________________________________________
|
---|
4429 | Name: svn:eol-style
|
---|
4430 | + native
|
---|
4431 | Name: svn:keywords
|
---|
4432 | + Date Rev Author URL Id
|
---|
4433 | Name: svn:mime-type
|
---|
4434 | + text/plain
|
---|
4435 |
|
---|
4436 | Index: /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.h
|
---|
4437 | ===================================================================
|
---|
4438 | --- /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.h (revision 0)
|
---|
4439 | +++ /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.h (revision 0)
|
---|
4440 | @@ -0,0 +1,51 @@
|
---|
4441 | +/* ScummVM - Graphic Adventure Engine
|
---|
4442 | + *
|
---|
4443 | + * ScummVM is the legal property of its developers, whose names
|
---|
4444 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
4445 | + * file distributed with this source distribution.
|
---|
4446 | + *
|
---|
4447 | + * This program is free software; you can redistribute it and/or
|
---|
4448 | + * modify it under the terms of the GNU General Public License
|
---|
4449 | + * as published by the Free Software Foundation; either version 2
|
---|
4450 | + * of the License, or (at your option) any later version.
|
---|
4451 | + *
|
---|
4452 | + * This program is distributed in the hope that it will be useful,
|
---|
4453 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
4454 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
4455 | + * GNU General Public License for more details.
|
---|
4456 | + *
|
---|
4457 | + * You should have received a copy of the GNU General Public License
|
---|
4458 | + * along with this program; if not, write to the Free Software
|
---|
4459 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
4460 | + *
|
---|
4461 | + * $URL: $
|
---|
4462 | + * $Id: $
|
---|
4463 | + */
|
---|
4464 | +
|
---|
4465 | +#ifndef WINDOWS_FILESYSTEM_FACTORY_H
|
---|
4466 | +#define WINDOWS_FILESYSTEM_FACTORY_H
|
---|
4467 | +
|
---|
4468 | +#include "common/singleton.h"
|
---|
4469 | +#include "backends/fs/abstract-fs-factory.h"
|
---|
4470 | +
|
---|
4471 | +/**
|
---|
4472 | + * Creates WindowsFilesystemNode objects.
|
---|
4473 | + *
|
---|
4474 | + * Parts of this class are documented in the base interface class, AbstractFilesystemFactory.
|
---|
4475 | + */
|
---|
4476 | +class WindowsFilesystemFactory : public AbstractFilesystemFactory, public Common::Singleton<WindowsFilesystemFactory> {
|
---|
4477 | +public:
|
---|
4478 | + typedef Common::String String;
|
---|
4479 | +
|
---|
4480 | + virtual AbstractFilesystemNode *makeRootFileNode() const;
|
---|
4481 | + virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
|
---|
4482 | + virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
|
---|
4483 | +
|
---|
4484 | +protected:
|
---|
4485 | + WindowsFilesystemFactory() {};
|
---|
4486 | +
|
---|
4487 | +private:
|
---|
4488 | + friend class Common::Singleton<SingletonBaseType>;
|
---|
4489 | +};
|
---|
4490 | +
|
---|
4491 | +#endif /*WINDOWS_FILESYSTEM_FACTORY_H*/
|
---|
4492 |
|
---|
4493 | Property changes on: /home/david/Projects/scummvm/backends/fs/windows/windows-fs-factory.h
|
---|
4494 | ___________________________________________________________________
|
---|
4495 | Name: svn:eol-style
|
---|
4496 | + native
|
---|
4497 | Name: svn:keywords
|
---|
4498 | + Date Rev Author URL Id
|
---|
4499 | Name: svn:mime-type
|
---|
4500 | + text/plain
|
---|
4501 |
|
---|
4502 | Index: /home/david/Projects/scummvm/backends/fs/windows/windows-fs.cpp
|
---|
4503 | ===================================================================
|
---|
4504 | --- /home/david/Projects/scummvm/backends/fs/windows/windows-fs.cpp (revision 28941)
|
---|
4505 | +++ /home/david/Projects/scummvm/backends/fs/windows/windows-fs.cpp (working copy)
|
---|
4506 | @@ -29,6 +29,7 @@
|
---|
4507 | #endif
|
---|
4508 | #include "common/stdafx.h"
|
---|
4509 | #include "backends/fs/abstract-fs.h"
|
---|
4510 | +#include <io.h>
|
---|
4511 | #include <stdio.h>
|
---|
4512 | #include <stdlib.h>
|
---|
4513 | #ifndef _WIN32_WCE
|
---|
4514 | @@ -36,39 +37,93 @@
|
---|
4515 | #endif
|
---|
4516 | #include <tchar.h>
|
---|
4517 |
|
---|
4518 | -/*
|
---|
4519 | +/**
|
---|
4520 | * Implementation of the ScummVM file system API based on Windows API.
|
---|
4521 | + *
|
---|
4522 | + * Parts of this class are documented in the base interface class, AbstractFilesystemNode.
|
---|
4523 | */
|
---|
4524 | -
|
---|
4525 | class WindowsFilesystemNode : public AbstractFilesystemNode {
|
---|
4526 | protected:
|
---|
4527 | String _displayName;
|
---|
4528 | + String _path;
|
---|
4529 | bool _isDirectory;
|
---|
4530 | - bool _isValid;
|
---|
4531 | bool _isPseudoRoot;
|
---|
4532 | - String _path;
|
---|
4533 | + bool _isValid;
|
---|
4534 |
|
---|
4535 | public:
|
---|
4536 | + /**
|
---|
4537 | + * Creates a WindowsFilesystemNode with the root node as path.
|
---|
4538 | + *
|
---|
4539 | + * In regular windows systems, a virtual root path is used "".
|
---|
4540 | + * In windows CE, the "\" root is used instead.
|
---|
4541 | + */
|
---|
4542 | WindowsFilesystemNode();
|
---|
4543 | - WindowsFilesystemNode(const String &path);
|
---|
4544 | -
|
---|
4545 | - virtual String displayName() const { return _displayName; }
|
---|
4546 | - virtual String name() const { return _displayName; }
|
---|
4547 | - virtual bool isValid() const { return _isValid; }
|
---|
4548 | +
|
---|
4549 | + /**
|
---|
4550 | + * Creates a WindowsFilesystemNode for a given path.
|
---|
4551 | + *
|
---|
4552 | + * Examples:
|
---|
4553 | + * path=c:\foo\bar.txt, currentDir=false -> c:\foo\bar.txt
|
---|
4554 | + * path=c:\foo\bar.txt, currentDir=true -> current directory
|
---|
4555 | + * path=NULL, currentDir=true -> current directory
|
---|
4556 | + *
|
---|
4557 | + * @param path String with the path the new node should point to.
|
---|
4558 | + * @param currentDir if true, the path parameter will be ignored and the resulting node will point to the current directory.
|
---|
4559 | + */
|
---|
4560 | + WindowsFilesystemNode(const String &path, const bool currentDir);
|
---|
4561 | +
|
---|
4562 | + virtual bool exists() const { return _access(_path.c_str(), F_OK) == 0; }
|
---|
4563 | + virtual String getDisplayName() const { return _displayName; }
|
---|
4564 | + virtual String getName() const { return _displayName; }
|
---|
4565 | + virtual String getPath() const { return _path; }
|
---|
4566 | virtual bool isDirectory() const { return _isDirectory; }
|
---|
4567 | - virtual String path() const { return _path; }
|
---|
4568 | + virtual bool isReadable() const { return _access(_path.c_str(), R_OK) == 0; }
|
---|
4569 | + virtual bool isValid() const { return _isValid; }
|
---|
4570 | + virtual bool isWritable() const { return _access(_path.c_str(), W_OK) == 0; }
|
---|
4571 |
|
---|
4572 | - virtual bool listDir(AbstractFSList &list, ListMode mode) const;
|
---|
4573 | - virtual AbstractFilesystemNode *parent() const;
|
---|
4574 | - virtual AbstractFilesystemNode *child(const String &n) const;
|
---|
4575 | + virtual AbstractFilesystemNode *getChild(const String &n) const;
|
---|
4576 | + virtual bool getChildren(AbstractFSList &list, ListMode mode, bool hidden) const;
|
---|
4577 | + virtual AbstractFilesystemNode *getParent() const;
|
---|
4578 |
|
---|
4579 | private:
|
---|
4580 | - static char *toAscii(TCHAR *x);
|
---|
4581 | - static const TCHAR* toUnicode(const char *x);
|
---|
4582 | - static void addFile (AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data);
|
---|
4583 | + /**
|
---|
4584 | + * Adds a single WindowsFilesystemNode to a given list.
|
---|
4585 | + * This method is used by getChildren() to populate the directory entries list.
|
---|
4586 | + *
|
---|
4587 | + * @param list List to put the file entry node in.
|
---|
4588 | + * @param mode Mode to use while adding the file entry to the list.
|
---|
4589 | + * @param base String with the directory being listed.
|
---|
4590 | + * @param find_data Describes a file that the FindFirstFile, FindFirstFileEx, or FindNextFile functions find.
|
---|
4591 | + */
|
---|
4592 | + static void addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data);
|
---|
4593 | +
|
---|
4594 | + /**
|
---|
4595 | + * Converts a Unicode string to Ascii format.
|
---|
4596 | + *
|
---|
4597 | + * @param str String to convert from Unicode to Ascii.
|
---|
4598 | + * @return str in Ascii format.
|
---|
4599 | + */
|
---|
4600 | + static char *toAscii(TCHAR *str);
|
---|
4601 | +
|
---|
4602 | + /**
|
---|
4603 | + * Converts an Ascii string to Unicode format.
|
---|
4604 | + *
|
---|
4605 | + * @param str String to convert from Ascii to Unicode.
|
---|
4606 | + * @return str in Unicode format.
|
---|
4607 | + */
|
---|
4608 | + static const TCHAR* toUnicode(const char *str);
|
---|
4609 | };
|
---|
4610 |
|
---|
4611 | -
|
---|
4612 | +/**
|
---|
4613 | + * Returns the last component of a given path.
|
---|
4614 | + *
|
---|
4615 | + * Examples:
|
---|
4616 | + * c:\foo\bar.txt would return "\bar.txt"
|
---|
4617 | + * c:\foo\bar\ would return "\bar\"
|
---|
4618 | + *
|
---|
4619 | + * @param str Path to obtain the last component from.
|
---|
4620 | + * @return Pointer to the first char of the last component inside str.
|
---|
4621 | + */
|
---|
4622 | static const char *lastPathComponent(const Common::String &str) {
|
---|
4623 | const char *start = str.c_str();
|
---|
4624 | const char *cur = start + str.size() - 2;
|
---|
4625 | @@ -80,27 +135,6 @@
|
---|
4626 | return cur + 1;
|
---|
4627 | }
|
---|
4628 |
|
---|
4629 | -char* WindowsFilesystemNode::toAscii(TCHAR *x) {
|
---|
4630 | -
|
---|
4631 | -#ifndef UNICODE
|
---|
4632 | - return (char*)x;
|
---|
4633 | -#else
|
---|
4634 | - static char asciiString[MAX_PATH];
|
---|
4635 | - WideCharToMultiByte(CP_ACP, 0, x, _tcslen(x) + 1, asciiString, sizeof(asciiString), NULL, NULL);
|
---|
4636 | - return asciiString;
|
---|
4637 | -#endif
|
---|
4638 | -}
|
---|
4639 | -
|
---|
4640 | -const TCHAR* WindowsFilesystemNode::toUnicode(const char *x) {
|
---|
4641 | -#ifndef UNICODE
|
---|
4642 | - return (const TCHAR *)x;
|
---|
4643 | -#else
|
---|
4644 | - static TCHAR unicodeString[MAX_PATH];
|
---|
4645 | - MultiByteToWideChar(CP_ACP, 0, x, strlen(x) + 1, unicodeString, sizeof(unicodeString) / sizeof(TCHAR));
|
---|
4646 | - return unicodeString;
|
---|
4647 | -#endif
|
---|
4648 | -}
|
---|
4649 | -
|
---|
4650 | void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const char *base, WIN32_FIND_DATA* find_data) {
|
---|
4651 | WindowsFilesystemNode entry;
|
---|
4652 | char *asciiName = toAscii(find_data->cFileName);
|
---|
4653 | @@ -128,25 +162,24 @@
|
---|
4654 | list.push_back(new WindowsFilesystemNode(entry));
|
---|
4655 | }
|
---|
4656 |
|
---|
4657 | -AbstractFilesystemNode *AbstractFilesystemNode::getCurrentDirectory() {
|
---|
4658 | - char path[MAX_PATH];
|
---|
4659 | - GetCurrentDirectory(MAX_PATH, path);
|
---|
4660 | -
|
---|
4661 | - // Add a trailing slash, if necessary.
|
---|
4662 | - if (path[0] != 0) {
|
---|
4663 | - if (path[strlen(path) - 1] != '\\')
|
---|
4664 | - strcat(path, "\\");
|
---|
4665 | - }
|
---|
4666 | -
|
---|
4667 | - return new WindowsFilesystemNode(path);
|
---|
4668 | +char* WindowsFilesystemNode::toAscii(TCHAR *str) {
|
---|
4669 | +#ifndef UNICODE
|
---|
4670 | + return (char*)str;
|
---|
4671 | +#else
|
---|
4672 | + static char asciiString[MAX_PATH];
|
---|
4673 | + WideCharToMultiByte(CP_ACP, 0, str, _tcslen(str) + 1, asciiString, sizeof(asciiString), NULL, NULL);
|
---|
4674 | + return asciiString;
|
---|
4675 | +#endif
|
---|
4676 | }
|
---|
4677 |
|
---|
4678 | -AbstractFilesystemNode *AbstractFilesystemNode::getRoot() {
|
---|
4679 | - return new WindowsFilesystemNode();
|
---|
4680 | -}
|
---|
4681 | -
|
---|
4682 | -AbstractFilesystemNode *AbstractFilesystemNode::getNodeForPath(const String &path) {
|
---|
4683 | - return new WindowsFilesystemNode(path);
|
---|
4684 | +const TCHAR* WindowsFilesystemNode::toUnicode(const char *str) {
|
---|
4685 | +#ifndef UNICODE
|
---|
4686 | + return (const TCHAR *)str;
|
---|
4687 | +#else
|
---|
4688 | + static TCHAR unicodeString[MAX_PATH];
|
---|
4689 | + MultiByteToWideChar(CP_ACP, 0, str, strlen(str) + 1, unicodeString, sizeof(unicodeString) / sizeof(TCHAR));
|
---|
4690 | + return unicodeString;
|
---|
4691 | +#endif
|
---|
4692 | }
|
---|
4693 |
|
---|
4694 | WindowsFilesystemNode::WindowsFilesystemNode() {
|
---|
4695 | @@ -165,10 +198,23 @@
|
---|
4696 | #endif
|
---|
4697 | }
|
---|
4698 |
|
---|
4699 | -WindowsFilesystemNode::WindowsFilesystemNode(const String &p) {
|
---|
4700 | - assert(p.size() > 0);
|
---|
4701 | +WindowsFilesystemNode::WindowsFilesystemNode(const String &p, const bool currentDir) {
|
---|
4702 | + if (currentDir) {
|
---|
4703 | + char path[MAX_PATH];
|
---|
4704 | + GetCurrentDirectory(MAX_PATH, path);
|
---|
4705 |
|
---|
4706 | - _path = p;
|
---|
4707 | + // Add a trailing slash, if necessary.
|
---|
4708 | + if (path[0] != 0) {
|
---|
4709 | + if (path[strlen(path) - 1] != '\\')
|
---|
4710 | + strcat(path, "\\");
|
---|
4711 | + }
|
---|
4712 | + _path = path;
|
---|
4713 | + }
|
---|
4714 | + else {
|
---|
4715 | + assert(p.size() > 0);
|
---|
4716 | + _path = p;
|
---|
4717 | + }
|
---|
4718 | +
|
---|
4719 | _displayName = lastPathComponent(_path);
|
---|
4720 |
|
---|
4721 | // Check whether it is a directory, and whether the file actually exists
|
---|
4722 | @@ -175,11 +221,11 @@
|
---|
4723 | DWORD fileAttribs = GetFileAttributes(toUnicode(_path.c_str()));
|
---|
4724 |
|
---|
4725 | if (fileAttribs == INVALID_FILE_ATTRIBUTES) {
|
---|
4726 | + _isDirectory = false;
|
---|
4727 | _isValid = false;
|
---|
4728 | - _isDirectory = false;
|
---|
4729 | } else {
|
---|
4730 | + _isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
---|
4731 | _isValid = true;
|
---|
4732 | - _isDirectory = ((fileAttribs & FILE_ATTRIBUTE_DIRECTORY) != 0);
|
---|
4733 | }
|
---|
4734 | _isPseudoRoot = false;
|
---|
4735 | }
|
---|
4736 | @@ -184,9 +230,27 @@
|
---|
4737 | _isPseudoRoot = false;
|
---|
4738 | }
|
---|
4739 |
|
---|
4740 | -bool WindowsFilesystemNode::listDir(AbstractFSList &myList, ListMode mode) const {
|
---|
4741 | +AbstractFilesystemNode *WindowsFilesystemNode::getChild(const String &n) const {
|
---|
4742 | + assert(_isDirectory);
|
---|
4743 | +
|
---|
4744 | + String newPath(_path);
|
---|
4745 | + if (_path.lastChar() != '\\')
|
---|
4746 | + newPath += '\\';
|
---|
4747 | + newPath += n;
|
---|
4748 | +
|
---|
4749 | + // Check whether the directory actually exists
|
---|
4750 | + DWORD fileAttribs = GetFileAttributes(toUnicode(newPath.c_str()));
|
---|
4751 | + if (fileAttribs == INVALID_FILE_ATTRIBUTES)
|
---|
4752 | + return 0;
|
---|
4753 | +
|
---|
4754 | + return new WindowsFilesystemNode(newPath, false);
|
---|
4755 | +}
|
---|
4756 | +
|
---|
4757 | +bool WindowsFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, bool hidden) const {
|
---|
4758 | assert(_isDirectory);
|
---|
4759 |
|
---|
4760 | + //TODO: honor the hidden flag
|
---|
4761 | +
|
---|
4762 | if (_isPseudoRoot) {
|
---|
4763 | #ifndef _WIN32_WCE
|
---|
4764 | // Drives enumeration
|
---|
4765 | @@ -218,9 +282,12 @@
|
---|
4766 | sprintf(searchPath, "%s*", _path.c_str());
|
---|
4767 |
|
---|
4768 | handle = FindFirstFile(toUnicode(searchPath), &desc);
|
---|
4769 | +
|
---|
4770 | if (handle == INVALID_HANDLE_VALUE)
|
---|
4771 | return false;
|
---|
4772 | +
|
---|
4773 | addFile(myList, mode, _path.c_str(), &desc);
|
---|
4774 | +
|
---|
4775 | while (FindNextFile(handle, &desc))
|
---|
4776 | addFile(myList, mode, _path.c_str(), &desc);
|
---|
4777 |
|
---|
4778 | @@ -230,10 +297,12 @@
|
---|
4779 | return true;
|
---|
4780 | }
|
---|
4781 |
|
---|
4782 | -AbstractFilesystemNode *WindowsFilesystemNode::parent() const {
|
---|
4783 | +AbstractFilesystemNode *WindowsFilesystemNode::getParent() const {
|
---|
4784 | assert(_isValid || _isPseudoRoot);
|
---|
4785 | +
|
---|
4786 | if (_isPseudoRoot)
|
---|
4787 | return 0;
|
---|
4788 | +
|
---|
4789 | WindowsFilesystemNode *p = new WindowsFilesystemNode();
|
---|
4790 | if (_path.size() > 3) {
|
---|
4791 | const char *start = _path.c_str();
|
---|
4792 | @@ -246,23 +315,8 @@
|
---|
4793 | p->_displayName = lastPathComponent(p->_path);
|
---|
4794 | p->_isPseudoRoot = false;
|
---|
4795 | }
|
---|
4796 | +
|
---|
4797 | return p;
|
---|
4798 | }
|
---|
4799 |
|
---|
4800 | -AbstractFilesystemNode *WindowsFilesystemNode::child(const String &n) const {
|
---|
4801 | - assert(_isDirectory);
|
---|
4802 | - String newPath(_path);
|
---|
4803 | - if (_path.lastChar() != '\\')
|
---|
4804 | - newPath += '\\';
|
---|
4805 | - newPath += n;
|
---|
4806 | -
|
---|
4807 | - // Check whether the directory actually exists
|
---|
4808 | - DWORD fileAttribs = GetFileAttributes(toUnicode(newPath.c_str()));
|
---|
4809 | - if (fileAttribs == INVALID_FILE_ATTRIBUTES)
|
---|
4810 | - return 0;
|
---|
4811 | -
|
---|
4812 | - WindowsFilesystemNode *p = new WindowsFilesystemNode(newPath);
|
---|
4813 | - return p;
|
---|
4814 | -}
|
---|
4815 | -
|
---|
4816 | -#endif // WIN32
|
---|
4817 | +#endif //#ifdef WIN32
|
---|
4818 | Index: /home/david/Projects/scummvm/backends/plugins/dc/dc-provider.cpp
|
---|
4819 | ===================================================================
|
---|
4820 | --- /home/david/Projects/scummvm/backends/plugins/dc/dc-provider.cpp (revision 28941)
|
---|
4821 | +++ /home/david/Projects/scummvm/backends/plugins/dc/dc-provider.cpp (working copy)
|
---|
4822 | @@ -114,7 +114,7 @@
|
---|
4823 | // Scan for all plugins in this directory
|
---|
4824 | FilesystemNode dir(PLUGIN_DIRECTORY);
|
---|
4825 | FSList files;
|
---|
4826 | - if (!dir.listDir(files, FilesystemNode::kListFilesOnly)) {
|
---|
4827 | + if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) {
|
---|
4828 | error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY);
|
---|
4829 | }
|
---|
4830 |
|
---|
4831 | @@ -119,9 +119,9 @@
|
---|
4832 | }
|
---|
4833 |
|
---|
4834 | for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
|
---|
4835 | - Common::String name(i->name());
|
---|
4836 | + Common::String name(i->getName());
|
---|
4837 | if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) {
|
---|
4838 | - pl.push_back(new DCPlugin(i->path()));
|
---|
4839 | + pl.push_back(new DCPlugin(i->getPath()));
|
---|
4840 | }
|
---|
4841 | }
|
---|
4842 |
|
---|
4843 | Index: /home/david/Projects/scummvm/backends/plugins/posix/posix-provider.cpp
|
---|
4844 | ===================================================================
|
---|
4845 | --- /home/david/Projects/scummvm/backends/plugins/posix/posix-provider.cpp (revision 28941)
|
---|
4846 | +++ /home/david/Projects/scummvm/backends/plugins/posix/posix-provider.cpp (working copy)
|
---|
4847 | @@ -107,7 +107,7 @@
|
---|
4848 | // Scan for all plugins in this directory
|
---|
4849 | FilesystemNode dir(PLUGIN_DIRECTORY);
|
---|
4850 | FSList files;
|
---|
4851 | - if (!dir.listDir(files, FilesystemNode::kListFilesOnly)) {
|
---|
4852 | + if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) {
|
---|
4853 | error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY);
|
---|
4854 | }
|
---|
4855 |
|
---|
4856 | @@ -112,9 +112,9 @@
|
---|
4857 | }
|
---|
4858 |
|
---|
4859 | for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
|
---|
4860 | - Common::String name(i->name());
|
---|
4861 | + Common::String name(i->getName());
|
---|
4862 | if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) {
|
---|
4863 | - pl.push_back(new POSIXPlugin(i->path()));
|
---|
4864 | + pl.push_back(new POSIXPlugin(i->getPath()));
|
---|
4865 | }
|
---|
4866 | }
|
---|
4867 |
|
---|
4868 | Index: /home/david/Projects/scummvm/backends/plugins/sdl/sdl-provider.cpp
|
---|
4869 | ===================================================================
|
---|
4870 | --- /home/david/Projects/scummvm/backends/plugins/sdl/sdl-provider.cpp (revision 28941)
|
---|
4871 | +++ /home/david/Projects/scummvm/backends/plugins/sdl/sdl-provider.cpp (working copy)
|
---|
4872 | @@ -107,7 +107,7 @@
|
---|
4873 | // Scan for all plugins in this directory
|
---|
4874 | FilesystemNode dir(PLUGIN_DIRECTORY);
|
---|
4875 | FSList files;
|
---|
4876 | - if (!dir.listDir(files, FilesystemNode::kListFilesOnly)) {
|
---|
4877 | + if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) {
|
---|
4878 | error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY);
|
---|
4879 | }
|
---|
4880 |
|
---|
4881 | @@ -112,9 +112,9 @@
|
---|
4882 | }
|
---|
4883 |
|
---|
4884 | for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
|
---|
4885 | - Common::String name(i->name());
|
---|
4886 | + Common::String name(i->getName());
|
---|
4887 | if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) {
|
---|
4888 | - pl.push_back(new SDLPlugin(i->path()));
|
---|
4889 | + pl.push_back(new SDLPlugin(i->getPath()));
|
---|
4890 | }
|
---|
4891 | }
|
---|
4892 |
|
---|
4893 | Index: /home/david/Projects/scummvm/backends/plugins/win32/win32-provider.cpp
|
---|
4894 | ===================================================================
|
---|
4895 | --- /home/david/Projects/scummvm/backends/plugins/win32/win32-provider.cpp (revision 28941)
|
---|
4896 | +++ /home/david/Projects/scummvm/backends/plugins/win32/win32-provider.cpp (working copy)
|
---|
4897 | @@ -110,7 +110,7 @@
|
---|
4898 | // Scan for all plugins in this directory
|
---|
4899 | FilesystemNode dir(PLUGIN_DIRECTORY);
|
---|
4900 | FSList files;
|
---|
4901 | - if (!dir.listDir(files, FilesystemNode::kListFilesOnly)) {
|
---|
4902 | + if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) {
|
---|
4903 | error("Couldn't open plugin directory '%s'", PLUGIN_DIRECTORY);
|
---|
4904 | }
|
---|
4905 |
|
---|
4906 | @@ -115,9 +115,9 @@
|
---|
4907 | }
|
---|
4908 |
|
---|
4909 | for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) {
|
---|
4910 | - Common::String name(i->name());
|
---|
4911 | + Common::String name(i->getName());
|
---|
4912 | if (name.hasPrefix(PLUGIN_PREFIX) && name.hasSuffix(PLUGIN_SUFFIX)) {
|
---|
4913 | - pl.push_back(new Win32Plugin(i->path()));
|
---|
4914 | + pl.push_back(new Win32Plugin(i->getPath()));
|
---|
4915 | }
|
---|
4916 | }
|
---|
4917 |
|
---|
4918 | Index: /home/david/Projects/scummvm/backends/saves/default/default-saves.cpp
|
---|
4919 | ===================================================================
|
---|
4920 | --- /home/david/Projects/scummvm/backends/saves/default/default-saves.cpp (revision 28941)
|
---|
4921 | +++ /home/david/Projects/scummvm/backends/saves/default/default-saves.cpp (working copy)
|
---|
4922 | @@ -28,6 +28,8 @@
|
---|
4923 | #include "common/stdafx.h"
|
---|
4924 | #include "common/savefile.h"
|
---|
4925 | #include "common/util.h"
|
---|
4926 | +#include "common/fs.h"
|
---|
4927 | +#include "common/file.h"
|
---|
4928 | #include "backends/saves/default/default-saves.h"
|
---|
4929 | #include "backends/saves/compressed/compressed-saves.h"
|
---|
4930 |
|
---|
4931 | @@ -86,7 +88,6 @@
|
---|
4932 | }
|
---|
4933 | };
|
---|
4934 |
|
---|
4935 | -
|
---|
4936 | static void join_paths(const char *filename, const char *directory,
|
---|
4937 | char *buf, int bufsize) {
|
---|
4938 | buf[bufsize-1] = '\0';
|
---|
4939 | @@ -113,6 +114,34 @@
|
---|
4940 | strncat(buf, filename, bufsize-1);
|
---|
4941 | }
|
---|
4942 |
|
---|
4943 | +Common::StringList DefaultSaveFileManager::listSavefiles(const char *regex) {
|
---|
4944 | + FilesystemNode savePath(getSavePath());
|
---|
4945 | + FSList savefiles;
|
---|
4946 | + Common::StringList results;
|
---|
4947 | + Common::String search(regex);
|
---|
4948 | +
|
---|
4949 | + if (savePath.lookupFile(savefiles, savePath, search, false, true)) {
|
---|
4950 | + for (FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); file++) {
|
---|
4951 | + results.push_back(file->getPath());
|
---|
4952 | + }
|
---|
4953 | + }
|
---|
4954 | +
|
---|
4955 | + return results;
|
---|
4956 | +}
|
---|
4957 | +
|
---|
4958 | +Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) {
|
---|
4959 | + char buf[256];
|
---|
4960 | + join_paths(filename, getSavePath(), buf, sizeof(buf));
|
---|
4961 | +
|
---|
4962 | + StdioSaveFile *sf = new StdioSaveFile(buf, false);
|
---|
4963 | +
|
---|
4964 | + if (!sf->isOpen()) {
|
---|
4965 | + delete sf;
|
---|
4966 | + sf = 0;
|
---|
4967 | + }
|
---|
4968 | + return wrapInSaveFile(sf);
|
---|
4969 | +}
|
---|
4970 | +
|
---|
4971 | Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) {
|
---|
4972 | char buf[256];
|
---|
4973 |
|
---|
4974 | @@ -119,8 +148,10 @@
|
---|
4975 | // Ensure that the savepath exists and is writeable. If not, generate
|
---|
4976 | // an appropriate error
|
---|
4977 | const char *savePath = getSavePath();
|
---|
4978 | +
|
---|
4979 | #if defined(UNIX) || defined(__SYMBIAN32__)
|
---|
4980 | struct stat sb;
|
---|
4981 | + clearError();
|
---|
4982 |
|
---|
4983 | // Check whether the dir exists
|
---|
4984 | if (stat(savePath, &sb) == -1) {
|
---|
4985 | @@ -126,8 +157,18 @@
|
---|
4986 | if (stat(savePath, &sb) == -1) {
|
---|
4987 | // The dir does not exist, or stat failed for some other reason.
|
---|
4988 | // If the problem was that the path pointed to nothing, try
|
---|
4989 | - // to create the dir.
|
---|
4990 | - if (errno == ENOENT) {
|
---|
4991 | + // to create the dir (ENOENT case).
|
---|
4992 | + switch (errno) {
|
---|
4993 | + case EACCES:
|
---|
4994 | + setError(SFM_DIR_ACCESS, Common::String("Search or write permission denied"));
|
---|
4995 | + break;
|
---|
4996 | + case ELOOP:
|
---|
4997 | + setError(SFM_DIR_LOOP, Common::String("Too many symbolic links encountered while traversing the path"));
|
---|
4998 | + break;
|
---|
4999 | + case ENAMETOOLONG:
|
---|
5000 | + setError(SFM_DIR_NAMETOOLONG, Common::String("The path name is too long"));
|
---|
5001 | + break;
|
---|
5002 | + case ENOENT:
|
---|
5003 | if (mkdir(savePath, 0755) != 0) {
|
---|
5004 | // mkdir could fail for various reasons: The parent dir doesn't exist,
|
---|
5005 | // or is not writeable, the path could be completly bogus, etc.
|
---|
5006 | @@ -133,22 +174,43 @@
|
---|
5007 | // or is not writeable, the path could be completly bogus, etc.
|
---|
5008 | warning("mkdir for '%s' failed!", savePath);
|
---|
5009 | perror("mkdir");
|
---|
5010 | - // TODO: Specify an error code here so that callers can
|
---|
5011 | - // determine what exactly went wrong.
|
---|
5012 | +
|
---|
5013 | + switch (errno) {
|
---|
5014 | + case EACCES:
|
---|
5015 | + setError(SFM_DIR_ACCESS, Common::String("Search or write permission denied"));
|
---|
5016 | + break;
|
---|
5017 | + case EMLINK:
|
---|
5018 | + setError(SFM_DIR_LINKMAX, Common::String("The link count of the parent directory would exceed {LINK_MAX}"));
|
---|
5019 | + break;
|
---|
5020 | + case ELOOP:
|
---|
5021 | + setError(SFM_DIR_LOOP, Common::String("Too many symbolic links encountered while traversing the path"));
|
---|
5022 | + break;
|
---|
5023 | + case ENAMETOOLONG:
|
---|
5024 | + setError(SFM_DIR_NAMETOOLONG, Common::String("The path name is too long"));
|
---|
5025 | + break;
|
---|
5026 | + case ENOENT:
|
---|
5027 | + setError(SFM_DIR_NOENT, Common::String("A component of the path path does not exist, or the path is an empty string"));
|
---|
5028 | + break;
|
---|
5029 | + case ENOTDIR:
|
---|
5030 | + setError(SFM_DIR_NOTDIR, Common::String("A component of the path prefix is not a directory"));
|
---|
5031 | + break;
|
---|
5032 | + case EROFS:
|
---|
5033 | + setError(SFM_DIR_ROFS, Common::String("The parent directory resides on a read-only file system"));
|
---|
5034 | + break;
|
---|
5035 | + }
|
---|
5036 | +
|
---|
5037 | return 0;
|
---|
5038 | }
|
---|
5039 | - } else {
|
---|
5040 | - // Unknown error, abort.
|
---|
5041 | - // TODO: Specify an error code here so that callers can
|
---|
5042 | - // determine what exactly went wrong.
|
---|
5043 | - return 0;
|
---|
5044 | - }
|
---|
5045 | + break;
|
---|
5046 | + case ENOTDIR:
|
---|
5047 | + setError(SFM_DIR_NOTDIR, Common::String("A component of the path prefix is not a directory"));
|
---|
5048 | + break;
|
---|
5049 | + }
|
---|
5050 | } else {
|
---|
5051 | - // So stat() succeeded. But is the path actually pointing to a
|
---|
5052 | - // directory?
|
---|
5053 | + // So stat() succeeded. But is the path actually pointing to a directory?
|
---|
5054 | if (!S_ISDIR(sb.st_mode)) {
|
---|
5055 | - // TODO: Specify an error code here so that callers can
|
---|
5056 | - // determine what exactly went wrong.
|
---|
5057 | + setError(SFM_DIR_NOTDIR, Common::String("The given savepath is not a directory"));
|
---|
5058 | +
|
---|
5059 | return 0;
|
---|
5060 | }
|
---|
5061 | }
|
---|
5062 | @@ -163,27 +225,14 @@
|
---|
5063 | delete sf;
|
---|
5064 | sf = 0;
|
---|
5065 | }
|
---|
5066 | +
|
---|
5067 | return wrapOutSaveFile(sf);
|
---|
5068 | }
|
---|
5069 |
|
---|
5070 | -Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) {
|
---|
5071 | - char buf[256];
|
---|
5072 | - join_paths(filename, getSavePath(), buf, sizeof(buf));
|
---|
5073 | -
|
---|
5074 | - StdioSaveFile *sf = new StdioSaveFile(buf, false);
|
---|
5075 | -
|
---|
5076 | - if (!sf->isOpen()) {
|
---|
5077 | - delete sf;
|
---|
5078 | - sf = 0;
|
---|
5079 | - }
|
---|
5080 | - return wrapInSaveFile(sf);
|
---|
5081 | -}
|
---|
5082 | -
|
---|
5083 | -void DefaultSaveFileManager::listSavefiles(const char * /* prefix */, bool *marks, int num) {
|
---|
5084 | - // TODO: Implement this properly, at least on systems that support
|
---|
5085 | - // opendir/readdir.
|
---|
5086 | - // Even better, replace this with a better design...
|
---|
5087 | - memset(marks, true, num * sizeof(bool));
|
---|
5088 | +bool DefaultSaveFileManager::removeSavefile(const char *filename) {
|
---|
5089 | + Common::File file;
|
---|
5090 | + FilesystemNode savePath(filename);
|
---|
5091 | + return file.remove(savePath);
|
---|
5092 | }
|
---|
5093 |
|
---|
5094 | #endif // !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)
|
---|
5095 | Index: /home/david/Projects/scummvm/backends/saves/default/default-saves.h
|
---|
5096 | ===================================================================
|
---|
5097 | --- /home/david/Projects/scummvm/backends/saves/default/default-saves.h (revision 28941)
|
---|
5098 | +++ /home/david/Projects/scummvm/backends/saves/default/default-saves.h (working copy)
|
---|
5099 | @@ -28,12 +28,14 @@
|
---|
5100 |
|
---|
5101 | #include "common/stdafx.h"
|
---|
5102 | #include "common/savefile.h"
|
---|
5103 | +#include "common/str.h"
|
---|
5104 |
|
---|
5105 | class DefaultSaveFileManager : public Common::SaveFileManager {
|
---|
5106 | public:
|
---|
5107 | + virtual Common::StringList listSavefiles(const char *regex);
|
---|
5108 | + virtual Common::InSaveFile *openForLoading(const char *filename);
|
---|
5109 | virtual Common::OutSaveFile *openForSaving(const char *filename);
|
---|
5110 | - virtual Common::InSaveFile *openForLoading(const char *filename);
|
---|
5111 | - virtual void listSavefiles(const char * /* prefix */, bool *marks, int num);
|
---|
5112 | + virtual bool removeSavefile(const char *filename);
|
---|
5113 | };
|
---|
5114 |
|
---|
5115 | #endif
|
---|
5116 | Index: /home/david/Projects/scummvm/base/commandLine.cpp
|
---|
5117 | ===================================================================
|
---|
5118 | --- /home/david/Projects/scummvm/base/commandLine.cpp (revision 28941)
|
---|
5119 | +++ /home/david/Projects/scummvm/base/commandLine.cpp (working copy)
|
---|
5120 | @@ -32,6 +32,7 @@
|
---|
5121 |
|
---|
5122 | #include "common/config-manager.h"
|
---|
5123 | #include "common/system.h"
|
---|
5124 | +#include "common/fs.h"
|
---|
5125 |
|
---|
5126 | #include "sound/mididrv.h"
|
---|
5127 | #include "sound/mixer.h"
|
---|
5128 | @@ -48,10 +49,6 @@
|
---|
5129 |
|
---|
5130 | #define DETECTOR_TESTING_HACK
|
---|
5131 |
|
---|
5132 | -#ifdef DETECTOR_TESTING_HACK
|
---|
5133 | -#include "common/fs.h"
|
---|
5134 | -#endif
|
---|
5135 | -
|
---|
5136 | namespace Base {
|
---|
5137 |
|
---|
5138 | static const char USAGE_STRING[] =
|
---|
5139 | @@ -313,7 +310,7 @@
|
---|
5140 | for (int i = 1; i < argc; ++i) {
|
---|
5141 | s = argv[i];
|
---|
5142 | s2 = (i < argc-1) ? argv[i+1] : 0;
|
---|
5143 | -
|
---|
5144 | +
|
---|
5145 | if (s[0] != '-') {
|
---|
5146 | // The argument doesn't start with a dash, so it's not an option.
|
---|
5147 | // Hence it must be the target name. We currently enforce that
|
---|
5148 | @@ -390,7 +387,12 @@
|
---|
5149 | END_OPTION
|
---|
5150 |
|
---|
5151 | DO_OPTION('p', "path")
|
---|
5152 | - // TODO: Verify whether the path is valid
|
---|
5153 | + FilesystemNode path(option);
|
---|
5154 | + if(!path.exists()) {
|
---|
5155 | + usage("Non-existent game path '%s'", option);
|
---|
5156 | + } else if(!path.isReadable()) {
|
---|
5157 | + usage("Non-readable game path '%s'", option);
|
---|
5158 | + }
|
---|
5159 | END_OPTION
|
---|
5160 |
|
---|
5161 | DO_OPTION('q', "language")
|
---|
5162 | @@ -428,7 +430,12 @@
|
---|
5163 | END_OPTION
|
---|
5164 |
|
---|
5165 | DO_LONG_OPTION("soundfont")
|
---|
5166 | - // TODO: Verify whether the path is valid
|
---|
5167 | + FilesystemNode path(option);
|
---|
5168 | + if(!path.exists()) {
|
---|
5169 | + usage("Non-existent soundfont path '%s'", option);
|
---|
5170 | + } else if(!path.isReadable()) {
|
---|
5171 | + usage("Non-readable soundfont path '%s'", option);
|
---|
5172 | + }
|
---|
5173 | END_OPTION
|
---|
5174 |
|
---|
5175 | DO_LONG_OPTION_BOOL("disable-sdl-parachute")
|
---|
5176 | @@ -453,7 +460,12 @@
|
---|
5177 | END_OPTION
|
---|
5178 |
|
---|
5179 | DO_LONG_OPTION("savepath")
|
---|
5180 | - // TODO: Verify whether the path is valid
|
---|
5181 | + FilesystemNode path(option);
|
---|
5182 | + if(!path.exists()) {
|
---|
5183 | + usage("Non-existent savegames path '%s'", option);
|
---|
5184 | + } else if(!path.isWritable()) {
|
---|
5185 | + usage("Non-writable savegames path '%s'", option);
|
---|
5186 | + }
|
---|
5187 | END_OPTION
|
---|
5188 |
|
---|
5189 | DO_LONG_OPTION_INT("talkspeed")
|
---|
5190 | @@ -466,7 +478,12 @@
|
---|
5191 | END_OPTION
|
---|
5192 |
|
---|
5193 | DO_LONG_OPTION("themepath")
|
---|
5194 | - // TODO: Verify whether the path is valid
|
---|
5195 | + FilesystemNode path(option);
|
---|
5196 | + if(!path.exists()) {
|
---|
5197 | + usage("Non-existent theme path '%s'", option);
|
---|
5198 | + } else if(!path.isReadable()) {
|
---|
5199 | + usage("Non-readable theme path '%s'", option);
|
---|
5200 | + }
|
---|
5201 | END_OPTION
|
---|
5202 |
|
---|
5203 | DO_LONG_OPTION("target-md5")
|
---|
5204 | @@ -562,7 +579,7 @@
|
---|
5205 |
|
---|
5206 | FilesystemNode dir(path);
|
---|
5207 | FSList files;
|
---|
5208 | - if (!dir.listDir(files, FilesystemNode::kListAll)) {
|
---|
5209 | + if (!dir.getChildren(files, FilesystemNode::kListAll)) {
|
---|
5210 | printf(" ... invalid path, skipping\n");
|
---|
5211 | continue;
|
---|
5212 | }
|
---|
5213 | @@ -673,8 +690,14 @@
|
---|
5214 | if (!settings.contains("savepath")) {
|
---|
5215 | const char *dir = getenv("SCUMMVM_SAVEPATH");
|
---|
5216 | if (dir && *dir && strlen(dir) < MAXPATHLEN) {
|
---|
5217 | - // TODO: Verify whether the path is valid
|
---|
5218 | - settings["savepath"] = dir;
|
---|
5219 | + FilesystemNode saveDir(dir);
|
---|
5220 | + if(!saveDir.exists()) {
|
---|
5221 | + warning("Non-existent SCUMMVM_SAVEPATH save path. It will be ignored.");
|
---|
5222 | + } else if(!saveDir.isWritable()) {
|
---|
5223 | + warning("Non-writable SCUMMVM_SAVEPATH save path. It will be ignored.");
|
---|
5224 | + } else {
|
---|
5225 | + settings["savepath"] = dir;
|
---|
5226 | + }
|
---|
5227 | }
|
---|
5228 | }
|
---|
5229 | #endif
|
---|
5230 | @@ -679,7 +702,6 @@
|
---|
5231 | }
|
---|
5232 | #endif
|
---|
5233 |
|
---|
5234 | -
|
---|
5235 | // Finally, store the command line settings into the config manager.
|
---|
5236 | for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) {
|
---|
5237 | Common::String key(x->_key);
|
---|
5238 | Index: /home/david/Projects/scummvm/common/advancedDetector.cpp
|
---|
5239 | ===================================================================
|
---|
5240 | --- /home/david/Projects/scummvm/common/advancedDetector.cpp (revision 28941)
|
---|
5241 | +++ /home/david/Projects/scummvm/common/advancedDetector.cpp (working copy)
|
---|
5242 | @@ -276,7 +276,7 @@
|
---|
5243 |
|
---|
5244 | FSList fslist;
|
---|
5245 | FilesystemNode dir(ConfMan.get("path"));
|
---|
5246 | - if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
5247 | + if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
5248 | return kInvalidPathError;
|
---|
5249 | }
|
---|
5250 |
|
---|
5251 | @@ -345,7 +345,7 @@
|
---|
5252 | // Get the information of the existing files
|
---|
5253 | for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
|
---|
5254 | if (file->isDirectory()) continue;
|
---|
5255 | - tstr = file->name();
|
---|
5256 | + tstr = file->getName();
|
---|
5257 | tstr.toLowercase();
|
---|
5258 |
|
---|
5259 | // Strip any trailing dot
|
---|
5260 | @@ -364,7 +364,7 @@
|
---|
5261 |
|
---|
5262 | debug(3, "> %s: %s", tstr.c_str(), md5str);
|
---|
5263 |
|
---|
5264 | - if (testFile.open(file->path())) {
|
---|
5265 | + if (testFile.open(file->getPath())) {
|
---|
5266 | filesSize[tstr] = (int32)testFile.size();
|
---|
5267 | testFile.close();
|
---|
5268 | }
|
---|
5269 | Index: /home/david/Projects/scummvm/common/error.h
|
---|
5270 | ===================================================================
|
---|
5271 | --- /home/david/Projects/scummvm/common/error.h (revision 0)
|
---|
5272 | +++ /home/david/Projects/scummvm/common/error.h (revision 0)
|
---|
5273 | @@ -0,0 +1,47 @@
|
---|
5274 | +/* ScummVM - Graphic Adventure Engine
|
---|
5275 | + *
|
---|
5276 | + * ScummVM is the legal property of its developers, whose names
|
---|
5277 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
5278 | + * file distributed with this source distribution.
|
---|
5279 | + *
|
---|
5280 | + * This program is free software; you can redistribute it and/or
|
---|
5281 | + * modify it under the terms of the GNU General Public License
|
---|
5282 | + * as published by the Free Software Foundation; either version 2
|
---|
5283 | + * of the License, or (at your option) any later version.
|
---|
5284 | +
|
---|
5285 | + * This program is distributed in the hope that it will be useful,
|
---|
5286 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
5287 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
5288 | + * GNU General Public License for more details.
|
---|
5289 | +
|
---|
5290 | + * You should have received a copy of the GNU General Public License
|
---|
5291 | + * along with this program; if not, write to the Free Software
|
---|
5292 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
5293 | + *
|
---|
5294 | + * $URL: $
|
---|
5295 | + * $Id: $
|
---|
5296 | + *
|
---|
5297 | + */
|
---|
5298 | +
|
---|
5299 | +#ifndef COMMON_ERROR_H
|
---|
5300 | +#define COMMON_ERROR_H
|
---|
5301 | +
|
---|
5302 | +/**
|
---|
5303 | + * This file contains enums with error codes commonly used.
|
---|
5304 | + */
|
---|
5305 | +
|
---|
5306 | +/**
|
---|
5307 | + * Errors used in the SaveFileManager class.
|
---|
5308 | + */
|
---|
5309 | +enum SFMError {
|
---|
5310 | + SFM_NO_ERROR, //Default state, indicates no error has been recorded
|
---|
5311 | + SFM_DIR_ACCESS, //stat(), mkdir()::EACCES: Search or write permission denied
|
---|
5312 | + SFM_DIR_LINKMAX, //mkdir()::EMLINK: The link count of the parent directory would exceed {LINK_MAX}
|
---|
5313 | + SFM_DIR_LOOP, //stat(), mkdir()::ELOOP: Too many symbolic links encountered while traversing the path
|
---|
5314 | + SFM_DIR_NAMETOOLONG, //stat(), mkdir()::ENAMETOOLONG: The path name is too long
|
---|
5315 | + SFM_DIR_NOENT, //stat(), mkdir()::ENOENT: A component of the path path does not exist, or the path is an empty string
|
---|
5316 | + SFM_DIR_NOTDIR, //stat(), mkdir()::ENOTDIR: A component of the path prefix is not a directory
|
---|
5317 | + SFM_DIR_ROFS //mkdir()::EROFS: The parent directory resides on a read-only file system
|
---|
5318 | +};
|
---|
5319 | +
|
---|
5320 | +#endif //COMMON_ERROR_H
|
---|
5321 |
|
---|
5322 | Property changes on: /home/david/Projects/scummvm/common/error.h
|
---|
5323 | ___________________________________________________________________
|
---|
5324 | Name: svn:eol-style
|
---|
5325 | + native
|
---|
5326 | Name: svn:keywords
|
---|
5327 | + Date Rev Author URL Id
|
---|
5328 | Name: svn:mime-type
|
---|
5329 | + text/plain
|
---|
5330 |
|
---|
5331 | Index: /home/david/Projects/scummvm/common/file.cpp
|
---|
5332 | ===================================================================
|
---|
5333 | --- /home/david/Projects/scummvm/common/file.cpp (revision 28941)
|
---|
5334 | +++ /home/david/Projects/scummvm/common/file.cpp (working copy)
|
---|
5335 | @@ -28,6 +28,7 @@
|
---|
5336 | #include "common/hashmap.h"
|
---|
5337 | #include "common/util.h"
|
---|
5338 | #include "common/hash-str.h"
|
---|
5339 | +#include <errno.h>
|
---|
5340 |
|
---|
5341 | #ifdef MACOSX
|
---|
5342 | #include "CoreFoundation/CoreFoundation.h"
|
---|
5343 | @@ -226,7 +227,7 @@
|
---|
5344 | return;
|
---|
5345 |
|
---|
5346 | FSList fslist;
|
---|
5347 | - if (!dir.listDir(fslist, FilesystemNode::kListAll)) {
|
---|
5348 | + if (!dir.getChildren(fslist, FilesystemNode::kListAll)) {
|
---|
5349 | // Failed listing the contents of this node, so it is either not a
|
---|
5350 | // directory, or just doesn't exist at all.
|
---|
5351 | return;
|
---|
5352 | @@ -237,7 +238,7 @@
|
---|
5353 |
|
---|
5354 | // Do not add directories multiple times, unless this time they are added
|
---|
5355 | // with a bigger depth.
|
---|
5356 | - const String &directory(dir.path());
|
---|
5357 | + const String &directory(dir.getPath());
|
---|
5358 | if (_defaultDirectories->contains(directory) && (*_defaultDirectories)[directory] >= level)
|
---|
5359 | return;
|
---|
5360 | (*_defaultDirectories)[directory] = level;
|
---|
5361 | @@ -247,13 +248,13 @@
|
---|
5362 |
|
---|
5363 | for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
5364 | if (file->isDirectory()) {
|
---|
5365 | - addDefaultDirectoryRecursive(file->path(), level - 1, prefix + file->name() + "/");
|
---|
5366 | + addDefaultDirectoryRecursive(file->getPath(), level - 1, prefix + file->getName() + "/");
|
---|
5367 | } else {
|
---|
5368 | String lfn(prefix);
|
---|
5369 | - lfn += file->name();
|
---|
5370 | + lfn += file->getName();
|
---|
5371 | lfn.toLowercase();
|
---|
5372 | if (!_filesMap->contains(lfn)) {
|
---|
5373 | - (*_filesMap)[lfn] = file->path();
|
---|
5374 | + (*_filesMap)[lfn] = file->getPath();
|
---|
5375 | }
|
---|
5376 | }
|
---|
5377 | }
|
---|
5378 | @@ -364,8 +365,8 @@
|
---|
5379 | bool File::open(const FilesystemNode &node, AccessMode mode) {
|
---|
5380 | assert(mode == kFileReadMode || mode == kFileWriteMode);
|
---|
5381 |
|
---|
5382 | - if (!node.isValid()) {
|
---|
5383 | - warning("File::open: Trying to open an invalid FilesystemNode object");
|
---|
5384 | + if (!node.exists()) {
|
---|
5385 | + warning("File::open: Trying to open a FilesystemNode which does not exist");
|
---|
5386 | return false;
|
---|
5387 | } else if (node.isDirectory()) {
|
---|
5388 | warning("File::open: Trying to open a FilesystemNode which is a directory");
|
---|
5389 | @@ -370,9 +371,15 @@
|
---|
5390 | } else if (node.isDirectory()) {
|
---|
5391 | warning("File::open: Trying to open a FilesystemNode which is a directory");
|
---|
5392 | return false;
|
---|
5393 | - }
|
---|
5394 | + } /*else if (!node.isReadable() && mode == kFileReadMode) {
|
---|
5395 | + warning("File::open: Trying to open an unreadable FilesystemNode object for reading");
|
---|
5396 | + return false;
|
---|
5397 | + } else if (!node.isWritable() && mode == kFileWriteMode) {
|
---|
5398 | + warning("File::open: Trying to open an unwritable FilesystemNode object for writing");
|
---|
5399 | + return false;
|
---|
5400 | + }*/
|
---|
5401 |
|
---|
5402 | - String filename(node.name());
|
---|
5403 | + String filename(node.getName());
|
---|
5404 |
|
---|
5405 | if (_handle) {
|
---|
5406 | error("File::open: This file object already is opened (%s), won't open '%s'", _name.c_str(), filename.c_str());
|
---|
5407 | @@ -383,7 +390,7 @@
|
---|
5408 |
|
---|
5409 | const char *modeStr = (mode == kFileReadMode) ? "rb" : "wb";
|
---|
5410 |
|
---|
5411 | - _handle = fopen(node.path().c_str(), modeStr);
|
---|
5412 | + _handle = fopen(node.getPath().c_str(), modeStr);
|
---|
5413 |
|
---|
5414 | if (_handle == NULL) {
|
---|
5415 | if (mode == kFileReadMode)
|
---|
5416 | @@ -402,6 +409,32 @@
|
---|
5417 | return true;
|
---|
5418 | }
|
---|
5419 |
|
---|
5420 | +bool File::remove(const String &filename){
|
---|
5421 | + if (remove(filename.c_str()) != 0) {
|
---|
5422 | + if(errno == EACCES)
|
---|
5423 | + ;//TODO: read-only file
|
---|
5424 | + if(errno == ENOENT)
|
---|
5425 | + ;//TODO: non-existent file
|
---|
5426 | +
|
---|
5427 | + return false;
|
---|
5428 | + } else {
|
---|
5429 | + return true;
|
---|
5430 | + }
|
---|
5431 | +}
|
---|
5432 | +
|
---|
5433 | +bool File::remove(const FilesystemNode &node){
|
---|
5434 | + if (remove(node.getPath()) != 0) {
|
---|
5435 | + if(errno == EACCES)
|
---|
5436 | + ;//TODO: read-only file
|
---|
5437 | + if(errno == ENOENT)
|
---|
5438 | + ;//TODO: non-existent file
|
---|
5439 | +
|
---|
5440 | + return false;
|
---|
5441 | + } else {
|
---|
5442 | + return true;
|
---|
5443 | + }
|
---|
5444 | +}
|
---|
5445 | +
|
---|
5446 | bool File::exists(const String &filename) {
|
---|
5447 | // First try to find the file it via a FilesystemNode (in case an absolute
|
---|
5448 | // path was passed). But we only use this to filter out directories.
|
---|
5449 | @@ -406,12 +439,10 @@
|
---|
5450 | // First try to find the file it via a FilesystemNode (in case an absolute
|
---|
5451 | // path was passed). But we only use this to filter out directories.
|
---|
5452 | FilesystemNode file(filename);
|
---|
5453 | - // FIXME: can't use isValid() here since at the time of writing
|
---|
5454 | - // FilesystemNode is to be unable to find for example files
|
---|
5455 | - // added in extrapath
|
---|
5456 | - if (file.isDirectory())
|
---|
5457 | - return false;
|
---|
5458 | -
|
---|
5459 | +
|
---|
5460 | + return (!file.isDirectory() && file.exists());
|
---|
5461 | +
|
---|
5462 | + //***DEPRECATED COMMENTS BELOW, LEFT FOR DISCUSSION***
|
---|
5463 | // Next, try to locate the file by *opening* it in read mode. This has
|
---|
5464 | // multiple effects:
|
---|
5465 | // 1) It takes _filesMap and _defaultDirectories into consideration -> good
|
---|
5466 | Index: /home/david/Projects/scummvm/common/file.h
|
---|
5467 | ===================================================================
|
---|
5468 | --- /home/david/Projects/scummvm/common/file.h (revision 28941)
|
---|
5469 | +++ /home/david/Projects/scummvm/common/file.h (working copy)
|
---|
5470 | @@ -52,7 +52,7 @@
|
---|
5471 | // code that accidentally copied File objects tended to break in strange
|
---|
5472 | // ways.
|
---|
5473 | File(const File &f);
|
---|
5474 | - File &operator =(const File &f);
|
---|
5475 | + File &operator =(const File &f);
|
---|
5476 |
|
---|
5477 | public:
|
---|
5478 | enum AccessMode {
|
---|
5479 | @@ -86,6 +86,9 @@
|
---|
5480 |
|
---|
5481 | virtual void close();
|
---|
5482 |
|
---|
5483 | + virtual bool remove(const String &filename);
|
---|
5484 | + virtual bool remove(const FilesystemNode &node);
|
---|
5485 | +
|
---|
5486 | /**
|
---|
5487 | * Checks if the object opened a file successfully.
|
---|
5488 | *
|
---|
5489 | Index: /home/david/Projects/scummvm/common/fs.cpp
|
---|
5490 | ===================================================================
|
---|
5491 | --- /home/david/Projects/scummvm/common/fs.cpp (revision 28941)
|
---|
5492 | +++ /home/david/Projects/scummvm/common/fs.cpp (working copy)
|
---|
5493 | @@ -23,14 +23,45 @@
|
---|
5494 | */
|
---|
5495 |
|
---|
5496 | #include "common/stdafx.h"
|
---|
5497 | -
|
---|
5498 | +#include "common/util.h"
|
---|
5499 | #include "backends/fs/abstract-fs.h"
|
---|
5500 | -#include "common/util.h"
|
---|
5501 | +#include "backends/fs/fs-factory-maker.cpp"
|
---|
5502 |
|
---|
5503 | +/*
|
---|
5504 | + * Simple DOS-style pattern matching function (understands * and ? like used in DOS).
|
---|
5505 | + * Taken from exult/files/listfiles.cc
|
---|
5506 | + */
|
---|
5507 | +static bool matchString(const char *str, const char *pat) {
|
---|
5508 | + const char *p = 0;
|
---|
5509 | + const char *q = 0;
|
---|
5510 | +
|
---|
5511 | + for (;;) {
|
---|
5512 | + switch (*pat) {
|
---|
5513 | + case '*':
|
---|
5514 | + p = ++pat;
|
---|
5515 | + q = str;
|
---|
5516 | + break;
|
---|
5517 |
|
---|
5518 | -FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
|
---|
5519 | - _realNode = realNode;
|
---|
5520 | - _refCount = new int(1);
|
---|
5521 | + default:
|
---|
5522 | + if (*pat != *str) {
|
---|
5523 | + if (p) {
|
---|
5524 | + pat = p;
|
---|
5525 | + str = ++q;
|
---|
5526 | + if(!*str)
|
---|
5527 | + return !*pat;
|
---|
5528 | + break;
|
---|
5529 | + }
|
---|
5530 | + else
|
---|
5531 | + return false;
|
---|
5532 | + }
|
---|
5533 | + // fallthrough
|
---|
5534 | + case '?':
|
---|
5535 | + if(!*str)
|
---|
5536 | + return !*pat;
|
---|
5537 | + pat++;
|
---|
5538 | + str++;
|
---|
5539 | + }
|
---|
5540 | + }
|
---|
5541 | }
|
---|
5542 |
|
---|
5543 | FilesystemNode::FilesystemNode() {
|
---|
5544 | @@ -38,6 +69,11 @@
|
---|
5545 | _refCount = 0;
|
---|
5546 | }
|
---|
5547 |
|
---|
5548 | +FilesystemNode::FilesystemNode(AbstractFilesystemNode *realNode) {
|
---|
5549 | + _realNode = realNode;
|
---|
5550 | + _refCount = new int(1);
|
---|
5551 | +}
|
---|
5552 | +
|
---|
5553 | FilesystemNode::FilesystemNode(const FilesystemNode &node) {
|
---|
5554 | _realNode = node._realNode;
|
---|
5555 | _refCount = node._refCount;
|
---|
5556 | @@ -46,10 +82,12 @@
|
---|
5557 | }
|
---|
5558 |
|
---|
5559 | FilesystemNode::FilesystemNode(const Common::String &p) {
|
---|
5560 | + AbstractFilesystemFactory *factory = makeFSFactory();
|
---|
5561 | +
|
---|
5562 | if (p.empty() || p == ".")
|
---|
5563 | - _realNode = AbstractFilesystemNode::getCurrentDirectory();
|
---|
5564 | + _realNode = factory->makeCurrentDirectoryFileNode();
|
---|
5565 | else
|
---|
5566 | - _realNode = AbstractFilesystemNode::getNodeForPath(p);
|
---|
5567 | + _realNode = factory->makeFileNodePath(p);
|
---|
5568 | _refCount = new int(1);
|
---|
5569 | }
|
---|
5570 |
|
---|
5571 | @@ -57,18 +95,7 @@
|
---|
5572 | decRefCount();
|
---|
5573 | }
|
---|
5574 |
|
---|
5575 | -void FilesystemNode::decRefCount() {
|
---|
5576 | - if (_refCount) {
|
---|
5577 | - assert(*_refCount > 0);
|
---|
5578 | - --(*_refCount);
|
---|
5579 | - if (*_refCount == 0) {
|
---|
5580 | - delete _refCount;
|
---|
5581 | - delete _realNode;
|
---|
5582 | - }
|
---|
5583 | - }
|
---|
5584 | -}
|
---|
5585 | -
|
---|
5586 | -FilesystemNode &FilesystemNode::operator =(const FilesystemNode &node) {
|
---|
5587 | +FilesystemNode &FilesystemNode::operator= (const FilesystemNode &node) {
|
---|
5588 | if (node._refCount)
|
---|
5589 | ++(*node._refCount);
|
---|
5590 |
|
---|
5591 | @@ -80,24 +107,34 @@
|
---|
5592 | return *this;
|
---|
5593 | }
|
---|
5594 |
|
---|
5595 | -bool FilesystemNode::isValid() const {
|
---|
5596 | - if (_realNode == 0)
|
---|
5597 | +bool FilesystemNode::operator<(const FilesystemNode& node) const
|
---|
5598 | +{
|
---|
5599 | + if (isDirectory() && !node.isDirectory())
|
---|
5600 | + return true;
|
---|
5601 | + if (!isDirectory() && node.isDirectory())
|
---|
5602 | return false;
|
---|
5603 | - return _realNode->isValid();
|
---|
5604 | +
|
---|
5605 | + return scumm_stricmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0;
|
---|
5606 | }
|
---|
5607 |
|
---|
5608 | -FilesystemNode FilesystemNode::getParent() const {
|
---|
5609 | - if (_realNode == 0)
|
---|
5610 | - return *this;
|
---|
5611 | -
|
---|
5612 | - AbstractFilesystemNode *node = _realNode->parent();
|
---|
5613 | - if (node == 0) {
|
---|
5614 | - return *this;
|
---|
5615 | - } else {
|
---|
5616 | - return FilesystemNode(node);
|
---|
5617 | +void FilesystemNode::decRefCount() {
|
---|
5618 | + if (_refCount) {
|
---|
5619 | + assert(*_refCount > 0);
|
---|
5620 | + --(*_refCount);
|
---|
5621 | + if (*_refCount == 0) {
|
---|
5622 | + delete _refCount;
|
---|
5623 | + delete _realNode;
|
---|
5624 | + }
|
---|
5625 | }
|
---|
5626 | }
|
---|
5627 |
|
---|
5628 | +bool FilesystemNode::exists() const {
|
---|
5629 | + if (_realNode == 0)
|
---|
5630 | + return false;
|
---|
5631 | +
|
---|
5632 | + return _realNode->exists();
|
---|
5633 | +}
|
---|
5634 | +
|
---|
5635 | FilesystemNode FilesystemNode::getChild(const Common::String &n) const {
|
---|
5636 | if (_realNode == 0)
|
---|
5637 | return *this;
|
---|
5638 | @@ -103,11 +140,11 @@
|
---|
5639 | return *this;
|
---|
5640 |
|
---|
5641 | assert(_realNode->isDirectory());
|
---|
5642 | - AbstractFilesystemNode *node = _realNode->child(n);
|
---|
5643 | + AbstractFilesystemNode *node = _realNode->getChild(n);
|
---|
5644 | return FilesystemNode(node);
|
---|
5645 | }
|
---|
5646 |
|
---|
5647 | -bool FilesystemNode::listDir(FSList &fslist, ListMode mode) const {
|
---|
5648 | +bool FilesystemNode::getChildren(FSList &fslist, ListMode mode, bool hidden) const {
|
---|
5649 | if (!_realNode || !_realNode->isDirectory())
|
---|
5650 | return false;
|
---|
5651 |
|
---|
5652 | @@ -113,7 +150,7 @@
|
---|
5653 |
|
---|
5654 | AbstractFSList tmp;
|
---|
5655 |
|
---|
5656 | - if (!_realNode->listDir(tmp, mode))
|
---|
5657 | + if (!_realNode->getChildren(tmp, mode, hidden))
|
---|
5658 | return false;
|
---|
5659 |
|
---|
5660 | fslist.clear();
|
---|
5661 | @@ -124,33 +161,108 @@
|
---|
5662 | return true;
|
---|
5663 | }
|
---|
5664 |
|
---|
5665 | +Common::String FilesystemNode::getDisplayName() const {
|
---|
5666 | + assert(_realNode);
|
---|
5667 | + return _realNode->getDisplayName();
|
---|
5668 | +}
|
---|
5669 | +
|
---|
5670 | +Common::String FilesystemNode::getName() const {
|
---|
5671 | + assert(_realNode);
|
---|
5672 | + return _realNode->getName();
|
---|
5673 | +}
|
---|
5674 | +
|
---|
5675 | +FilesystemNode FilesystemNode::getParent() const {
|
---|
5676 | + if (_realNode == 0)
|
---|
5677 | + return *this;
|
---|
5678 | +
|
---|
5679 | + AbstractFilesystemNode *node = _realNode->getParent();
|
---|
5680 | + if (node == 0) {
|
---|
5681 | + return *this;
|
---|
5682 | + } else {
|
---|
5683 | + return FilesystemNode(node);
|
---|
5684 | + }
|
---|
5685 | +}
|
---|
5686 | +
|
---|
5687 | +Common::String FilesystemNode::getPath() const {
|
---|
5688 | + assert(_realNode);
|
---|
5689 | + return _realNode->getPath();
|
---|
5690 | +}
|
---|
5691 | +
|
---|
5692 | bool FilesystemNode::isDirectory() const {
|
---|
5693 | if (_realNode == 0)
|
---|
5694 | return false;
|
---|
5695 | +
|
---|
5696 | return _realNode->isDirectory();
|
---|
5697 | }
|
---|
5698 |
|
---|
5699 | -Common::String FilesystemNode::displayName() const {
|
---|
5700 | - assert(_realNode);
|
---|
5701 | - return _realNode->displayName();
|
---|
5702 | +bool FilesystemNode::isReadable() const {
|
---|
5703 | + if (_realNode == 0)
|
---|
5704 | + return false;
|
---|
5705 | +
|
---|
5706 | + return _realNode->isReadable();
|
---|
5707 | }
|
---|
5708 |
|
---|
5709 | -Common::String FilesystemNode::name() const {
|
---|
5710 | - assert(_realNode);
|
---|
5711 | - return _realNode->name();
|
---|
5712 | +bool FilesystemNode::isWritable() const {
|
---|
5713 | + if (_realNode == 0)
|
---|
5714 | + return false;
|
---|
5715 | +
|
---|
5716 | + return _realNode->isWritable();
|
---|
5717 | }
|
---|
5718 |
|
---|
5719 | -Common::String FilesystemNode::path() const {
|
---|
5720 | - assert(_realNode);
|
---|
5721 | - return _realNode->path();
|
---|
5722 | +bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const
|
---|
5723 | +{
|
---|
5724 | + int matches = 0;
|
---|
5725 | +
|
---|
5726 | + for (FSList::iterator entry = fslist.begin(); entry != fslist.end(); ++entry) {
|
---|
5727 | + if (entry->isDirectory()) {
|
---|
5728 | + matches += lookupFileRec(results, *entry, filename, hidden, exhaustive);
|
---|
5729 | + }
|
---|
5730 | + }
|
---|
5731 | +
|
---|
5732 | + return ((matches > 0) ? true : false);
|
---|
5733 | }
|
---|
5734 |
|
---|
5735 | -
|
---|
5736 | -bool FilesystemNode::operator< (const FilesystemNode& node) const
|
---|
5737 | +bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
|
---|
5738 | {
|
---|
5739 | - if (isDirectory() && !node.isDirectory())
|
---|
5740 | - return true;
|
---|
5741 | - if (!isDirectory() && node.isDirectory())
|
---|
5742 | + int matches;
|
---|
5743 | +
|
---|
5744 | + if (!dir.isDirectory())
|
---|
5745 | return false;
|
---|
5746 | - return scumm_stricmp(displayName().c_str(), node.displayName().c_str()) < 0;
|
---|
5747 | +
|
---|
5748 | + matches = lookupFileRec(results, dir, filename, hidden, exhaustive);
|
---|
5749 | +
|
---|
5750 | + return ((matches > 0) ? true : false);
|
---|
5751 | +}
|
---|
5752 | +
|
---|
5753 | +int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
|
---|
5754 | +{
|
---|
5755 | + FSList entries;
|
---|
5756 | + FSList children;
|
---|
5757 | + int matches = 0;
|
---|
5758 | + dir.getChildren(entries, FilesystemNode::kListAll, hidden);
|
---|
5759 | +
|
---|
5760 | + //Breadth search (entries in the same level)
|
---|
5761 | + for (FSList::iterator entry = entries.begin(); entry != entries.end(); ++entry) {
|
---|
5762 | + if (entry->isDirectory()) {
|
---|
5763 | + children.push_back(*entry);
|
---|
5764 | + } else {
|
---|
5765 | + //TODO: here we assume all backends implement the lastPathComponent method. It is currently static,
|
---|
5766 | + // so it might be a good idea to include it inside the backend class. This would enforce its
|
---|
5767 | + // implementation by all ports.
|
---|
5768 | + if (matchString(lastPathComponent(entry->getPath()), filename.c_str())) {
|
---|
5769 | + results.push_back(*entry);
|
---|
5770 | + matches++;
|
---|
5771 | +
|
---|
5772 | + if (!exhaustive)
|
---|
5773 | + break;
|
---|
5774 | + }
|
---|
5775 | + }
|
---|
5776 | + }
|
---|
5777 | +
|
---|
5778 | + //Depth search (entries in lower levels)
|
---|
5779 | + for (FSList::iterator child = children.begin(); child != children.end(); ++child) {
|
---|
5780 | + matches += lookupFileRec(results, *child, filename, hidden, exhaustive);
|
---|
5781 | + }
|
---|
5782 | +
|
---|
5783 | + return matches;
|
---|
5784 | }
|
---|
5785 | Index: /home/david/Projects/scummvm/common/fs.h
|
---|
5786 | ===================================================================
|
---|
5787 | --- /home/david/Projects/scummvm/common/fs.h (revision 28941)
|
---|
5788 | +++ /home/david/Projects/scummvm/common/fs.h (working copy)
|
---|
5789 | @@ -33,7 +33,6 @@
|
---|
5790 | class FilesystemNode;
|
---|
5791 | class AbstractFilesystemNode;
|
---|
5792 |
|
---|
5793 | -
|
---|
5794 | /**
|
---|
5795 | * List of multiple file system nodes. E.g. the contents of a given directory.
|
---|
5796 | * This is subclass instead of just a typedef so that we can use forward
|
---|
5797 | @@ -41,9 +40,8 @@
|
---|
5798 | */
|
---|
5799 | class FSList : public Common::Array<FilesystemNode> {};
|
---|
5800 |
|
---|
5801 | -
|
---|
5802 | /**
|
---|
5803 | - * FilesystemNode provides an abstraction for file pathes, allowing for portable
|
---|
5804 | + * FilesystemNode provides an abstraction for file paths, allowing for portable
|
---|
5805 | * file system browsing. To this ends, multiple or single roots have to be supported
|
---|
5806 | * (compare Unix with a single root, Windows with multiple roots C:, D:, ...).
|
---|
5807 | *
|
---|
5808 | @@ -64,12 +62,13 @@
|
---|
5809 | * paths (MacOS 9 doesn't even have the notion of a "current directory").
|
---|
5810 | * And if we ever want to support devices with no FS in the classical sense (Palm...),
|
---|
5811 | * we can build upon this.
|
---|
5812 | + *
|
---|
5813 | + * This class acts as a wrapper around the AbstractFilesystemNode class defined in backends/fs.
|
---|
5814 | */
|
---|
5815 | class FilesystemNode {
|
---|
5816 | private:
|
---|
5817 | + int *_refCount;
|
---|
5818 | AbstractFilesystemNode *_realNode;
|
---|
5819 | - int *_refCount;
|
---|
5820 | -
|
---|
5821 | FilesystemNode(AbstractFilesystemNode *realNode);
|
---|
5822 |
|
---|
5823 | public:
|
---|
5824 | @@ -83,9 +82,9 @@
|
---|
5825 | };
|
---|
5826 |
|
---|
5827 | /**
|
---|
5828 | - * Create a new invalid FilesystemNode. In other words, isValid() for that
|
---|
5829 | - * node returns false, and if you try to get it's path, an assert is
|
---|
5830 | - * triggered.
|
---|
5831 | + * Create a new pathless FilesystemNode. Since there's no path associated
|
---|
5832 | + * with this node, path-related operations (i.e. exists(), isDirectory(),
|
---|
5833 | + * getPath()) will always return false or raise an assertion.
|
---|
5834 | */
|
---|
5835 | FilesystemNode();
|
---|
5836 |
|
---|
5837 | @@ -113,43 +112,35 @@
|
---|
5838 | /**
|
---|
5839 | * Copy operator.
|
---|
5840 | */
|
---|
5841 | - FilesystemNode &operator =(const FilesystemNode &node);
|
---|
5842 | -
|
---|
5843 | + FilesystemNode &operator= (const FilesystemNode &node);
|
---|
5844 | +
|
---|
5845 | /**
|
---|
5846 | - * Checks if the FilesystemNode is valid for any usage
|
---|
5847 | + * Compare the name of this node to the name of another. Directories
|
---|
5848 | + * go before normal files.
|
---|
5849 | */
|
---|
5850 | - bool isValid() const;
|
---|
5851 | + bool operator<(const FilesystemNode& node) const;
|
---|
5852 |
|
---|
5853 | /**
|
---|
5854 | - * Get the parent node of this node. If this node has no parent node,
|
---|
5855 | - * then it returns a duplicate of this node.
|
---|
5856 | + * Indicates whether the object referred by this path exists in the filesystem or not.
|
---|
5857 | + *
|
---|
5858 | + * @return bool true if the path exists, false otherwise.
|
---|
5859 | */
|
---|
5860 | - FilesystemNode getParent() const;
|
---|
5861 | + virtual bool exists() const;
|
---|
5862 |
|
---|
5863 | /**
|
---|
5864 | * Fetch a child node of this node, with the given name. Only valid for
|
---|
5865 | - * directory nodes (an assertion is triggered otherwise). If no no child
|
---|
5866 | - * node with the given name exists, an invalid node is returned.
|
---|
5867 | + * directory nodes (an assertion is triggered otherwise).
|
---|
5868 | + * If no child node with the given name exists, an invalid node is returned.
|
---|
5869 | */
|
---|
5870 | FilesystemNode getChild(const Common::String &name) const;
|
---|
5871 | -
|
---|
5872 | +
|
---|
5873 | /**
|
---|
5874 | * Return a list of child nodes of this directory node. If called on a node
|
---|
5875 | * that does not represent a directory, false is returned.
|
---|
5876 | + *
|
---|
5877 | * @return true if succesful, false otherwise (e.g. when the directory does not exist).
|
---|
5878 | - * @todo Rename this to listChildren or getChildren.
|
---|
5879 | */
|
---|
5880 | - virtual bool listDir(FSList &fslist, ListMode mode = kListDirectoriesOnly) const;
|
---|
5881 | -
|
---|
5882 | - /**
|
---|
5883 | - * Is this node pointing to a directory?
|
---|
5884 | - * @todo Currently we assume that a valid node that is not a directory
|
---|
5885 | - * automatically is a file (ignoring things like symlinks). That might
|
---|
5886 | - * actually be OK... but we could still add an isFile method. Or even replace
|
---|
5887 | - * isValid and isDirectory by a getType() method that can return values like
|
---|
5888 | - * kDirNodeType, kFileNodeType, kInvalidNodeType.
|
---|
5889 | - */
|
---|
5890 | - virtual bool isDirectory() const;
|
---|
5891 | + virtual bool getChildren(FSList &fslist, ListMode mode = kListDirectoriesOnly, bool hidden = false) const;
|
---|
5892 |
|
---|
5893 | /**
|
---|
5894 | * Return a human readable string for this node, usable for display (e.g.
|
---|
5895 | @@ -155,9 +146,10 @@
|
---|
5896 | * Return a human readable string for this node, usable for display (e.g.
|
---|
5897 | * in the GUI code). Do *not* rely on it being usable for anything else,
|
---|
5898 | * like constructing paths!
|
---|
5899 | + *
|
---|
5900 | * @return the display name
|
---|
5901 | */
|
---|
5902 | - virtual Common::String displayName() const;
|
---|
5903 | + virtual Common::String getDisplayName() const;
|
---|
5904 |
|
---|
5905 | /**
|
---|
5906 | * Return a string representation of the name of the file. This is can be
|
---|
5907 | @@ -167,7 +159,7 @@
|
---|
5908 | *
|
---|
5909 | * @return the file name
|
---|
5910 | */
|
---|
5911 | - virtual Common::String name() const;
|
---|
5912 | + virtual Common::String getName() const;
|
---|
5913 |
|
---|
5914 | /**
|
---|
5915 | * Return a string representation of the file which can be passed to fopen(),
|
---|
5916 | @@ -180,16 +172,105 @@
|
---|
5917 | *
|
---|
5918 | * @return the 'path' represented by this filesystem node
|
---|
5919 | */
|
---|
5920 | - virtual Common::String path() const;
|
---|
5921 | + virtual Common::String getPath() const;
|
---|
5922 | +
|
---|
5923 | + /**
|
---|
5924 | + * Get the parent node of this node. If this node has no parent node,
|
---|
5925 | + * then it returns a duplicate of this node.
|
---|
5926 | + */
|
---|
5927 | + FilesystemNode getParent() const;
|
---|
5928 |
|
---|
5929 | /**
|
---|
5930 | - * Compare the name of this node to the name of another. Directories
|
---|
5931 | - * go before normal files.
|
---|
5932 | + * Indicates whether the path refers to a directory or not.
|
---|
5933 | + *
|
---|
5934 | + * @todo Currently we assume that a node that is not a directory
|
---|
5935 | + * automatically is a file (ignoring things like symlinks or pipes).
|
---|
5936 | + * That might actually be OK... but we could still add an isFile method.
|
---|
5937 | + * Or even replace isDirectory by a getType() method that can return values like
|
---|
5938 | + * kDirNodeType, kFileNodeType, kInvalidNodeType.
|
---|
5939 | + */
|
---|
5940 | + virtual bool isDirectory() const;
|
---|
5941 | +
|
---|
5942 | + /**
|
---|
5943 | + * Indicates whether the object referred by this path can be read from or not.
|
---|
5944 | + *
|
---|
5945 | + * If the path refers to a directory, readability implies being able to read
|
---|
5946 | + * and list the directory entries.
|
---|
5947 | + *
|
---|
5948 | + * If the path refers to a file, readability implies being able to read the
|
---|
5949 | + * contents of the file.
|
---|
5950 | + *
|
---|
5951 | + * @return bool true if the object can be read, false otherwise.
|
---|
5952 | + */
|
---|
5953 | + virtual bool isReadable() const;
|
---|
5954 | +
|
---|
5955 | + /**
|
---|
5956 | + * Indicates whether the object referred by this path can be written to or not.
|
---|
5957 | + *
|
---|
5958 | + * If the path refers to a directory, writability implies being able to modify
|
---|
5959 | + * the directory entry (i.e. rename the directory, remove it or write files inside of it).
|
---|
5960 | + *
|
---|
5961 | + * If the path refers to a file, writability implies being able to write data
|
---|
5962 | + * to the file.
|
---|
5963 | + *
|
---|
5964 | + * @return bool true if the object can be written to, false otherwise.
|
---|
5965 | + */
|
---|
5966 | + virtual bool isWritable() const;
|
---|
5967 | +
|
---|
5968 | + /**
|
---|
5969 | + * Searches recursively for a filename inside the given directories.
|
---|
5970 | + *
|
---|
5971 | + * For each directory in the directory list a breadth-first search is performed,
|
---|
5972 | + * that is, the current directory entries are scanned before going into subdirectories.
|
---|
5973 | + *
|
---|
5974 | + * @param results List to put the matches in.
|
---|
5975 | + * @param fslist List of directories to search within.
|
---|
5976 | + * @param filename Name of the file to look for.
|
---|
5977 | + * @param hidden Whether to search hidden files or not.
|
---|
5978 | + * @param exhaustive Whether to continue searching after one match has been found.
|
---|
5979 | + *
|
---|
5980 | + * @return true if matches could be found, false otherwise.
|
---|
5981 | */
|
---|
5982 | - bool operator< (const FilesystemNode& node) const;
|
---|
5983 | + virtual bool lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const;
|
---|
5984 | +
|
---|
5985 | + /**
|
---|
5986 | + * Searches recursively for a filename inside the given directory.
|
---|
5987 | + *
|
---|
5988 | + * The search is performed breadth-first, that is, the current directory entries
|
---|
5989 | + * are scanned before going into subdirectories.
|
---|
5990 | + *
|
---|
5991 | + * @param results List to put the matches in.
|
---|
5992 | + * @param FilesystemNode Directory to search within.
|
---|
5993 | + * @param filename Name of the file to look for.
|
---|
5994 | + * @param hidden Whether to search hidden files or not.
|
---|
5995 | + * @param exhaustive Whether to continue searching after one match has been found.
|
---|
5996 | + *
|
---|
5997 | + * @return true if matches could be found, false otherwise.
|
---|
5998 | + */
|
---|
5999 | + virtual bool lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const;
|
---|
6000 |
|
---|
6001 | protected:
|
---|
6002 | + /**
|
---|
6003 | + * Decreases the reference count to the FilesystemNode, and if necessary,
|
---|
6004 | + * deletes the corresponding underlying references.
|
---|
6005 | + */
|
---|
6006 | void decRefCount();
|
---|
6007 | +
|
---|
6008 | + /**
|
---|
6009 | + * Searches recursively for a filename inside the given directory.
|
---|
6010 | + *
|
---|
6011 | + * The search is performed breadth-first, that is, the current directory entries
|
---|
6012 | + * are scanned before going into subdirectories.
|
---|
6013 | + *
|
---|
6014 | + * @param results List to put the matches in.
|
---|
6015 | + * @param FilesystemNode Directory to search within.
|
---|
6016 | + * @param filename Name of the file to look for.
|
---|
6017 | + * @param hidden Whether to search hidden files or not.
|
---|
6018 | + * @param exhaustive Whether to continue searching after one match has been found.
|
---|
6019 | + *
|
---|
6020 | + * @return The number of matches found.
|
---|
6021 | + */
|
---|
6022 | + int lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const;
|
---|
6023 | };
|
---|
6024 |
|
---|
6025 | //} // End of namespace Common
|
---|
6026 | @@ -194,4 +275,4 @@
|
---|
6027 |
|
---|
6028 | //} // End of namespace Common
|
---|
6029 |
|
---|
6030 | -#endif
|
---|
6031 | +#endif //COMMON_FS_H
|
---|
6032 | Index: /home/david/Projects/scummvm/common/md5.cpp
|
---|
6033 | ===================================================================
|
---|
6034 | --- /home/david/Projects/scummvm/common/md5.cpp (revision 28941)
|
---|
6035 | +++ /home/david/Projects/scummvm/common/md5.cpp (working copy)
|
---|
6036 | @@ -246,15 +246,18 @@
|
---|
6037 | }
|
---|
6038 |
|
---|
6039 | bool md5_file(const FilesystemNode &file, uint8 digest[16], uint32 length) {
|
---|
6040 | - if (!file.isValid()) {
|
---|
6041 | - warning("md5_file: using an invalid FilesystemNode");
|
---|
6042 | + if(!file.exists()) {
|
---|
6043 | + warning("md5_file: using an inexistent FilesystemNode");
|
---|
6044 | + return false;
|
---|
6045 | + } else if (!file.isReadable()) {
|
---|
6046 | + warning("md5_file: using an unreadable FilesystemNode");
|
---|
6047 | return false;
|
---|
6048 | } else if (file.isDirectory()) {
|
---|
6049 | - warning("md5_file: using a diretory FilesystemNode");
|
---|
6050 | + warning("md5_file: using a directory FilesystemNode");
|
---|
6051 | return false;
|
---|
6052 | }
|
---|
6053 |
|
---|
6054 | - return md5_file(file.path().c_str(), digest, length);
|
---|
6055 | + return md5_file(file.getPath().c_str(), digest, length);
|
---|
6056 | }
|
---|
6057 |
|
---|
6058 | bool md5_file(const char *name, uint8 digest[16], uint32 length) {
|
---|
6059 | Index: /home/david/Projects/scummvm/common/savefile.h
|
---|
6060 | ===================================================================
|
---|
6061 | --- /home/david/Projects/scummvm/common/savefile.h (revision 28941)
|
---|
6062 | +++ /home/david/Projects/scummvm/common/savefile.h (working copy)
|
---|
6063 | @@ -30,6 +30,8 @@
|
---|
6064 | #include "common/noncopyable.h"
|
---|
6065 | #include "common/scummsys.h"
|
---|
6066 | #include "common/stream.h"
|
---|
6067 | +#include "common/str.h"
|
---|
6068 | +#include "common/error.h"
|
---|
6069 |
|
---|
6070 | namespace Common {
|
---|
6071 |
|
---|
6072 | @@ -75,10 +77,40 @@
|
---|
6073 | * returning the single SaveFileManager instances to be used.
|
---|
6074 | */
|
---|
6075 | class SaveFileManager : NonCopyable {
|
---|
6076 | -
|
---|
6077 | +
|
---|
6078 | +protected:
|
---|
6079 | + SFMError _error;
|
---|
6080 | + String _errorDesc;
|
---|
6081 | +
|
---|
6082 | public:
|
---|
6083 | virtual ~SaveFileManager() {}
|
---|
6084 | -
|
---|
6085 | +
|
---|
6086 | + /**
|
---|
6087 | + * Clears the last set error code and string.
|
---|
6088 | + */
|
---|
6089 | + virtual void clearError() { _error = SFM_NO_ERROR; _errorDesc = ""; }
|
---|
6090 | +
|
---|
6091 | + /**
|
---|
6092 | + * Returns the last ocurred error code. If none ocurred, returns SFM_NO_ERROR.
|
---|
6093 | + *
|
---|
6094 | + * @return A SFMError indicating the type of the last error.
|
---|
6095 | + */
|
---|
6096 | + virtual SFMError getError() { return _error; }
|
---|
6097 | +
|
---|
6098 | + /**
|
---|
6099 | + * Returns the last ocurred error description. If none ocurred, returns 0.
|
---|
6100 | + *
|
---|
6101 | + * @return A string describing the last error.
|
---|
6102 | + */
|
---|
6103 | + virtual String getErrorDesc() { return _errorDesc; }
|
---|
6104 | +
|
---|
6105 | + /**
|
---|
6106 | + * Sets the last ocurred error.
|
---|
6107 | + * @param error Code identifying the last error.
|
---|
6108 | + * @param errorDesc String describing the last error.
|
---|
6109 | + */
|
---|
6110 | + virtual void setError(SFMError error, String errorDesc) { _error = error; _errorDesc = errorDesc; }
|
---|
6111 | +
|
---|
6112 | /**
|
---|
6113 | * Open the file with name filename in the given directory for saving.
|
---|
6114 | * @param filename the filename
|
---|
6115 | @@ -94,12 +126,18 @@
|
---|
6116 | virtual InSaveFile *openForLoading(const char *filename) = 0;
|
---|
6117 |
|
---|
6118 | /**
|
---|
6119 | - * Request a list of available savegames with a given prefix.
|
---|
6120 | - * TODO: Document this better!
|
---|
6121 | - * TODO: Or even replace it with a better API. For example, one that
|
---|
6122 | - * returns a list of strings for all present file names.
|
---|
6123 | + * Removes the given savefile from the filesystem.
|
---|
6124 | + * @param filename Filename path pointing to the savefile.
|
---|
6125 | + * @return true if no error ocurred. false otherwise.
|
---|
6126 | */
|
---|
6127 | - virtual void listSavefiles(const char * /* prefix */, bool *marks, int num) = 0;
|
---|
6128 | + virtual bool removeSavefile(const char *filename) = 0;
|
---|
6129 | +
|
---|
6130 | + /**
|
---|
6131 | + * Request a list of available savegames with a given regex.
|
---|
6132 | + * @param regex Regular expression to match. Wildcards like * or ? are available.
|
---|
6133 | + * returns a list of strings for all present file names.
|
---|
6134 | + */
|
---|
6135 | + virtual Common::StringList listSavefiles(const char *regex) = 0;
|
---|
6136 |
|
---|
6137 | /**
|
---|
6138 | * Get the path to the save game directory.
|
---|
6139 | Index: /home/david/Projects/scummvm/engines/agi/agi_v3.cpp
|
---|
6140 | ===================================================================
|
---|
6141 | --- /home/david/Projects/scummvm/engines/agi/agi_v3.cpp (revision 0)
|
---|
6142 | +++ /home/david/Projects/scummvm/engines/agi/agi_v3.cpp (revision 0)
|
---|
6143 | @@ -0,0 +1,390 @@
|
---|
6144 | +/* ScummVM - Graphic Adventure Engine
|
---|
6145 | + *
|
---|
6146 | + * ScummVM is the legal property of its developers, whose names
|
---|
6147 | + * are too numerous to list here. Please refer to the COPYRIGHT
|
---|
6148 | + * file distributed with this source distribution.
|
---|
6149 | + *
|
---|
6150 | + * This program is free software; you can redistribute it and/or
|
---|
6151 | + * modify it under the terms of the GNU General Public License
|
---|
6152 | + * as published by the Free Software Foundation; either version 2
|
---|
6153 | + * of the License, or (at your option) any later version.
|
---|
6154 | +
|
---|
6155 | + * This program is distributed in the hope that it will be useful,
|
---|
6156 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
6157 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
6158 | + * GNU General Public License for more details.
|
---|
6159 | +
|
---|
6160 | + * You should have received a copy of the GNU General Public License
|
---|
6161 | + * along with this program; if not, write to the Free Software
|
---|
6162 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
6163 | + *
|
---|
6164 | + * $URL$
|
---|
6165 | + * $Id$
|
---|
6166 | + *
|
---|
6167 | + */
|
---|
6168 | +
|
---|
6169 | +#include "common/stdafx.h"
|
---|
6170 | +
|
---|
6171 | +#include "agi/agi.h"
|
---|
6172 | +#include "agi/lzw.h"
|
---|
6173 | +
|
---|
6174 | +#include "common/config-manager.h"
|
---|
6175 | +#include "common/fs.h"
|
---|
6176 | +
|
---|
6177 | +namespace Agi {
|
---|
6178 | +
|
---|
6179 | +int AgiLoader_v3::version() {
|
---|
6180 | + return 3;
|
---|
6181 | +}
|
---|
6182 | +
|
---|
6183 | +void AgiLoader_v3::setIntVersion(int ver) {
|
---|
6184 | + _intVersion = ver;
|
---|
6185 | +}
|
---|
6186 | +
|
---|
6187 | +int AgiLoader_v3::getIntVersion() {
|
---|
6188 | + return _intVersion;
|
---|
6189 | +}
|
---|
6190 | +
|
---|
6191 | +int AgiLoader_v3::detectGame() {
|
---|
6192 | + int ec = errUnk;
|
---|
6193 | + bool found = false;
|
---|
6194 | +
|
---|
6195 | + FSList fslist;
|
---|
6196 | + FilesystemNode dir(ConfMan.get("path"));
|
---|
6197 | +
|
---|
6198 | + if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6199 | + warning("AgiEngine: invalid game path '%s'", dir.getPath().c_str());
|
---|
6200 | + return errInvalidAGIFile;
|
---|
6201 | + }
|
---|
6202 | +
|
---|
6203 | + for (FSList::const_iterator file = fslist.begin();
|
---|
6204 | + file != fslist.end() && !found; ++file) {
|
---|
6205 | + Common::String f = file->getName();
|
---|
6206 | + f.toLowercase();
|
---|
6207 | +
|
---|
6208 | + if (f.hasSuffix("vol.0")) {
|
---|
6209 | + memset(_vm->_game.name, 0, 8);
|
---|
6210 | + strncpy(_vm->_game.name, f.c_str(), MIN((uint)8, f.size() > 5 ? f.size() - 5 : f.size()));
|
---|
6211 | + debugC(3, kDebugLevelMain, "game.name = %s", _vm->_game.name);
|
---|
6212 | + _intVersion = 0x3149; // setup for 3.002.149
|
---|
6213 | + ec = _vm->v3IdGame();
|
---|
6214 | +
|
---|
6215 | + found = true;
|
---|
6216 | + }
|
---|
6217 | + }
|
---|
6218 | +
|
---|
6219 | + if (!found) {
|
---|
6220 | + debugC(3, kDebugLevelMain, "not found");
|
---|
6221 | + ec = errInvalidAGIFile;
|
---|
6222 | + }
|
---|
6223 | +
|
---|
6224 | + return ec;
|
---|
6225 | +}
|
---|
6226 | +
|
---|
6227 | +int AgiLoader_v3::loadDir(struct AgiDir *agid, Common::File *fp,
|
---|
6228 | + uint32 offs, uint32 len) {
|
---|
6229 | + int ec = errOK;
|
---|
6230 | + uint8 *mem;
|
---|
6231 | + unsigned int i;
|
---|
6232 | +
|
---|
6233 | + fp->seek(offs, SEEK_SET);
|
---|
6234 | + if ((mem = (uint8 *)malloc(len + 32)) != NULL) {
|
---|
6235 | + fp->read(mem, len);
|
---|
6236 | +
|
---|
6237 | + /* set all directory resources to gone */
|
---|
6238 | + for (i = 0; i < MAX_DIRS; i++) {
|
---|
6239 | + agid[i].volume = 0xff;
|
---|
6240 | + agid[i].offset = _EMPTY;
|
---|
6241 | + }
|
---|
6242 | +
|
---|
6243 | + /* build directory entries */
|
---|
6244 | + for (i = 0; i < len; i += 3) {
|
---|
6245 | + agid[i / 3].volume = *(mem + i) >> 4;
|
---|
6246 | + agid[i / 3].offset = READ_BE_UINT24(mem + i) & (uint32) _EMPTY;
|
---|
6247 | + }
|
---|
6248 | +
|
---|
6249 | + free(mem);
|
---|
6250 | + } else {
|
---|
6251 | + ec = errNotEnoughMemory;
|
---|
6252 | + }
|
---|
6253 | +
|
---|
6254 | + return ec;
|
---|
6255 | +}
|
---|
6256 | +
|
---|
6257 | +struct agi3vol {
|
---|
6258 | + uint32 sddr;
|
---|
6259 | + uint32 len;
|
---|
6260 | +};
|
---|
6261 | +
|
---|
6262 | +int AgiLoader_v3::init() {
|
---|
6263 | + int ec = errOK;
|
---|
6264 | + struct agi3vol agiVol3[4];
|
---|
6265 | + int i;
|
---|
6266 | + uint16 xd[4];
|
---|
6267 | + Common::File fp;
|
---|
6268 | + Common::String path;
|
---|
6269 | +
|
---|
6270 | + if (_vm->getPlatform() == Common::kPlatformAmiga) {
|
---|
6271 | + path = Common::String("dirs");
|
---|
6272 | + _vm->_game.name[0] = 0; // Empty prefix
|
---|
6273 | + } else if (_vm->getFeatures() & GF_MACGOLDRUSH) {
|
---|
6274 | + path = "grdir";
|
---|
6275 | + _vm->_game.name[0] = 0; // Empty prefix
|
---|
6276 | + } else {
|
---|
6277 | + path = Common::String(_vm->_game.name) + DIR_;
|
---|
6278 | + }
|
---|
6279 | +
|
---|
6280 | + if (!fp.open(path)) {
|
---|
6281 | + printf("Failed to open \"%s\"\n", path.c_str());
|
---|
6282 | + return errBadFileOpen;
|
---|
6283 | + }
|
---|
6284 | + /* build offset table for v3 directory format */
|
---|
6285 | + fp.read(&xd, 8);
|
---|
6286 | + fp.seek(0, SEEK_END);
|
---|
6287 | +
|
---|
6288 | + for (i = 0; i < 4; i++)
|
---|
6289 | + agiVol3[i].sddr = READ_LE_UINT16((uint8 *) & xd[i]);
|
---|
6290 | +
|
---|
6291 | + agiVol3[0].len = agiVol3[1].sddr - agiVol3[0].sddr;
|
---|
6292 | + agiVol3[1].len = agiVol3[2].sddr - agiVol3[1].sddr;
|
---|
6293 | + agiVol3[2].len = agiVol3[3].sddr - agiVol3[2].sddr;
|
---|
6294 | + agiVol3[3].len = fp.pos() - agiVol3[3].sddr;
|
---|
6295 | +
|
---|
6296 | + if (agiVol3[3].len > 256 * 3)
|
---|
6297 | + agiVol3[3].len = 256 * 3;
|
---|
6298 | +
|
---|
6299 | + fp.seek(0, SEEK_SET);
|
---|
6300 | +
|
---|
6301 | + /* read in directory files */
|
---|
6302 | + ec = loadDir(_vm->_game.dirLogic, &fp, agiVol3[0].sddr, agiVol3[0].len);
|
---|
6303 | +
|
---|
6304 | + if (ec == errOK) {
|
---|
6305 | + ec = loadDir(_vm->_game.dirPic, &fp, agiVol3[1].sddr, agiVol3[1].len);
|
---|
6306 | + }
|
---|
6307 | +
|
---|
6308 | + if (ec == errOK) {
|
---|
6309 | + ec = loadDir(_vm->_game.dirView, &fp, agiVol3[2].sddr, agiVol3[2].len);
|
---|
6310 | + }
|
---|
6311 | +
|
---|
6312 | + if (ec == errOK) {
|
---|
6313 | + ec = loadDir(_vm->_game.dirSound, &fp, agiVol3[3].sddr, agiVol3[3].len);
|
---|
6314 | + }
|
---|
6315 | +
|
---|
6316 | + return ec;
|
---|
6317 | +}
|
---|
6318 | +
|
---|
6319 | +int AgiLoader_v3::deinit() {
|
---|
6320 | + int ec = errOK;
|
---|
6321 | +
|
---|
6322 | +#if 0
|
---|
6323 | + /* unload words */
|
---|
6324 | + agiV3UnloadWords();
|
---|
6325 | +
|
---|
6326 | + /* unload objects */
|
---|
6327 | + agiV3UnloadObjects();
|
---|
6328 | +#endif
|
---|
6329 | +
|
---|
6330 | + return ec;
|
---|
6331 | +}
|
---|
6332 | +
|
---|
6333 | +int AgiLoader_v3::unloadResource(int t, int n) {
|
---|
6334 | + switch (t) {
|
---|
6335 | + case rLOGIC:
|
---|
6336 | + _vm->unloadLogic(n);
|
---|
6337 | + break;
|
---|
6338 | + case rPICTURE:
|
---|
6339 | + _vm->_picture->unloadPicture(n);
|
---|
6340 | + break;
|
---|
6341 | + case rVIEW:
|
---|
6342 | + _vm->unloadView(n);
|
---|
6343 | + break;
|
---|
6344 | + case rSOUND:
|
---|
6345 | + _vm->_sound->unloadSound(n);
|
---|
6346 | + break;
|
---|
6347 | + }
|
---|
6348 | +
|
---|
6349 | + return errOK;
|
---|
6350 | +}
|
---|
6351 | +
|
---|
6352 | +/*
|
---|
6353 | + * This function does noting but load a raw resource into memory.
|
---|
6354 | + * If further decoding is required, it must be done by another
|
---|
6355 | + * routine.
|
---|
6356 | + *
|
---|
6357 | + * NULL is returned if unsucsessful.
|
---|
6358 | + */
|
---|
6359 | +uint8 *AgiLoader_v3::loadVolRes(AgiDir *agid) {
|
---|
6360 | + char x[MAX_PATH];
|
---|
6361 | + uint8 *data = NULL, *compBuffer;
|
---|
6362 | + Common::File fp;
|
---|
6363 | + Common::String path;
|
---|
6364 | +
|
---|
6365 | + debugC(3, kDebugLevelResources, "(%p)", (void *)agid);
|
---|
6366 | + sprintf(x, "vol.%i", agid->volume);
|
---|
6367 | + path = Common::String(_vm->_game.name) + x;
|
---|
6368 | +
|
---|
6369 | + if (agid->offset != _EMPTY && fp.open(path)) {
|
---|
6370 | + fp.seek(agid->offset, SEEK_SET);
|
---|
6371 | + fp.read(&x, 7);
|
---|
6372 | +
|
---|
6373 | + if (READ_BE_UINT16((uint8 *) x) != 0x1234) {
|
---|
6374 | +#if 0
|
---|
6375 | + /* FIXME */
|
---|
6376 | + deinitVideoMode();
|
---|
6377 | +#endif
|
---|
6378 | + debugC(3, kDebugLevelResources, "path = %s", path.c_str());
|
---|
6379 | + debugC(3, kDebugLevelResources, "offset = %d", agid->offset);
|
---|
6380 | + debugC(3, kDebugLevelResources, "x = %x %x", x[0], x[1]);
|
---|
6381 | + error("ACK! BAD RESOURCE");
|
---|
6382 | +
|
---|
6383 | + g_system->quit();
|
---|
6384 | + }
|
---|
6385 | +
|
---|
6386 | + agid->len = READ_LE_UINT16((uint8 *) x + 3); /* uncompressed size */
|
---|
6387 | + agid->clen = READ_LE_UINT16((uint8 *) x + 5); /* compressed len */
|
---|
6388 | +
|
---|
6389 | + compBuffer = (uint8 *)calloc(1, agid->clen + 32);
|
---|
6390 | + fp.read(compBuffer, agid->clen);
|
---|
6391 | +
|
---|
6392 | + if (x[2] & 0x80 || agid->len == agid->clen) {
|
---|
6393 | + /* do not decompress */
|
---|
6394 | + data = compBuffer;
|
---|
6395 | +
|
---|
6396 | +#if 0
|
---|
6397 | + /* CM: added to avoid problems in
|
---|
6398 | + * convert_v2_v3_pic() when clen > len
|
---|
6399 | + * e.g. Sierra demo 4, first picture
|
---|
6400 | + * (Tue Mar 16 13:13:43 EST 1999)
|
---|
6401 | + */
|
---|
6402 | + agid->len = agid->clen;
|
---|
6403 | +
|
---|
6404 | + /* Now removed to fix Gold Rush! in demo4 */
|
---|
6405 | +#endif
|
---|
6406 | + } else {
|
---|
6407 | + /* it is compressed */
|
---|
6408 | + data = (uint8 *)calloc(1, agid->len + 32);
|
---|
6409 | + lzwExpand(compBuffer, data, agid->len);
|
---|
6410 | + free(compBuffer);
|
---|
6411 | + agid->flags |= RES_COMPRESSED;
|
---|
6412 | + }
|
---|
6413 | +
|
---|
6414 | + fp.close();
|
---|
6415 | + } else {
|
---|
6416 | + /* we have a bad volume resource */
|
---|
6417 | + /* set that resource to NA */
|
---|
6418 | + agid->offset = _EMPTY;
|
---|
6419 | + }
|
---|
6420 | +
|
---|
6421 | + return data;
|
---|
6422 | +}
|
---|
6423 | +
|
---|
6424 | +/*
|
---|
6425 | + * Loads a resource into memory, a raw resource is loaded in
|
---|
6426 | + * with above routine, then further decoded here.
|
---|
6427 | + */
|
---|
6428 | +int AgiLoader_v3::loadResource(int t, int n) {
|
---|
6429 | + int ec = errOK;
|
---|
6430 | + uint8 *data = NULL;
|
---|
6431 | +
|
---|
6432 | + if (n > MAX_DIRS)
|
---|
6433 | + return errBadResource;
|
---|
6434 | +
|
---|
6435 | + switch (t) {
|
---|
6436 | + case rLOGIC:
|
---|
6437 | + /* load resource into memory, decrypt messages at the end
|
---|
6438 | + * and build the message list (if logic is in memory)
|
---|
6439 | + */
|
---|
6440 | + if (~_vm->_game.dirLogic[n].flags & RES_LOADED) {
|
---|
6441 | + /* if logic is already in memory, unload it */
|
---|
6442 | + unloadResource(rLOGIC, n);
|
---|
6443 | +
|
---|
6444 | + /* load raw resource into data */
|
---|
6445 | + data = loadVolRes(&_vm->_game.dirLogic[n]);
|
---|
6446 | + _vm->_game.logics[n].data = data;
|
---|
6447 | +
|
---|
6448 | + /* uncompressed logic files need to be decrypted */
|
---|
6449 | + if (data != NULL) {
|
---|
6450 | + /* resloaded flag gets set by decode logic */
|
---|
6451 | + /* needed to build string table */
|
---|
6452 | + ec = _vm->decodeLogic(n);
|
---|
6453 | + _vm->_game.logics[n].sIP = 2;
|
---|
6454 | + } else {
|
---|
6455 | + ec = errBadResource;
|
---|
6456 | + }
|
---|
6457 | +
|
---|
6458 | + /*logics[n].sIP=2; *//* saved IP = 2 */
|
---|
6459 | + /*logics[n].cIP=2; *//* current IP = 2 */
|
---|
6460 | +
|
---|
6461 | + _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
---|
6462 | + }
|
---|
6463 | +
|
---|
6464 | + /* if logic was cached, we get here */
|
---|
6465 | + /* reset code pointers incase it was cached */
|
---|
6466 | +
|
---|
6467 | + _vm->_game.logics[n].cIP = _vm->_game.logics[n].sIP;
|
---|
6468 | + break;
|
---|
6469 | + case rPICTURE:
|
---|
6470 | + /* if picture is currently NOT loaded *OR* cacheing is off,
|
---|
6471 | + * unload the resource (caching==off) and reload it
|
---|
6472 | + */
|
---|
6473 | + if (~_vm->_game.dirPic[n].flags & RES_LOADED) {
|
---|
6474 | + unloadResource(rPICTURE, n);
|
---|
6475 | + data = loadVolRes(&_vm->_game.dirPic[n]);
|
---|
6476 | + if (data != NULL) {
|
---|
6477 | + data = _vm->_picture->convertV3Pic(data, _vm->_game.dirPic[n].len);
|
---|
6478 | + _vm->_game.pictures[n].rdata = data;
|
---|
6479 | + _vm->_game.dirPic[n].flags |= RES_LOADED;
|
---|
6480 | + } else {
|
---|
6481 | + ec = errBadResource;
|
---|
6482 | + }
|
---|
6483 | + }
|
---|
6484 | + break;
|
---|
6485 | + case rSOUND:
|
---|
6486 | + if (_vm->_game.dirSound[n].flags & RES_LOADED)
|
---|
6487 | + break;
|
---|
6488 | +
|
---|
6489 | + data = loadVolRes(&_vm->_game.dirSound[n]);
|
---|
6490 | + if (data != NULL) {
|
---|
6491 | + // Freeing of the raw resource from memory is delegated to the createFromRawResource-function
|
---|
6492 | + _vm->_game.sounds[n] = AgiSound::createFromRawResource(data, _vm->_game.dirSound[n].len, n, *_vm->_sound);
|
---|
6493 | + _vm->_game.dirSound[n].flags |= RES_LOADED;
|
---|
6494 | + } else {
|
---|
6495 | + ec = errBadResource;
|
---|
6496 | + }
|
---|
6497 | + break;
|
---|
6498 | + case rVIEW:
|
---|
6499 | + /* Load a VIEW resource into memory...
|
---|
6500 | + * Since VIEWS alter the view table ALL the time can we
|
---|
6501 | + * cache the view? or must we reload it all the time?
|
---|
6502 | + */
|
---|
6503 | + /* load a raw view from a VOL file into data */
|
---|
6504 | + if (_vm->_game.dirView[n].flags & RES_LOADED)
|
---|
6505 | + break;
|
---|
6506 | +
|
---|
6507 | + unloadResource(rVIEW, n);
|
---|
6508 | + data = loadVolRes(&_vm->_game.dirView[n]);
|
---|
6509 | + if (data != NULL) {
|
---|
6510 | + _vm->_game.views[n].rdata = data;
|
---|
6511 | + _vm->_game.dirView[n].flags |= RES_LOADED;
|
---|
6512 | + ec = _vm->decodeView(n);
|
---|
6513 | + } else {
|
---|
6514 | + ec = errBadResource;
|
---|
6515 | + }
|
---|
6516 | + break;
|
---|
6517 | + default:
|
---|
6518 | + ec = errBadResource;
|
---|
6519 | + break;
|
---|
6520 | + }
|
---|
6521 | +
|
---|
6522 | + return ec;
|
---|
6523 | +}
|
---|
6524 | +
|
---|
6525 | +int AgiLoader_v3::loadObjects(const char *fname) {
|
---|
6526 | + return _vm->loadObjects(fname);
|
---|
6527 | +}
|
---|
6528 | +
|
---|
6529 | +int AgiLoader_v3::loadWords(const char *fname) {
|
---|
6530 | + return _vm->loadWords(fname);
|
---|
6531 | +}
|
---|
6532 | +
|
---|
6533 | +} // End of namespace Agi
|
---|
6534 |
|
---|
6535 | Property changes on: /home/david/Projects/scummvm/engines/agi/agi_v3.cpp
|
---|
6536 | ___________________________________________________________________
|
---|
6537 | Name: svn:eol-style
|
---|
6538 | + native
|
---|
6539 | Name: svn:keywords
|
---|
6540 | + Date Rev Author URL Id
|
---|
6541 | Name: svn:mime-type
|
---|
6542 | + text/plain
|
---|
6543 |
|
---|
6544 | Index: /home/david/Projects/scummvm/engines/agi/detection.cpp
|
---|
6545 | ===================================================================
|
---|
6546 | --- /home/david/Projects/scummvm/engines/agi/detection.cpp (revision 28941)
|
---|
6547 | +++ /home/david/Projects/scummvm/engines/agi/detection.cpp (working copy)
|
---|
6548 | @@ -1930,7 +1930,7 @@
|
---|
6549 | path = ".";
|
---|
6550 |
|
---|
6551 | FilesystemNode fsCurrentDir(path);
|
---|
6552 | - fsCurrentDir.listDir(fslistCurrentDir, FilesystemNode::kListFilesOnly);
|
---|
6553 | + fsCurrentDir.getChildren(fslistCurrentDir, FilesystemNode::kListFilesOnly);
|
---|
6554 | fslist = &fslistCurrentDir;
|
---|
6555 | }
|
---|
6556 |
|
---|
6557 | @@ -1947,7 +1947,7 @@
|
---|
6558 | // First grab all filenames and at the same time count the number of *.wag files
|
---|
6559 | for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
|
---|
6560 | if (file->isDirectory()) continue;
|
---|
6561 | - Common::String filename = file->name();
|
---|
6562 | + Common::String filename = file->getName();
|
---|
6563 | filename.toLowercase();
|
---|
6564 | allFiles[filename] = true; // Save the filename in a hash table
|
---|
6565 |
|
---|
6566 | @@ -1953,7 +1953,7 @@
|
---|
6567 |
|
---|
6568 | if (filename.hasSuffix(".wag")) {
|
---|
6569 | // Save latest found *.wag file's path (Can be used to open the file, the name can't)
|
---|
6570 | - wagFilePath = file->path();
|
---|
6571 | + wagFilePath = file->getPath();
|
---|
6572 | wagFileCount++; // Count found *.wag files
|
---|
6573 | }
|
---|
6574 | }
|
---|
6575 | Index: /home/david/Projects/scummvm/engines/agi/loader_v3.cpp
|
---|
6576 | ===================================================================
|
---|
6577 | --- /home/david/Projects/scummvm/engines/agi/loader_v3.cpp (revision 28941)
|
---|
6578 | +++ /home/david/Projects/scummvm/engines/agi/loader_v3.cpp (working copy)
|
---|
6579 | @@ -52,8 +52,8 @@
|
---|
6580 | FSList fslist;
|
---|
6581 | FilesystemNode dir(ConfMan.get("path"));
|
---|
6582 |
|
---|
6583 | - if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6584 | - warning("AgiEngine: invalid game path '%s'", dir.path().c_str());
|
---|
6585 | + if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6586 | + warning("AgiEngine: invalid game path '%s'", dir.getPath().c_str());
|
---|
6587 | return errInvalidAGIFile;
|
---|
6588 | }
|
---|
6589 |
|
---|
6590 | @@ -59,7 +59,7 @@
|
---|
6591 |
|
---|
6592 | for (FSList::const_iterator file = fslist.begin();
|
---|
6593 | file != fslist.end() && !found; ++file) {
|
---|
6594 | - Common::String f = file->name();
|
---|
6595 | + Common::String f = file->getName();
|
---|
6596 | f.toLowercase();
|
---|
6597 |
|
---|
6598 | if (f.hasSuffix("vol.0")) {
|
---|
6599 | Index: /home/david/Projects/scummvm/engines/agi/sound.cpp
|
---|
6600 | ===================================================================
|
---|
6601 | --- /home/david/Projects/scummvm/engines/agi/sound.cpp (revision 28941)
|
---|
6602 | +++ /home/david/Projects/scummvm/engines/agi/sound.cpp (working copy)
|
---|
6603 | @@ -989,7 +989,7 @@
|
---|
6604 | fsnodeNameEqualsIgnoreCase(const Common::String str) { _str.push_back(str); }
|
---|
6605 | bool operator()(const FilesystemNode ¶m) const {
|
---|
6606 | for (Common::StringList::const_iterator iter = _str.begin(); iter != _str.end(); iter++)
|
---|
6607 | - if (param.name().equalsIgnoreCase(*iter))
|
---|
6608 | + if (param.getName().equalsIgnoreCase(*iter))
|
---|
6609 | return true;
|
---|
6610 | return false;
|
---|
6611 | }
|
---|
6612 | @@ -1014,8 +1014,8 @@
|
---|
6613 | // List files in the game path
|
---|
6614 | FSList fslist;
|
---|
6615 | FilesystemNode dir(ConfMan.get("path"));
|
---|
6616 | - if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6617 | - warning("Invalid game path (\"%s\"), not loading Apple IIGS instruments", dir.path().c_str());
|
---|
6618 | + if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6619 | + warning("Invalid game path (\"%s\"), not loading Apple IIGS instruments", dir.getPath().c_str());
|
---|
6620 | return false;
|
---|
6621 | }
|
---|
6622 |
|
---|
6623 | @@ -1050,7 +1050,7 @@
|
---|
6624 | // Finally fix the instruments' lengths using the wave file data
|
---|
6625 | // (A zero in the wave file data can end the sample prematurely)
|
---|
6626 | // and convert the wave file from 8-bit unsigned to 16-bit signed format.
|
---|
6627 | - Common::MemoryReadStream *uint8Wave = loadWaveFile(waveFsnode->path(), *exeInfo);
|
---|
6628 | + Common::MemoryReadStream *uint8Wave = loadWaveFile(waveFsnode->getPath(), *exeInfo);
|
---|
6629 | // Seek the wave to its
|
---|
6630 | if (uint8Wave != NULL)
|
---|
6631 | uint8Wave->seek(0);
|
---|
6632 | @@ -1055,7 +1055,7 @@
|
---|
6633 | if (uint8Wave != NULL)
|
---|
6634 | uint8Wave->seek(0);
|
---|
6635 |
|
---|
6636 | - bool result = uint8Wave != NULL && loadInstrumentHeaders(exeFsnode->path(), *exeInfo) &&
|
---|
6637 | + bool result = uint8Wave != NULL && loadInstrumentHeaders(exeFsnode->getPath(), *exeInfo) &&
|
---|
6638 | finalizeInstruments(*uint8Wave) && convertWave(*uint8Wave, g_wave, uint8Wave->size());
|
---|
6639 |
|
---|
6640 | delete uint8Wave; // Free the 8-bit unsigned wave file buffer
|
---|
6641 | Index: /home/david/Projects/scummvm/engines/agos/saveload.cpp
|
---|
6642 | ===================================================================
|
---|
6643 | --- /home/david/Projects/scummvm/engines/agos/saveload.cpp (revision 28941)
|
---|
6644 | +++ /home/david/Projects/scummvm/engines/agos/saveload.cpp (working copy)
|
---|
6645 | @@ -38,13 +38,29 @@
|
---|
6646 |
|
---|
6647 | int AGOSEngine::countSaveGames() {
|
---|
6648 | Common::InSaveFile *f;
|
---|
6649 | + Common::StringList filenames;
|
---|
6650 | uint i = 1;
|
---|
6651 | + char slot[3];
|
---|
6652 | + int slotNum;
|
---|
6653 | bool marks[256];
|
---|
6654 |
|
---|
6655 | char *prefix = genSaveName(998);
|
---|
6656 | - prefix[strlen(prefix)-3] = '\0';
|
---|
6657 | - _saveFileMan->listSavefiles(prefix, marks, 256);
|
---|
6658 | + prefix[strlen(prefix)-3] = '*';
|
---|
6659 | + prefix[strlen(prefix)-2] = '\0';
|
---|
6660 | + memset(marks, false, 256 * sizeof(bool)); //assume no savegames for this title
|
---|
6661 | + filenames = _saveFileMan->listSavefiles(prefix);
|
---|
6662 |
|
---|
6663 | + for(Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
|
---|
6664 | + //Obtain the last 3 digits of the filename, since they correspond to the save slot
|
---|
6665 | + slot[0] = file->c_str()[file->size()-3];
|
---|
6666 | + slot[1] = file->c_str()[file->size()-2];
|
---|
6667 | + slot[2] = file->c_str()[file->size()-1];
|
---|
6668 | +
|
---|
6669 | + slotNum = atoi(slot);
|
---|
6670 | + if(slotNum >= 0 && slotNum < 256)
|
---|
6671 | + marks[slotNum] = true; //mark this slot as valid
|
---|
6672 | + }
|
---|
6673 | +
|
---|
6674 | while (i < 256) {
|
---|
6675 | if (marks[i] &&
|
---|
6676 | (f = _saveFileMan->openForLoading(genSaveName(i)))) {
|
---|
6677 | @@ -53,6 +69,7 @@
|
---|
6678 | } else
|
---|
6679 | break;
|
---|
6680 | }
|
---|
6681 | +
|
---|
6682 | return i;
|
---|
6683 | }
|
---|
6684 |
|
---|
6685 | Index: /home/david/Projects/scummvm/engines/kyra/resource.cpp
|
---|
6686 | ===================================================================
|
---|
6687 | --- /home/david/Projects/scummvm/engines/kyra/resource.cpp (revision 28941)
|
---|
6688 | +++ /home/david/Projects/scummvm/engines/kyra/resource.cpp (working copy)
|
---|
6689 | @@ -82,8 +82,8 @@
|
---|
6690 | FSList fslist;
|
---|
6691 | FilesystemNode dir(ConfMan.get("path"));
|
---|
6692 |
|
---|
6693 | - if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly))
|
---|
6694 | - error("invalid game path '%s'", dir.path().c_str());
|
---|
6695 | + if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly))
|
---|
6696 | + error("invalid game path '%s'", dir.getPath().c_str());
|
---|
6697 |
|
---|
6698 | if (_vm->game() == GI_KYRA1 && _vm->gameFlags().isTalkie) {
|
---|
6699 | static const char *list[] = {
|
---|
6700 | @@ -96,7 +96,7 @@
|
---|
6701 | Common::for_each(_pakfiles.begin(), _pakfiles.end(), Common::bind2nd(Common::mem_fun(&ResourceFile::protect), true));
|
---|
6702 | } else {
|
---|
6703 | for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
6704 | - Common::String filename = file->name();
|
---|
6705 | + Common::String filename = file->getName();
|
---|
6706 | filename.toUppercase();
|
---|
6707 |
|
---|
6708 | // No real PAK file!
|
---|
6709 | @@ -104,8 +104,8 @@
|
---|
6710 | continue;
|
---|
6711 |
|
---|
6712 | if (filename.hasSuffix("PAK") || filename.hasSuffix("APK")) {
|
---|
6713 | - if (!loadPakFile(file->name()))
|
---|
6714 | - error("couldn't open pakfile '%s'", file->name().c_str());
|
---|
6715 | + if (!loadPakFile(file->getName()))
|
---|
6716 | + error("couldn't open pakfile '%s'", file->getName().c_str());
|
---|
6717 | }
|
---|
6718 | }
|
---|
6719 |
|
---|
6720 | Index: /home/david/Projects/scummvm/engines/lure/detection.cpp
|
---|
6721 | ===================================================================
|
---|
6722 | --- /home/david/Projects/scummvm/engines/lure/detection.cpp (revision 28941)
|
---|
6723 | +++ /home/david/Projects/scummvm/engines/lure/detection.cpp (working copy)
|
---|
6724 | @@ -97,7 +97,7 @@
|
---|
6725 | continue;
|
---|
6726 |
|
---|
6727 | for (g = lure_games; g->gameid; g++) {
|
---|
6728 | - if (scumm_stricmp(file->name().c_str(), g->checkFile) == 0)
|
---|
6729 | + if (scumm_stricmp(file->getName().c_str(), g->checkFile) == 0)
|
---|
6730 | isFound = true;
|
---|
6731 | }
|
---|
6732 | if (isFound)
|
---|
6733 | Index: /home/david/Projects/scummvm/engines/queen/queen.cpp
|
---|
6734 | ===================================================================
|
---|
6735 | --- /home/david/Projects/scummvm/engines/queen/queen.cpp (revision 28941)
|
---|
6736 | +++ /home/david/Projects/scummvm/engines/queen/queen.cpp (working copy)
|
---|
6737 | @@ -73,7 +73,7 @@
|
---|
6738 | if (file->isDirectory()) {
|
---|
6739 | continue;
|
---|
6740 | }
|
---|
6741 | - if (file->name().equalsIgnoreCase("queen.1") || file->name().equalsIgnoreCase("queen.1c")) {
|
---|
6742 | + if (file->getName().equalsIgnoreCase("queen.1") || file->getName().equalsIgnoreCase("queen.1c")) {
|
---|
6743 | Common::File dataFile;
|
---|
6744 | if (!dataFile.open(*file)) {
|
---|
6745 | continue;
|
---|
6746 | @@ -317,11 +317,28 @@
|
---|
6747 | }
|
---|
6748 |
|
---|
6749 | void QueenEngine::findGameStateDescriptions(char descriptions[100][32]) {
|
---|
6750 | - char filename[20];
|
---|
6751 | - makeGameStateName(0, filename);
|
---|
6752 | - filename[strlen(filename) - 2] = 0;
|
---|
6753 | + char prefix[20];
|
---|
6754 | + makeGameStateName(0, prefix);
|
---|
6755 | + prefix[strlen(prefix) - 2] = '*';
|
---|
6756 | + prefix[strlen(prefix) - 1] = 0;
|
---|
6757 | bool marks[SAVESTATE_MAX_NUM];
|
---|
6758 | - _saveFileMan->listSavefiles(filename, marks, SAVESTATE_MAX_NUM);
|
---|
6759 | + char slot[2];
|
---|
6760 | + int slotNum;
|
---|
6761 | + Common::StringList filenames;
|
---|
6762 | +
|
---|
6763 | + memset(marks, false, SAVESTATE_MAX_NUM * sizeof(bool)); //assume no savegames for this title
|
---|
6764 | + filenames = _saveFileMan->listSavefiles(prefix);
|
---|
6765 | +
|
---|
6766 | + for(Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
|
---|
6767 | + //Obtain the last 2 digits of the filename, since they correspond to the save slot
|
---|
6768 | + slot[0] = file->c_str()[file->size()-2];
|
---|
6769 | + slot[1] = file->c_str()[file->size()-1];
|
---|
6770 | +
|
---|
6771 | + slotNum = atoi(slot);
|
---|
6772 | + if(slotNum >= 0 && slotNum < SAVESTATE_MAX_NUM)
|
---|
6773 | + marks[slotNum] = true; //mark this slot as valid
|
---|
6774 | + }
|
---|
6775 | +
|
---|
6776 | for (int i = 0; i < SAVESTATE_MAX_NUM; ++i) {
|
---|
6777 | if (marks[i]) {
|
---|
6778 | GameStateHeader header;
|
---|
6779 | Index: /home/david/Projects/scummvm/engines/saga/saveload.cpp
|
---|
6780 | ===================================================================
|
---|
6781 | --- /home/david/Projects/scummvm/engines/saga/saveload.cpp (revision 28941)
|
---|
6782 | +++ /home/david/Projects/scummvm/engines/saga/saveload.cpp (working copy)
|
---|
6783 | @@ -112,14 +112,32 @@
|
---|
6784 | }
|
---|
6785 |
|
---|
6786 | void SagaEngine::fillSaveList() {
|
---|
6787 | + assert(_saveMarks);
|
---|
6788 | +
|
---|
6789 | int i;
|
---|
6790 | Common::InSaveFile *in;
|
---|
6791 | + Common::StringList filenames;
|
---|
6792 | + char slot[2];
|
---|
6793 | + int slotNum;
|
---|
6794 | char *name;
|
---|
6795 |
|
---|
6796 | name = calcSaveFileName(MAX_SAVES);
|
---|
6797 | - name[strlen(name) - 2] = 0;
|
---|
6798 | - _saveFileMan->listSavefiles(name, _saveMarks, MAX_SAVES);
|
---|
6799 | -
|
---|
6800 | + name[strlen(name) - 2] = '*';
|
---|
6801 | + name[strlen(name) - 1] = 0;
|
---|
6802 | +
|
---|
6803 | + memset(_saveMarks, false, MAX_SAVES * sizeof(bool)); //assume no savegames for this title
|
---|
6804 | + filenames = _saveFileMan->listSavefiles(name);
|
---|
6805 | +
|
---|
6806 | + for(Common::StringList::iterator file = filenames.begin(); file != filenames.end(); file++){
|
---|
6807 | + //Obtain the last 2 digits of the filename, since they correspond to the save slot
|
---|
6808 | + slot[0] = file->c_str()[file->size()-2];
|
---|
6809 | + slot[1] = file->c_str()[file->size()-1];
|
---|
6810 | +
|
---|
6811 | + slotNum = atoi(slot);
|
---|
6812 | + if(slotNum >= 0 && slotNum < MAX_SAVES)
|
---|
6813 | + _saveMarks[slotNum] = true; //mark this slot as valid
|
---|
6814 | + }
|
---|
6815 | +
|
---|
6816 | _saveFilesMaxCount = 0;
|
---|
6817 | for (i = 0; i < MAX_SAVES; i++) {
|
---|
6818 | if (_saveMarks[i]) {
|
---|
6819 | Index: /home/david/Projects/scummvm/engines/scumm/detection.cpp
|
---|
6820 | ===================================================================
|
---|
6821 | --- /home/david/Projects/scummvm/engines/scumm/detection.cpp (revision 28941)
|
---|
6822 | +++ /home/david/Projects/scummvm/engines/scumm/detection.cpp (working copy)
|
---|
6823 | @@ -18,8 +18,8 @@
|
---|
6824 | * along with this program; if not, write to the Free Software
|
---|
6825 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
6826 | *
|
---|
6827 | - * $URL$
|
---|
6828 | - * $Id$
|
---|
6829 | + * $URL:https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/branches/gsoc2007-fsnode/engines/scumm/detection.cpp $
|
---|
6830 | + * $Id:detection.cpp 26949 2007-05-26 20:23:24Z david_corrales $
|
---|
6831 | *
|
---|
6832 | */
|
---|
6833 |
|
---|
6834 | @@ -190,7 +190,7 @@
|
---|
6835 | // the first match is used.
|
---|
6836 | static bool searchFSNode(const FSList &fslist, const Common::String &name, FilesystemNode &result) {
|
---|
6837 | for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
6838 | - if (!scumm_stricmp(file->name().c_str(), name.c_str())) {
|
---|
6839 | + if (!scumm_stricmp(file->getName().c_str(), name.c_str())) {
|
---|
6840 | result = *file;
|
---|
6841 | return true;
|
---|
6842 | }
|
---|
6843 | @@ -216,7 +216,7 @@
|
---|
6844 | FSList tmpList;
|
---|
6845 | if (searchFSNode(fslist, "RESOURCE", resDir)
|
---|
6846 | && resDir.isDirectory()
|
---|
6847 | - && resDir.listDir(tmpList, FilesystemNode::kListFilesOnly)
|
---|
6848 | + && resDir.getChildren(tmpList, FilesystemNode::kListFilesOnly)
|
---|
6849 | && searchFSNode(tmpList, filename, langFile)) {
|
---|
6850 | tmp.open(langFile);
|
---|
6851 | }
|
---|
6852 | @@ -320,7 +320,7 @@
|
---|
6853 | DetectorDesc d;
|
---|
6854 | d.node = *file;
|
---|
6855 | d.md5Entry = 0;
|
---|
6856 | - fileMD5Map[file->name()] = d;
|
---|
6857 | + fileMD5Map[file->getName()] = d;
|
---|
6858 | }
|
---|
6859 | }
|
---|
6860 |
|
---|
6861 | @@ -447,7 +447,7 @@
|
---|
6862 |
|
---|
6863 | Common::File tmp;
|
---|
6864 | if (!tmp.open(d.node)) {
|
---|
6865 | - warning("SCUMM detectGames: failed to open '%s' for read access", d.node.path().c_str());
|
---|
6866 | + warning("SCUMM detectGames: failed to open '%s' for read access", d.node.getPath().c_str());
|
---|
6867 | return false;
|
---|
6868 | }
|
---|
6869 |
|
---|
6870 | @@ -751,7 +751,7 @@
|
---|
6871 | // Fetch the list of files in the current directory
|
---|
6872 | FSList fslist;
|
---|
6873 | FilesystemNode dir(ConfMan.get("path"));
|
---|
6874 | - if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6875 | + if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
|
---|
6876 | return kInvalidPathError;
|
---|
6877 | }
|
---|
6878 |
|
---|
6879 | Index: /home/david/Projects/scummvm/engines/scumm/dialogs.cpp
|
---|
6880 | ===================================================================
|
---|
6881 | --- /home/david/Projects/scummvm/engines/scumm/dialogs.cpp (revision 28941)
|
---|
6882 | +++ /home/david/Projects/scummvm/engines/scumm/dialogs.cpp (working copy)
|
---|
6883 | @@ -421,10 +421,10 @@
|
---|
6884 | #pragma mark -
|
---|
6885 |
|
---|
6886 | Common::StringList generateSavegameList(ScummEngine *scumm, bool saveMode) {
|
---|
6887 | - // Get savegame names
|
---|
6888 | - Common::StringList l;
|
---|
6889 | + // Get savegame descriptions
|
---|
6890 | + Common::StringList descriptions;
|
---|
6891 | char name[32];
|
---|
6892 | - uint i = saveMode ? 1 : 0;
|
---|
6893 | + uint i = saveMode ? 1 : 0; //the autosave is on slot #0
|
---|
6894 | bool avail_saves[81];
|
---|
6895 |
|
---|
6896 | scumm->listSavegames(avail_saves, ARRAYSIZE(avail_saves));
|
---|
6897 | @@ -433,10 +433,10 @@
|
---|
6898 | scumm->getSavegameName(i, name);
|
---|
6899 | else
|
---|
6900 | name[0] = 0;
|
---|
6901 | - l.push_back(name);
|
---|
6902 | + descriptions.push_back(name);
|
---|
6903 | }
|
---|
6904 | -
|
---|
6905 | - return l;
|
---|
6906 | +
|
---|
6907 | + return descriptions;
|
---|
6908 | }
|
---|
6909 |
|
---|
6910 | MainMenuDialog::MainMenuDialog(ScummEngine *scumm)
|
---|
6911 | Index: /home/david/Projects/scummvm/engines/scumm/saveload.cpp
|
---|
6912 | ===================================================================
|
---|
6913 | --- /home/david/Projects/scummvm/engines/scumm/saveload.cpp (revision 28941)
|
---|
6914 | +++ /home/david/Projects/scummvm/engines/scumm/saveload.cpp (working copy)
|
---|
6915 | @@ -384,10 +384,28 @@
|
---|
6916 | }
|
---|
6917 |
|
---|
6918 | void ScummEngine::listSavegames(bool *marks, int num) {
|
---|
6919 | + assert(marks);
|
---|
6920 | +
|
---|
6921 | char prefix[256];
|
---|
6922 | + char slot[2];
|
---|
6923 | + int slotNum;
|
---|
6924 | + Common::StringList filenames;
|
---|
6925 | +
|
---|
6926 | makeSavegameName(prefix, 99, false);
|
---|
6927 | - prefix[strlen(prefix)-2] = 0;
|
---|
6928 | - _saveFileMan->listSavefiles(prefix, marks, num);
|
---|
6929 | + prefix[strlen(prefix)-2] = '*';
|
---|
6930 | + prefix[strlen(prefix)-1] = 0;
|
---|
6931 | + memset(marks, false, num * sizeof(bool)); //assume no savegames for this title
|
---|
6932 | + filenames = _saveFileMan->listSavefiles(prefix);
|
---|
6933 | +
|
---|
6934 | + for(Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
|
---|
6935 | + //Obtain the last 2 digits of the filename, since they correspond to the save slot
|
---|
6936 | + slot[0] = file->c_str()[file->size()-2];
|
---|
6937 | + slot[1] = file->c_str()[file->size()-1];
|
---|
6938 | +
|
---|
6939 | + slotNum = atoi(slot);
|
---|
6940 | + if(slotNum >= 0 && slotNum < num)
|
---|
6941 | + marks[slotNum] = true; //mark this slot as valid
|
---|
6942 | + }
|
---|
6943 | }
|
---|
6944 |
|
---|
6945 | bool ScummEngine::getSavegameName(int slot, char *desc) {
|
---|
6946 | Index: /home/david/Projects/scummvm/engines/sky/sky.cpp
|
---|
6947 | ===================================================================
|
---|
6948 | --- /home/david/Projects/scummvm/engines/sky/sky.cpp (revision 28941)
|
---|
6949 | +++ /home/david/Projects/scummvm/engines/sky/sky.cpp (working copy)
|
---|
6950 | @@ -124,11 +124,11 @@
|
---|
6951 | // Iterate over all files in the given directory
|
---|
6952 | for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
6953 | if (!file->isDirectory()) {
|
---|
6954 | - const char *fileName = file->name().c_str();
|
---|
6955 | + const char *fileName = file->getName().c_str();
|
---|
6956 |
|
---|
6957 | if (0 == scumm_stricmp("sky.dsk", fileName)) {
|
---|
6958 | Common::File dataDisk;
|
---|
6959 | - if (dataDisk.open(file->path())) {
|
---|
6960 | + if (dataDisk.open(file->getPath())) {
|
---|
6961 | hasSkyDsk = true;
|
---|
6962 | dataDiskSize = dataDisk.size();
|
---|
6963 | }
|
---|
6964 | @@ -136,7 +136,7 @@
|
---|
6965 |
|
---|
6966 | if (0 == scumm_stricmp("sky.dnr", fileName)) {
|
---|
6967 | Common::File dinner;
|
---|
6968 | - if (dinner.open(file->path())) {
|
---|
6969 | + if (dinner.open(file->getPath())) {
|
---|
6970 | hasSkyDnr = true;
|
---|
6971 | dinnerTableEntries = dinner.readUint32LE();
|
---|
6972 | }
|
---|
6973 | Index: /home/david/Projects/scummvm/engines/sword1/sword1.cpp
|
---|
6974 | ===================================================================
|
---|
6975 | --- /home/david/Projects/scummvm/engines/sword1/sword1.cpp (revision 28941)
|
---|
6976 | +++ /home/david/Projects/scummvm/engines/sword1/sword1.cpp (working copy)
|
---|
6977 | @@ -107,7 +107,7 @@
|
---|
6978 | void Sword1CheckDirectory(const FSList &fslist, bool *filesFound) {
|
---|
6979 | for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
6980 | if (!file->isDirectory()) {
|
---|
6981 | - const char *fileName = file->name().c_str();
|
---|
6982 | + const char *fileName = file->getName().c_str();
|
---|
6983 | for (int cnt = 0; cnt < NUM_FILES_TO_CHECK; cnt++)
|
---|
6984 | if (scumm_stricmp(fileName, g_filesToCheck[cnt]) == 0)
|
---|
6985 | filesFound[cnt] = true;
|
---|
6986 | @@ -113,9 +113,9 @@
|
---|
6987 | filesFound[cnt] = true;
|
---|
6988 | } else {
|
---|
6989 | for (int cnt = 0; cnt < ARRAYSIZE(g_dirNames); cnt++)
|
---|
6990 | - if (scumm_stricmp(file->name().c_str(), g_dirNames[cnt]) == 0) {
|
---|
6991 | + if (scumm_stricmp(file->getName().c_str(), g_dirNames[cnt]) == 0) {
|
---|
6992 | FSList fslist2;
|
---|
6993 | - if (file->listDir(fslist2, FilesystemNode::kListFilesOnly))
|
---|
6994 | + if (file->getChildren(fslist2, FilesystemNode::kListFilesOnly))
|
---|
6995 | Sword1CheckDirectory(fslist2, filesFound);
|
---|
6996 | }
|
---|
6997 | }
|
---|
6998 | Index: /home/david/Projects/scummvm/engines/sword2/sword2.cpp
|
---|
6999 | ===================================================================
|
---|
7000 | --- /home/david/Projects/scummvm/engines/sword2/sword2.cpp (revision 28941)
|
---|
7001 | +++ /home/david/Projects/scummvm/engines/sword2/sword2.cpp (working copy)
|
---|
7002 | @@ -101,7 +101,7 @@
|
---|
7003 | // Iterate over all files in the given directory
|
---|
7004 | for (file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
7005 | if (!file->isDirectory()) {
|
---|
7006 | - const char *fileName = file->name().c_str();
|
---|
7007 | + const char *fileName = file->getName().c_str();
|
---|
7008 |
|
---|
7009 | if (0 == scumm_stricmp(g->detectname, fileName)) {
|
---|
7010 | // Match found, add to list of candidates, then abort inner loop.
|
---|
7011 | @@ -118,11 +118,11 @@
|
---|
7012 | // present e.g. if the user copied the data straight from CD.
|
---|
7013 | for (file = fslist.begin(); file != fslist.end(); ++file) {
|
---|
7014 | if (file->isDirectory()) {
|
---|
7015 | - const char *fileName = file->name().c_str();
|
---|
7016 | + const char *fileName = file->getName().c_str();
|
---|
7017 |
|
---|
7018 | if (0 == scumm_stricmp("clusters", fileName)) {
|
---|
7019 | FSList recList;
|
---|
7020 | - if (file->listDir(recList, FilesystemNode::kListAll)) {
|
---|
7021 | + if (file->getChildren(recList, FilesystemNode::kListAll)) {
|
---|
7022 | GameList recGames(Engine_SWORD2_detectGames(recList));
|
---|
7023 | if (!recGames.empty()) {
|
---|
7024 | detectedGames.push_back(recGames);
|
---|
7025 | @@ -144,7 +144,7 @@
|
---|
7026 |
|
---|
7027 | FSList fslist;
|
---|
7028 | FilesystemNode dir(ConfMan.get("path"));
|
---|
7029 | - if (!dir.listDir(fslist, FilesystemNode::kListAll)) {
|
---|
7030 | + if (!dir.getChildren(fslist, FilesystemNode::kListAll)) {
|
---|
7031 | return kInvalidPathError;
|
---|
7032 | }
|
---|
7033 |
|
---|
7034 | Index: /home/david/Projects/scummvm/engines/touche/saveload.cpp
|
---|
7035 | ===================================================================
|
---|
7036 | --- /home/david/Projects/scummvm/engines/touche/saveload.cpp (revision 28941)
|
---|
7037 | +++ /home/david/Projects/scummvm/engines/touche/saveload.cpp (working copy)
|
---|
7038 | @@ -400,7 +400,7 @@
|
---|
7039 |
|
---|
7040 | void ToucheEngine::generateGameStateFileName(int num, char *dst, int len, bool prefixOnly) const {
|
---|
7041 | if (prefixOnly) {
|
---|
7042 | - snprintf(dst, len, "%s.", _targetName.c_str());
|
---|
7043 | + snprintf(dst, len, "%s.*", _targetName.c_str());
|
---|
7044 | } else {
|
---|
7045 | snprintf(dst, len, "%s.%d", _targetName.c_str(), num);
|
---|
7046 | }
|
---|
7047 | Index: /home/david/Projects/scummvm/engines/touche/ui.cpp
|
---|
7048 | ===================================================================
|
---|
7049 | --- /home/david/Projects/scummvm/engines/touche/ui.cpp (revision 28941)
|
---|
7050 | +++ /home/david/Projects/scummvm/engines/touche/ui.cpp (working copy)
|
---|
7051 | @@ -370,9 +370,33 @@
|
---|
7052 | setupMenu(menuData.mode, &menuData);
|
---|
7053 | curMode = menuData.mode;
|
---|
7054 | if (menuData.mode == kMenuLoadStateMode || menuData.mode == kMenuSaveStateMode) {
|
---|
7055 | + assert(menuData.saveLoadMarks);
|
---|
7056 | +
|
---|
7057 | char gameStateFileName[16];
|
---|
7058 | generateGameStateFileName(999, gameStateFileName, 15, true);
|
---|
7059 | - _saveFileMan->listSavefiles(gameStateFileName, menuData.saveLoadMarks, 100);
|
---|
7060 | + char slot[2];
|
---|
7061 | + int slotNum;
|
---|
7062 | + Common::StringList filenames;
|
---|
7063 | +
|
---|
7064 | + memset(menuData.saveLoadMarks, false, 100 * sizeof(bool)); //assume no savegames for this title
|
---|
7065 | + filenames = _saveFileMan->listSavefiles(gameStateFileName);
|
---|
7066 | +
|
---|
7067 | + for(Common::StringList::const_iterator file = filenames.begin(); file != filenames.end(); file++){
|
---|
7068 | + //Obtain the last 1 or 2 digits of the filename, since they correspond to the save slot
|
---|
7069 | + //This engine can save games either with one or two digits, hence the additional if statement
|
---|
7070 | + slot[0] = file->c_str()[file->size()-2];
|
---|
7071 | + slot[1] = file->c_str()[file->size()-1];
|
---|
7072 | +
|
---|
7073 | + if(!atoi(&slot[0])){
|
---|
7074 | + slotNum = atoi(&slot[1]);
|
---|
7075 | + } else {
|
---|
7076 | + slotNum = atoi(slot);
|
---|
7077 | + }
|
---|
7078 | +
|
---|
7079 | + if(slotNum >= 0 && slotNum < 100)
|
---|
7080 | + menuData.saveLoadMarks[slotNum] = true; //mark this slot as valid
|
---|
7081 | + }
|
---|
7082 | +
|
---|
7083 | for (int i = 0; i < 100; ++i) {
|
---|
7084 | menuData.saveLoadDescriptionsTable[i][0] = 0;
|
---|
7085 | if (menuData.saveLoadMarks[i]) {
|
---|
7086 | Index: /home/david/Projects/scummvm/gui/browser.cpp
|
---|
7087 | ===================================================================
|
---|
7088 | --- /home/david/Projects/scummvm/gui/browser.cpp (revision 28941)
|
---|
7089 | +++ /home/david/Projects/scummvm/gui/browser.cpp (working copy)
|
---|
7090 | @@ -28,7 +28,6 @@
|
---|
7091 | #include "gui/ListWidget.h"
|
---|
7092 |
|
---|
7093 | #include "common/config-manager.h"
|
---|
7094 | -#include "common/fs.h"
|
---|
7095 | #include "common/system.h"
|
---|
7096 | #include "common/algorithm.h"
|
---|
7097 |
|
---|
7098 | @@ -223,10 +222,10 @@
|
---|
7099 |
|
---|
7100 | void BrowserDialog::updateListing() {
|
---|
7101 | // Update the path display
|
---|
7102 | - _currentPath->setLabel(_node.path());
|
---|
7103 | + _currentPath->setLabel(_node.getPath());
|
---|
7104 |
|
---|
7105 | // We memorize the last visited path.
|
---|
7106 | - ConfMan.set("browser_lastpath", _node.path());
|
---|
7107 | + ConfMan.set("browser_lastpath", _node.getPath());
|
---|
7108 |
|
---|
7109 | // Read in the data from the file system
|
---|
7110 | FilesystemNode::ListMode listMode = _isDirBrowser ? FilesystemNode::kListDirectoriesOnly
|
---|
7111 | @@ -231,7 +230,7 @@
|
---|
7112 | // Read in the data from the file system
|
---|
7113 | FilesystemNode::ListMode listMode = _isDirBrowser ? FilesystemNode::kListDirectoriesOnly
|
---|
7114 | : FilesystemNode::kListAll;
|
---|
7115 | - if (!_node.listDir(_nodeContent, listMode)) {
|
---|
7116 | + if (!_node.getChildren(_nodeContent, listMode)) {
|
---|
7117 | _nodeContent.clear();
|
---|
7118 | } else {
|
---|
7119 | Common::sort(_nodeContent.begin(), _nodeContent.end());
|
---|
7120 | @@ -241,9 +240,9 @@
|
---|
7121 | Common::StringList list;
|
---|
7122 | for (FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
|
---|
7123 | if (!_isDirBrowser && i->isDirectory())
|
---|
7124 | - list.push_back(i->displayName() + "/");
|
---|
7125 | + list.push_back(i->getDisplayName() + "/");
|
---|
7126 | else
|
---|
7127 | - list.push_back(i->displayName());
|
---|
7128 | + list.push_back(i->getDisplayName());
|
---|
7129 | }
|
---|
7130 | _fileList->setList(list);
|
---|
7131 | _fileList->scrollTo(0);
|
---|
7132 | Index: /home/david/Projects/scummvm/gui/launcher.cpp
|
---|
7133 | ===================================================================
|
---|
7134 | --- /home/david/Projects/scummvm/gui/launcher.cpp (revision 28941)
|
---|
7135 | +++ /home/david/Projects/scummvm/gui/launcher.cpp (working copy)
|
---|
7136 | @@ -394,9 +394,9 @@
|
---|
7137 | if (browser.runModal() > 0) {
|
---|
7138 | // User made this choice...
|
---|
7139 | FilesystemNode file(browser.getResult());
|
---|
7140 | - _soundFont->setLabel(file.path());
|
---|
7141 | + _soundFont->setLabel(file.getPath());
|
---|
7142 |
|
---|
7143 | - if (!file.path().empty() && (file.path() != "None"))
|
---|
7144 | + if (!file.getPath().empty() && (file.getPath() != "None"))
|
---|
7145 | _soundFontClearButton->setEnabled(true);
|
---|
7146 | else
|
---|
7147 | _soundFontClearButton->setEnabled(false);
|
---|
7148 | @@ -417,7 +417,7 @@
|
---|
7149 | // done with optional specific gameid to pluginmgr detectgames?
|
---|
7150 | // FSList files = dir.listDir(FilesystemNode::kListFilesOnly);
|
---|
7151 |
|
---|
7152 | - _gamePathWidget->setLabel(dir.path());
|
---|
7153 | + _gamePathWidget->setLabel(dir.getPath());
|
---|
7154 | draw();
|
---|
7155 | }
|
---|
7156 | draw();
|
---|
7157 | @@ -430,7 +430,7 @@
|
---|
7158 | if (browser.runModal() > 0) {
|
---|
7159 | // User made his choice...
|
---|
7160 | FilesystemNode dir(browser.getResult());
|
---|
7161 | - _extraPathWidget->setLabel(dir.path());
|
---|
7162 | + _extraPathWidget->setLabel(dir.getPath());
|
---|
7163 | draw();
|
---|
7164 | }
|
---|
7165 | draw();
|
---|
7166 | @@ -442,7 +442,7 @@
|
---|
7167 | if (browser.runModal() > 0) {
|
---|
7168 | // User made his choice...
|
---|
7169 | FilesystemNode dir(browser.getResult());
|
---|
7170 | - _savePathWidget->setLabel(dir.path());
|
---|
7171 | + _savePathWidget->setLabel(dir.getPath());
|
---|
7172 | draw();
|
---|
7173 | }
|
---|
7174 | draw();
|
---|
7175 | @@ -654,9 +654,9 @@
|
---|
7176 | // User made his choice...
|
---|
7177 | FilesystemNode dir(_browser->getResult());
|
---|
7178 | FSList files;
|
---|
7179 | - if (!dir.listDir(files, FilesystemNode::kListAll)) {
|
---|
7180 | + if (!dir.getChildren(files, FilesystemNode::kListAll)) {
|
---|
7181 | error("browser returned a node that is not a directory: '%s'",
|
---|
7182 | - dir.path().c_str());
|
---|
7183 | + dir.getPath().c_str());
|
---|
7184 | }
|
---|
7185 |
|
---|
7186 | // ...so let's determine a list of candidates, games that
|
---|
7187 | @@ -686,7 +686,7 @@
|
---|
7188 | GameDescriptor result = candidates[idx];
|
---|
7189 |
|
---|
7190 | // TODO: Change the detectors to set "path" !
|
---|
7191 | - result["path"] = dir.path();
|
---|
7192 | + result["path"] = dir.getPath();
|
---|
7193 |
|
---|
7194 | Common::String domain = addGameToConf(result);
|
---|
7195 |
|
---|
7196 | Index: /home/david/Projects/scummvm/gui/massadd.cpp
|
---|
7197 | ===================================================================
|
---|
7198 | --- /home/david/Projects/scummvm/gui/massadd.cpp (revision 28941)
|
---|
7199 | +++ /home/david/Projects/scummvm/gui/massadd.cpp (working copy)
|
---|
7200 | @@ -128,9 +128,9 @@
|
---|
7201 | FilesystemNode dir = _scanStack.pop();
|
---|
7202 |
|
---|
7203 | FSList files;
|
---|
7204 | - if (!dir.listDir(files, FilesystemNode::kListAll)) {
|
---|
7205 | + if (!dir.getChildren(files, FilesystemNode::kListAll)) {
|
---|
7206 | error("browser returned a node that is not a directory: '%s'",
|
---|
7207 | - dir.path().c_str());
|
---|
7208 | + dir.getPath().c_str());
|
---|
7209 | }
|
---|
7210 |
|
---|
7211 | // Run the detector on the dir
|
---|
7212 | @@ -142,7 +142,7 @@
|
---|
7213 | // e.g. ask the user which one to pick (make sure to display the
|
---|
7214 | // path, too).
|
---|
7215 | GameDescriptor result = candidates[0];
|
---|
7216 | - result["path"] = dir.path();
|
---|
7217 | + result["path"] = dir.getPath();
|
---|
7218 |
|
---|
7219 | _games.push_back(result);
|
---|
7220 | }
|
---|
7221 | Index: /home/david/Projects/scummvm/gui/options.cpp
|
---|
7222 | ===================================================================
|
---|
7223 | --- /home/david/Projects/scummvm/gui/options.cpp (revision 28941)
|
---|
7224 | +++ /home/david/Projects/scummvm/gui/options.cpp (working copy)
|
---|
7225 | @@ -27,6 +27,7 @@
|
---|
7226 | #include "gui/themebrowser.h"
|
---|
7227 | #include "gui/chooser.h"
|
---|
7228 | #include "gui/eval.h"
|
---|
7229 | +#include "gui/message.h"
|
---|
7230 | #include "gui/newgui.h"
|
---|
7231 | #include "gui/options.h"
|
---|
7232 | #include "gui/PopUpWidget.h"
|
---|
7233 | @@ -813,9 +814,14 @@
|
---|
7234 | if (browser.runModal() > 0) {
|
---|
7235 | // User made his choice...
|
---|
7236 | FilesystemNode dir(browser.getResult());
|
---|
7237 | - _savePath->setLabel(dir.path());
|
---|
7238 | + if(dir.isWritable()) {
|
---|
7239 | + _savePath->setLabel(dir.getPath());
|
---|
7240 | + } else {
|
---|
7241 | + MessageDialog error("The chosen directory cannot be written to. Please select another one.");
|
---|
7242 | + error.runModal();
|
---|
7243 | + return;
|
---|
7244 | + }
|
---|
7245 | draw();
|
---|
7246 | - // TODO - we should check if the directory is writeable before accepting it
|
---|
7247 | }
|
---|
7248 | break;
|
---|
7249 | }
|
---|
7250 | @@ -824,7 +830,7 @@
|
---|
7251 | if (browser.runModal() > 0) {
|
---|
7252 | // User made his choice...
|
---|
7253 | FilesystemNode dir(browser.getResult());
|
---|
7254 | - _themePath->setLabel(dir.path());
|
---|
7255 | + _themePath->setLabel(dir.getPath());
|
---|
7256 | draw();
|
---|
7257 | }
|
---|
7258 | break;
|
---|
7259 | @@ -834,7 +840,7 @@
|
---|
7260 | if (browser.runModal() > 0) {
|
---|
7261 | // User made his choice...
|
---|
7262 | FilesystemNode dir(browser.getResult());
|
---|
7263 | - _extraPath->setLabel(dir.path());
|
---|
7264 | + _extraPath->setLabel(dir.getPath());
|
---|
7265 | draw();
|
---|
7266 | }
|
---|
7267 | break;
|
---|
7268 | @@ -844,9 +850,9 @@
|
---|
7269 | if (browser.runModal() > 0) {
|
---|
7270 | // User made his choice...
|
---|
7271 | FilesystemNode file(browser.getResult());
|
---|
7272 | - _soundFont->setLabel(file.path());
|
---|
7273 | + _soundFont->setLabel(file.getPath());
|
---|
7274 |
|
---|
7275 | - if (!file.path().empty() && (file.path() != "None"))
|
---|
7276 | + if (!file.getPath().empty() && (file.getPath() != "None"))
|
---|
7277 | _soundFontClearButton->setEnabled(true);
|
---|
7278 | else
|
---|
7279 | _soundFontClearButton->setEnabled(false);
|
---|
7280 | Index: /home/david/Projects/scummvm/gui/themebrowser.cpp
|
---|
7281 | ===================================================================
|
---|
7282 | --- /home/david/Projects/scummvm/gui/themebrowser.cpp (revision 28941)
|
---|
7283 | +++ /home/david/Projects/scummvm/gui/themebrowser.cpp (working copy)
|
---|
7284 | @@ -27,7 +27,6 @@
|
---|
7285 | #include "gui/ListWidget.h"
|
---|
7286 | #include "gui/widget.h"
|
---|
7287 | #include "gui/theme.h"
|
---|
7288 | -#include "common/fs.h"
|
---|
7289 |
|
---|
7290 | #ifdef MACOSX
|
---|
7291 | #include "CoreFoundation/CoreFoundation.h"
|
---|
7292 | @@ -145,11 +144,11 @@
|
---|
7293 |
|
---|
7294 | FilesystemNode node(dir);
|
---|
7295 |
|
---|
7296 | - if (!node.isValid())
|
---|
7297 | + if (!node.exists() || !node.isReadable())
|
---|
7298 | return;
|
---|
7299 |
|
---|
7300 | FSList fslist;
|
---|
7301 | - if (!node.listDir(fslist, FilesystemNode::kListAll))
|
---|
7302 | + if (!node.getChildren(fslist, FilesystemNode::kListAll))
|
---|
7303 | return;
|
---|
7304 |
|
---|
7305 | for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) {
|
---|
7306 | @@ -154,7 +153,7 @@
|
---|
7307 |
|
---|
7308 | for (FSList::const_iterator i = fslist.begin(); i != fslist.end(); ++i) {
|
---|
7309 | if (i->isDirectory()) {
|
---|
7310 | - addDir(list, i->path(), level-1);
|
---|
7311 | + addDir(list, i->getPath(), level-1);
|
---|
7312 | } else {
|
---|
7313 | Entry th;
|
---|
7314 | if (isTheme(*i, th)) {
|
---|
7315 | @@ -177,7 +176,7 @@
|
---|
7316 | Common::ConfigFile cfg;
|
---|
7317 | Common::String type;
|
---|
7318 |
|
---|
7319 | - out.file = node.name();
|
---|
7320 | + out.file = node.getName();
|
---|
7321 | for (int i = out.file.size()-1; out.file[i] != '.' && i > 0; --i) {
|
---|
7322 | out.file.deleteLastChar();
|
---|
7323 | }
|
---|