aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/amigaos4/amigaos4-fs.cpp
diff options
context:
space:
mode:
authorDavid Corrales2007-10-07 00:28:38 +0000
committerDavid Corrales2007-10-07 00:28:38 +0000
commitaba30d7ea8541f7260ec7b96a8d33dd7dc06ed74 (patch)
tree86915d69c1463c4ff6fda79ab849b0f62432647b /backends/fs/amigaos4/amigaos4-fs.cpp
parent0fab64817fd027a8321e047c1007d0e7e9e135fc (diff)
downloadscummvm-rg350-aba30d7ea8541f7260ec7b96a8d33dd7dc06ed74.tar.gz
scummvm-rg350-aba30d7ea8541f7260ec7b96a8d33dd7dc06ed74.tar.bz2
scummvm-rg350-aba30d7ea8541f7260ec7b96a8d33dd7dc06ed74.zip
Commit of patch #1804861. It implements a static lastPathComponent() function in each backend, used to extract the last path component of a given path, returned by getName().
svn-id: r29159
Diffstat (limited to 'backends/fs/amigaos4/amigaos4-fs.cpp')
-rw-r--r--backends/fs/amigaos4/amigaos4-fs.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/backends/fs/amigaos4/amigaos4-fs.cpp b/backends/fs/amigaos4/amigaos4-fs.cpp
index c3a98e9b8a..ef6447fcf7 100644
--- a/backends/fs/amigaos4/amigaos4-fs.cpp
+++ b/backends/fs/amigaos4/amigaos4-fs.cpp
@@ -93,7 +93,6 @@ public:
virtual String getPath() const { return _sPath; };
virtual bool isDirectory() const { return _bIsDirectory; };
virtual bool isReadable() const { return true; } //FIXME: this is just a stub
- virtual bool isValid() const { return _bIsValid; };
virtual bool isWritable() const { return true; } //FIXME: this is just a stub
virtual AbstractFilesystemNode *getChild(const String &n) const;
@@ -106,9 +105,6 @@ public:
virtual AbstractFSList listVolumes() const;
};
-// TODO: this is ripped of
-// AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p)
-// maybe change it to use this function instead?
/**
* Returns the last component of a given path.
*
@@ -117,6 +113,12 @@ public:
*/
const char *lastPathComponent(const Common::String &str) {
int offset = str.size();
+
+ if (offset <= 0) {
+ debug(6, "Bad offset");
+ return;
+ }
+
const char *p = str.c_str();
while (offset > 0 && (p[offset-1] == '/' || p[offset-1] == ':'))
@@ -151,19 +153,7 @@ AmigaOSFilesystemNode::AmigaOSFilesystemNode(const String &p) {
}
_sPath = p;
-
- // Extract last component from path
- const char *str = p.c_str();
-
- while (offset > 0 && (str[offset-1] == '/' || str[offset-1] == ':'))
- offset--;
-
- while (offset > 0 && (str[offset-1] != '/' && str[offset-1] != ':')) {
- len++;
- offset--;
- }
-
- _sDisplayName = String(str + offset, len);
+ _sDisplayName = lastPathComponent(_sPath);
_pFileLock = 0;
_bIsDirectory = false;
@@ -352,7 +342,12 @@ bool AmigaOSFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b
if (lock) {
AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(lock, (char *)ead->ed_Name);
if (entry) {
- if (entry->isValid())
+ //FIXME: since the isValid() function is no longer part of the AbstractFilesystemNode
+ // specification, the following call had to be changed:
+ // if (entry->isValid())
+ // Please verify that the logic of the code remains coherent. Also, remember
+ // that the isReadable() and isWritable() methods are available.
+ if (entry->exists())
myList.push_back(entry);
else
delete entry;
@@ -453,7 +448,12 @@ AbstractFSList AmigaOSFilesystemNode::listVolumes() const {
AmigaOSFilesystemNode *entry = new AmigaOSFilesystemNode(volumeLock, buffer);
if (entry) {
- if (entry->isValid())
+ //FIXME: since the isValid() function is no longer part of the AbstractFilesystemNode
+ // specification, the following call had to be changed:
+ // if (entry->isValid())
+ // Please verify that the logic of the code remains coherent. Also, remember
+ // that the isReadable() and isWritable() methods are available.
+ if(entry->exists())
myList.push_back(entry);
else
delete entry;