aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/factories/abstract-fs-factory.h26
-rw-r--r--backends/factories/amigaos4/amigaos4-fs-factory.cpp24
-rw-r--r--backends/factories/amigaos4/amigaos4-fs-factory.h24
-rw-r--r--backends/factories/dc/ronincd-fs-factory.cpp24
-rw-r--r--backends/factories/dc/ronincd-fs-factory.h24
-rw-r--r--backends/factories/ds/ds-fs-factory.cpp24
-rw-r--r--backends/factories/ds/ds-fs-factory.h24
-rw-r--r--backends/factories/fs-factory-maker.cpp128
-rw-r--r--backends/factories/fs-factory-maker.h76
-rw-r--r--backends/factories/gp32/gp32-fs-factory.cpp24
-rw-r--r--backends/factories/morphos/abox-fs-factory.cpp24
-rw-r--r--backends/factories/morphos/abox-fs-factory.h24
-rw-r--r--backends/factories/palmos/palmos-fs-factory.cpp24
-rw-r--r--backends/factories/posix/posix-fs-factory.cpp28
-rw-r--r--backends/factories/posix/posix-fs-factory.h2
-rw-r--r--backends/factories/ps2/ps2-fs-factory.cpp24
-rw-r--r--backends/factories/ps2/ps2-fs-factory.h24
-rw-r--r--backends/factories/psp/psp-fs-factory.cpp24
-rw-r--r--backends/factories/psp/psp-fs-factory.h24
-rw-r--r--backends/factories/symbian/symbian-fs-factory.cpp24
-rw-r--r--backends/factories/symbian/symbian-fs-factory.h24
-rw-r--r--backends/factories/windows/windows-fs-factory.cpp24
-rw-r--r--backends/factories/windows/windows-fs-factory.h24
-rw-r--r--backends/file/base-file.cpp4
-rw-r--r--backends/file/base-file.h8
-rw-r--r--backends/file/posix/posix-file.cpp4
-rw-r--r--backends/file/posix/posix-file.h4
-rw-r--r--backends/fs/abstract-fs.h36
-rw-r--r--backends/fs/dc/dc-fs.cpp2
-rw-r--r--backends/fs/posix/posix-fs.cpp37
-rw-r--r--common/file.cpp4
-rw-r--r--common/file.h5
-rw-r--r--common/fs.cpp57
-rw-r--r--common/fs.h65
34 files changed, 748 insertions, 170 deletions
diff --git a/backends/factories/abstract-fs-factory.h b/backends/factories/abstract-fs-factory.h
index b06ad63228..4238baf5c2 100644
--- a/backends/factories/abstract-fs-factory.h
+++ b/backends/factories/abstract-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef ABSTRACT_FILESYSTEM_FACTORY_H
#define ABSTRACT_FILESYSTEM_FACTORY_H
@@ -50,7 +74,7 @@ public:
* Creates a base file usable by the Common::File wrapper to implement several
* methods.
*/
- virtual BaseFile *makeBaseFile() const = 0;
+ virtual Common::BaseFile *makeBaseFile() const = 0;
};
#endif /*ABSTRACT_FILESYSTEM_FACTORY_H*/
diff --git a/backends/factories/amigaos4/amigaos4-fs-factory.cpp b/backends/factories/amigaos4/amigaos4-fs-factory.cpp
index 2d73c4dbdc..15847e37fc 100644
--- a/backends/factories/amigaos4/amigaos4-fs-factory.cpp
+++ b/backends/factories/amigaos4/amigaos4-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/amigaos4/amigaos4-fs-factory.h"
#include "backends/fs/amigaos4/amigaos4-fs.cpp"
#include "backends/file/amigaos4/amigaos4-file.h"
diff --git a/backends/factories/amigaos4/amigaos4-fs-factory.h b/backends/factories/amigaos4/amigaos4-fs-factory.h
index 86f77ca6fa..6243303166 100644
--- a/backends/factories/amigaos4/amigaos4-fs-factory.h
+++ b/backends/factories/amigaos4/amigaos4-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef AMIGAOS_FILESYSTEM_FACTORY_H
#define AMIGAOS_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/dc/ronincd-fs-factory.cpp b/backends/factories/dc/ronincd-fs-factory.cpp
index c28d735aec..f87aa0b9d5 100644
--- a/backends/factories/dc/ronincd-fs-factory.cpp
+++ b/backends/factories/dc/ronincd-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/dc/ronincd-fs-factory.h"
#include "backends/fs/dc/dc-fs.cpp"
#include "backends/file/base-file.h"
diff --git a/backends/factories/dc/ronincd-fs-factory.h b/backends/factories/dc/ronincd-fs-factory.h
index 5aa6f7a91f..f41c3e81f0 100644
--- a/backends/factories/dc/ronincd-fs-factory.h
+++ b/backends/factories/dc/ronincd-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef RONINCD_FILESYSTEM_FACTORY_H
#define RONINCD_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/ds/ds-fs-factory.cpp b/backends/factories/ds/ds-fs-factory.cpp
index 94bf8e75d0..fab45c92e9 100644
--- a/backends/factories/ds/ds-fs-factory.cpp
+++ b/backends/factories/ds/ds-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/ds/ds-fs-factory.h"
#include "backends/fs/ds/ds-fs.cpp"
#include "backends/file/ds/ds-file.h"
diff --git a/backends/factories/ds/ds-fs-factory.h b/backends/factories/ds/ds-fs-factory.h
index eecd406682..c076f1cb99 100644
--- a/backends/factories/ds/ds-fs-factory.h
+++ b/backends/factories/ds/ds-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef DS_FILESYSTEM_FACTORY_H
#define DS_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/fs-factory-maker.cpp b/backends/factories/fs-factory-maker.cpp
index 8bef982f37..1056726887 100644
--- a/backends/factories/fs-factory-maker.cpp
+++ b/backends/factories/fs-factory-maker.cpp
@@ -1,113 +1,51 @@
-#include "backends/factories/abstract-fs-factory.h"
-
-/*
- * All the following includes choose, at compile time, which specific backend will be used
- * during the execution of the ScummVM.
- *
- * It has to be done this way because not all the necessary libraries will be available in
- * all build environments. Additionally, this results in smaller binaries.
- */
-#if defined(__amigaos4__)
- #include "backends/factories/amigaos4/amigaos4-fs-factory.cpp"
-#endif
-
-#if defined(__DC__)
- #include "backends/factories/dc/ronincd-fs-factory.cpp"
-#endif
-
-#if defined(__DS__)
- #include "backends/factories/ds/ds-fs-factory.cpp"
-#endif
-
-#if defined(__GP32__)
- #include "backends/factories/gp32/gp32-fs-factory.cpp"
-#endif
-
-#if defined(__MORPHOS__)
- #include "backends/factories/morphos/abox-fs-factory.cpp"
-#endif
-
-#if defined(PALMOS_MODE)
- #include "backends/factories/palmos/palmos-fs-factory.cpp"
-#endif
-
-#if defined(__PLAYSTATION2__)
- #include "backends/factories/ps2/ps2-fs-factory.cpp"
-#endif
-
-#if defined(__PSP__)
- #include "backends/factories/psp/psp-fs-factory.cpp"
-#endif
-
-#if defined(__SYMBIAN32__)
- #include "backends/factories/symbian/symbian-fs-factory.cpp"
-#endif
-
-#if defined(UNIX)
- #include "backends/factories/posix/posix-fs-factory.cpp"
-#endif
-
-#if defined(WIN32)
- #include "backends/factories/windows/windows-fs-factory.cpp"
-#endif
-
-/**
- * Creates concrete FilesystemFactory and FileFactory objects depending on the current architecture.
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
*/
-class FilesystemFactoryMaker {
-public:
- /**
- * Returns the correct concrete filesystem factory depending on the current build architecture.
- */
- static AbstractFilesystemFactory *makeFactory();
-
-protected:
- FilesystemFactoryMaker() {}; // avoid instances of this class
-};
+#include "backends/factories/fs-factory-maker.h"
AbstractFilesystemFactory *FilesystemFactoryMaker::makeFactory(){
#if defined(__amigaos4__)
return &AmigaOSFilesystemFactory::instance();
- #endif
-
- #if defined(__DC__)
+ #elif defined(__DC__)
return &RoninCDFilesystemFactory::instance();
- #endif
-
- #if defined(__DS__)
+ #elif defined(__DS__)
return &DSFilesystemFactory::instance();
- #endif
-
- #if defined(__GP32__)
+ #elif defined(__GP32__)
return &GP32FilesystemFactory::instance();
- #endif
-
- #if defined(__MORPHOS__)
+ #elif defined(__MORPHOS__)
return &ABoxFilesystemFactory::instance();
- #endif
-
- #if defined(PALMOS_MODE)
+ #elif defined(PALMOS_MODE)
return &PalmOSFilesystemFactory::instance();
- #endif
-
- #if defined(__PLAYSTATION2__)
+ #elif defined(__PLAYSTATION2__)
return &Ps2FilesystemFactory::instance();
- #endif
-
- #if defined(__PSP__)
+ #elif defined(__PSP__)
return &PSPFilesystemFactory::instance();
- #endif
-
- #if defined(__SYMBIAN32__)
+ #elif defined(__SYMBIAN32__)
return &SymbianFilesystemFactory::instance();
- #endif
-
- #if defined(UNIX)
+ #elif defined(UNIX)
return &POSIXFilesystemFactory::instance();
- #endif
-
- #if defined(WIN32)
+ #elif defined(WIN32)
return &WindowsFilesystemFactory::instance();
#endif
}
diff --git a/backends/factories/fs-factory-maker.h b/backends/factories/fs-factory-maker.h
new file mode 100644
index 0000000000..f9fc0ff85f
--- /dev/null
+++ b/backends/factories/fs-factory-maker.h
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
+#ifndef FS_FACTORY_MAKER_H
+#define FS_FACTORY_MAKER_H
+
+#include "backends/factories/abstract-fs-factory.h"
+
+/*
+ * All the following includes choose, at compile time, which specific backend will be used
+ * during the execution of the ScummVM.
+ *
+ * It has to be done this way because not all the necessary libraries will be available in
+ * all build environments. Additionally, this results in smaller binaries.
+ */
+#if defined(__amigaos4__)
+ #include "backends/factories/amigaos4/amigaos4-fs-factory.cpp"
+#elif defined(__DC__)
+ #include "backends/factories/dc/ronincd-fs-factory.cpp"
+#elif defined(__DS__)
+ #include "backends/factories/ds/ds-fs-factory.cpp"
+#elif defined(__GP32__)
+ #include "backends/factories/gp32/gp32-fs-factory.cpp"
+#elif defined(__MORPHOS__)
+ #include "backends/factories/morphos/abox-fs-factory.cpp"
+#elif defined(PALMOS_MODE)
+ #include "backends/factories/palmos/palmos-fs-factory.cpp"
+#elif defined(__PLAYSTATION2__)
+ #include "backends/factories/ps2/ps2-fs-factory.cpp"
+#elif defined(__PSP__)
+ #include "backends/factories/psp/psp-fs-factory.cpp"
+#elif defined(__SYMBIAN32__)
+ #include "backends/factories/symbian/symbian-fs-factory.cpp"
+#elif defined(UNIX)
+ #include "backends/factories/posix/posix-fs-factory.cpp"
+#elif defined(WIN32)
+ #include "backends/factories/windows/windows-fs-factory.cpp"
+#endif
+
+/**
+ * Creates concrete FilesystemFactory and FileFactory objects depending on the current architecture.
+ */
+class FilesystemFactoryMaker {
+public:
+
+ /**
+ * Returns the correct concrete filesystem factory depending on the current build architecture.
+ */
+ static AbstractFilesystemFactory *makeFactory();
+
+protected:
+ FilesystemFactoryMaker() {}; // avoid instances of this class
+};
+
+#endif //FS_FACTORY_MAKER_H
diff --git a/backends/factories/gp32/gp32-fs-factory.cpp b/backends/factories/gp32/gp32-fs-factory.cpp
index bffbffa21d..43d6a5330c 100644
--- a/backends/factories/gp32/gp32-fs-factory.cpp
+++ b/backends/factories/gp32/gp32-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/gp32/gp32-fs-factory.h"
#include "backends/fs/gp32/gp32-fs.cpp"
#include "backends/file/base-file.h"
diff --git a/backends/factories/morphos/abox-fs-factory.cpp b/backends/factories/morphos/abox-fs-factory.cpp
index 5659baf6f9..961a7cbb9d 100644
--- a/backends/factories/morphos/abox-fs-factory.cpp
+++ b/backends/factories/morphos/abox-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/morphos/abox-fs-factory.h"
#include "backends/fs/morphos/abox-fs.cpp"
#include "backends/file/base-file.h"
diff --git a/backends/factories/morphos/abox-fs-factory.h b/backends/factories/morphos/abox-fs-factory.h
index ff282b5bb9..c265b464a4 100644
--- a/backends/factories/morphos/abox-fs-factory.h
+++ b/backends/factories/morphos/abox-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef ABOX_FILESYSTEM_FACTORY_H
#define ABOX_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/palmos/palmos-fs-factory.cpp b/backends/factories/palmos/palmos-fs-factory.cpp
index 275118b518..bb90857eac 100644
--- a/backends/factories/palmos/palmos-fs-factory.cpp
+++ b/backends/factories/palmos/palmos-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/palmos/palmos-fs-factory.h"
#include "backends/fs/palmos/palmos-fs.cpp"
#include "backends/file/base-file.h"
diff --git a/backends/factories/posix/posix-fs-factory.cpp b/backends/factories/posix/posix-fs-factory.cpp
index 9b77e31557..1887aa8d5f 100644
--- a/backends/factories/posix/posix-fs-factory.cpp
+++ b/backends/factories/posix/posix-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/posix/posix-fs-factory.h"
#include "backends/fs/posix/posix-fs.cpp"
#include "backends/file/posix/posix-file.cpp"
@@ -19,6 +43,6 @@ AbstractFilesystemNode *POSIXFilesystemFactory::makeFileNodePath(const String &p
return new POSIXFilesystemNode(path, true);
}
-BaseFile *POSIXFilesystemFactory::makeBaseFile() const {
- return new POSIXFile();
+Common::BaseFile *POSIXFilesystemFactory::makeBaseFile() const {
+ return new Common::POSIXFile();
}
diff --git a/backends/factories/posix/posix-fs-factory.h b/backends/factories/posix/posix-fs-factory.h
index aef411c92b..0122f7ac58 100644
--- a/backends/factories/posix/posix-fs-factory.h
+++ b/backends/factories/posix/posix-fs-factory.h
@@ -16,7 +16,7 @@ public:
virtual AbstractFilesystemNode *makeRootFileNode() const;
virtual AbstractFilesystemNode *makeCurrentDirectoryFileNode() const;
virtual AbstractFilesystemNode *makeFileNodePath(const String &path) const;
- virtual BaseFile *makeBaseFile() const;
+ virtual Common::BaseFile *makeBaseFile() const;
protected:
POSIXFilesystemFactory() {};
diff --git a/backends/factories/ps2/ps2-fs-factory.cpp b/backends/factories/ps2/ps2-fs-factory.cpp
index cd6f293794..a56f376ec8 100644
--- a/backends/factories/ps2/ps2-fs-factory.cpp
+++ b/backends/factories/ps2/ps2-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/ps2/ps2-fs-factory.h"
#include "backends/fs/ps2/ps2-fs.cpp"
#include "backends/file/ps2/ps2-file.h"
diff --git a/backends/factories/ps2/ps2-fs-factory.h b/backends/factories/ps2/ps2-fs-factory.h
index e1ddee9677..413842789f 100644
--- a/backends/factories/ps2/ps2-fs-factory.h
+++ b/backends/factories/ps2/ps2-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef PS2_FILESYSTEM_FACTORY_H
#define PS2_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/psp/psp-fs-factory.cpp b/backends/factories/psp/psp-fs-factory.cpp
index 9c9bef21e7..0791904d96 100644
--- a/backends/factories/psp/psp-fs-factory.cpp
+++ b/backends/factories/psp/psp-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/psp/psp-fs-factory.h"
#include "backends/fs/psp/psp_fs.cpp"
#include "backends/file/base-file.h"
diff --git a/backends/factories/psp/psp-fs-factory.h b/backends/factories/psp/psp-fs-factory.h
index 0d30efd5ad..10a9bcc711 100644
--- a/backends/factories/psp/psp-fs-factory.h
+++ b/backends/factories/psp/psp-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef PSP_FILESYSTEM_FACTORY_H
#define PSP_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/symbian/symbian-fs-factory.cpp b/backends/factories/symbian/symbian-fs-factory.cpp
index a21b40a095..04fb3195d9 100644
--- a/backends/factories/symbian/symbian-fs-factory.cpp
+++ b/backends/factories/symbian/symbian-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/symbian/symbian-fs-factory.h"
#include "backends/fs/symbian/symbian-fs.cpp"
#include "backends/file/symbian/symbian-file.h"
diff --git a/backends/factories/symbian/symbian-fs-factory.h b/backends/factories/symbian/symbian-fs-factory.h
index 49f92410ce..edf39969d2 100644
--- a/backends/factories/symbian/symbian-fs-factory.h
+++ b/backends/factories/symbian/symbian-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef SYMBIAN_FILESYSTEM_FACTORY_H
#define SYMBIAN_FILESYSTEM_FACTORY_H
diff --git a/backends/factories/windows/windows-fs-factory.cpp b/backends/factories/windows/windows-fs-factory.cpp
index 55c48c3b9c..57976b6ad9 100644
--- a/backends/factories/windows/windows-fs-factory.cpp
+++ b/backends/factories/windows/windows-fs-factory.cpp
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#include "backends/factories/windows/windows-fs-factory.h"
#include "backends/fs/windows/windows-fs.cpp"
#include "backends/file/base-file.h"
diff --git a/backends/factories/windows/windows-fs-factory.h b/backends/factories/windows/windows-fs-factory.h
index 1f85d8f1c3..b1272a6bcb 100644
--- a/backends/factories/windows/windows-fs-factory.h
+++ b/backends/factories/windows/windows-fs-factory.h
@@ -1,3 +1,27 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL: $
+ * $Id: $
+ */
+
#ifndef WINDOWS_FILESYSTEM_FACTORY_H
#define WINDOWS_FILESYSTEM_FACTORY_H
diff --git a/backends/file/base-file.cpp b/backends/file/base-file.cpp
index 3174f5828c..e42f50ce98 100644
--- a/backends/file/base-file.cpp
+++ b/backends/file/base-file.cpp
@@ -37,6 +37,8 @@
#include "CoreFoundation/CoreFoundation.h"
#endif
+namespace Common {
+
BaseFile::BaseFile() {
_handle = 0;
_ioFailed = false;
@@ -224,3 +226,5 @@ long BaseFile::_ftell(FILE *stream) const {
int BaseFile::_fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream) {
return fwrite(ptr, obj_size, count, stream);
}
+
+} // End of namespace Common
diff --git a/backends/file/base-file.h b/backends/file/base-file.h
index f383a1a453..d28655b31e 100644
--- a/backends/file/base-file.h
+++ b/backends/file/base-file.h
@@ -30,12 +30,14 @@
#include "common/str.h"
#include "common/stream.h"
-using namespace Common;
+//using namespace Common;
+
+namespace Common {
/**
* Implements several file related functions used by the Common::File wrapper.
*/
-class BaseFile : public Common::SeekableReadStream {
+class BaseFile : public SeekableReadStream {
protected:
/** File handle to the actual file; 0 if no file is open. */
void *_handle;
@@ -177,4 +179,6 @@ public:
//uint32 write(const void *dataPtr, uint32 dataSize);
};
+} // End of namespace Common
+
#endif //BACKENDS_BASE_FILE_H
diff --git a/backends/file/posix/posix-file.cpp b/backends/file/posix/posix-file.cpp
index 84c82fa5c5..7419161ccd 100644
--- a/backends/file/posix/posix-file.cpp
+++ b/backends/file/posix/posix-file.cpp
@@ -1,5 +1,7 @@
#include "backends/file/posix/posix-file.h"
+namespace Common {
+
POSIXFile::POSIXFile() : BaseFile() {
//
}
@@ -39,3 +41,5 @@ long POSIXFile::_ftell(FILE *stream) const {
int POSIXFile::_fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream) {
return fwrite(ptr, obj_size, count, stream);
}
+
+} // End of namespace Common
diff --git a/backends/file/posix/posix-file.h b/backends/file/posix/posix-file.h
index 00ce307df5..e74338b8d8 100644
--- a/backends/file/posix/posix-file.h
+++ b/backends/file/posix/posix-file.h
@@ -27,6 +27,8 @@
#include "backends/file/base-file.cpp"
+namespace Common {
+
/**
* Implements several POSIX specific file related functions used by the Common::File wrapper.
*
@@ -47,4 +49,6 @@ protected:
int _fwrite(const void * ptr, size_t obj_size, size_t count, FILE * stream);
};
+} // End of namespace Common
+
#endif //BACKENDS_POSIX_FILE_H
diff --git a/backends/fs/abstract-fs.h b/backends/fs/abstract-fs.h
index 85fcbcdebb..e506d96a0b 100644
--- a/backends/fs/abstract-fs.h
+++ b/backends/fs/abstract-fs.h
@@ -79,7 +79,7 @@ public:
virtual ~AbstractFilesystemNode() {}
/*
- * Indicates whether the object refered by this path exists in the filesystem or not.
+ * Indicates whether the object referred by this path exists in the filesystem or not.
*/
virtual bool exists() const = 0;
@@ -103,6 +103,18 @@ public:
virtual String getDisplayName() const { return getName(); }
/**
+ * Returns the last component of a given path.
+ *
+ * Examples:
+ * /foo/bar.txt would return /bar.txt
+ * /foo/bar/ would return /bar/
+ *
+ * @param str String containing the path.
+ * @return Pointer to the first char of the last component inside str.
+ */
+ virtual const char *getLastPathComponent(const Common::String &str) const = 0;
+
+ /**
* Returns a string with an architecture dependent path description.
*/
virtual String getName() const = 0;
@@ -118,12 +130,28 @@ public:
virtual bool isDirectory() const = 0;
/**
- * Indicates whether this path can be read from or not.
+ * Indicates whether the object referred by this path can be read from or not.
+ *
+ * If the path refers to a directory, readability implies being able to read
+ * and list the directory entries.
+ *
+ * If the path refers to a file, readability implies being able to read the
+ * contents of the file.
+ *
+ * @return bool true if the object can be read, false otherwise.
*/
virtual bool isReadable() const = 0;
/**
- * Indicates whether this path can be written to or not.
+ * Indicates whether the object referred by this path can be written to or not.
+ *
+ * If the path refers to a directory, writability implies being able to modify
+ * the directory entry (i.e. rename the directory, remove it or write files inside of it).
+ *
+ * If the path refers to a file, writability implies being able to write data
+ * to the file.
+ *
+ * @return bool true if the object can be written to, false otherwise.
*/
virtual bool isWritable() const = 0;
@@ -132,4 +160,4 @@ public:
*/
};
-#endif
+#endif //BACKENDS_ABSTRACT_FS_H
diff --git a/backends/fs/dc/dc-fs.cpp b/backends/fs/dc/dc-fs.cpp
index e1228c7ff2..6554544c7f 100644
--- a/backends/fs/dc/dc-fs.cpp
+++ b/backends/fs/dc/dc-fs.cpp
@@ -32,7 +32,7 @@
#include <unistd.h>
/**
- * Implementation of the ScummVM file system API based on POSIX.
+ * Implementation of the ScummVM file system API based on Ronin.
*
* Parts of this class are documented in the base interface class, AbstractFilesystemNode.
*/
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp
index 3708acd2a8..9fd5b8a185 100644
--- a/backends/fs/posix/posix-fs.cpp
+++ b/backends/fs/posix/posix-fs.cpp
@@ -64,6 +64,7 @@ public:
virtual bool exists() const { return access(_path.c_str(), F_OK) == 0; }
virtual String getDisplayName() const { return _displayName; }
+ virtual const char *getLastPathComponent(const Common::String &str) const;
virtual String getName() const { return _displayName; }
virtual String getPath() const { return _path; }
virtual bool isDirectory() const { return _isDirectory; }
@@ -81,27 +82,6 @@ private:
virtual void setFlags();
};
-/**
- * Returns the last component of a given path.
- *
- * Examples:
- * /foo/bar.txt would return /bar.txt
- * /foo/bar/ would return /bar/
- *
- * @param str String containing the path.
- * @return Pointer to the first char of the last component inside str.
- */
-static const char *lastPathComponent(const Common::String &str) {
- const char *start = str.c_str();
- const char *cur = start + str.size() - 2;
-
- while (cur >= start && *cur != '/') {
- --cur;
- }
-
- return cur + 1;
-}
-
void POSIXFilesystemNode::setFlags() {
struct stat st;
@@ -142,7 +122,7 @@ POSIXFilesystemNode::POSIXFilesystemNode(const String &p, bool verify) {
assert(p.size() > 0);
_path = p;
- _displayName = lastPathComponent(_path);
+ _displayName = getLastPathComponent(_path);
if (verify) {
setFlags();
@@ -236,12 +216,23 @@ bool POSIXFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, boo
return true;
}
+const char *POSIXFilesystemNode::getLastPathComponent(const Common::String &str) const {
+ const char *start = str.c_str();
+ const char *cur = start + str.size() - 2;
+
+ while (cur >= start && *cur != '/') {
+ --cur;
+ }
+
+ return cur + 1;
+}
+
AbstractFilesystemNode *POSIXFilesystemNode::getParent() const {
if (_path == "/")
return 0;
const char *start = _path.c_str();
- const char *end = lastPathComponent(_path);
+ const char *end = getLastPathComponent(_path);
return new POSIXFilesystemNode(String(start, end - start), true);
}
diff --git a/common/file.cpp b/common/file.cpp
index 30ac870f05..e70a9328cb 100644
--- a/common/file.cpp
+++ b/common/file.cpp
@@ -24,14 +24,10 @@
*/
#include "common/file.h"
-#include "common/fs.h"
#include "common/hashmap.h"
#include "common/util.h"
#include "common/hash-str.h"
-
-#if defined(UNIX) || defined(__SYMBIAN32__)
#include <errno.h>
-#endif
#ifdef MACOSX
#include "CoreFoundation/CoreFoundation.h"
diff --git a/common/file.h b/common/file.h
index c18776a377..19b1d45144 100644
--- a/common/file.h
+++ b/common/file.h
@@ -30,6 +30,9 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "common/stream.h"
+#include "common/fs.h"
+#include "backends/file/base-file.h"
+//#include "backends/factories/fs-factory-maker.h"
class FilesystemNode;
@@ -38,7 +41,7 @@ namespace Common {
class File : public SeekableReadStream, public WriteStream {
protected:
/** File handle to the actual file; 0 if no file is open. */
- //BaseFile *_test;
+ BaseFile *_test;
/** File handle to the actual file; 0 if no file is open. */
void *_handle;
diff --git a/common/fs.cpp b/common/fs.cpp
index 40d9e4de14..442e3ed4d7 100644
--- a/common/fs.cpp
+++ b/common/fs.cpp
@@ -24,6 +24,7 @@
#include "common/stdafx.h"
#include "common/util.h"
+#include "common/fs.h"
#include "backends/fs/abstract-fs.h"
#include "backends/factories/fs-factory-maker.cpp"
@@ -107,12 +108,13 @@ FilesystemNode &FilesystemNode::operator= (const FilesystemNode &node) {
return *this;
}
-bool FilesystemNode::operator< (const FilesystemNode& node) const
+bool FilesystemNode::operator<(const FilesystemNode& node) const
{
if (isDirectory() && !node.isDirectory())
return true;
if (!isDirectory() && node.isDirectory())
return false;
+
return scumm_stricmp(getDisplayName().c_str(), node.getDisplayName().c_str()) < 0;
}
@@ -130,6 +132,7 @@ void FilesystemNode::decRefCount() {
bool FilesystemNode::exists() const {
if (_realNode == 0)
return false;
+
return _realNode->exists();
}
@@ -189,62 +192,78 @@ Common::String FilesystemNode::getPath() const {
bool FilesystemNode::isDirectory() const {
if (_realNode == 0)
return false;
+
return _realNode->isDirectory();
}
bool FilesystemNode::isReadable() const {
if (_realNode == 0)
return false;
+
return _realNode->isReadable();
}
bool FilesystemNode::isWritable() const {
if (_realNode == 0)
return false;
+
return _realNode->isWritable();
}
bool FilesystemNode::lookupFile(FSList &results, FSList &fslist, Common::String &filename, bool hidden, bool exhaustive) const
{
- for(FSList::iterator entry = fslist.begin(); entry != fslist.end(); ++entry)
- {
- if(entry->isDirectory()) {
- lookupFileRec(results, *entry, filename, hidden, exhaustive);
+ int matches = 0;
+
+ for (FSList::iterator entry = fslist.begin(); entry != fslist.end(); ++entry) {
+ if (entry->isDirectory()) {
+ matches += lookupFileRec(results, *entry, filename, hidden, exhaustive);
}
}
-
- //TODO: we would return true even if no matches were found, if the initial results list isn't empty
- return ((results.size() > 0) ? true : false);
+
+ return ((matches > 0) ? true : false);
}
bool FilesystemNode::lookupFile(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
{
- lookupFileRec(results, dir, filename, hidden, exhaustive);
+ int matches;
+
+ if (!dir.isDirectory())
+ return false;
+
+ matches = lookupFileRec(results, dir, filename, hidden, exhaustive);
- //TODO: we would return true even if no matches were found, if the initial results list isn't empty
- return ((results.size() > 0) ? true : false);
+ return ((matches > 0) ? true : false);
}
-void FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
+int FilesystemNode::lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const
{
FSList entries;
+ FSList children;
+ int matches = 0;
dir.getChildren(entries, FilesystemNode::kListAll, hidden);
- for(FSList::iterator entry = entries.begin(); entry != entries.end(); ++entry)
- {
- if(entry->isDirectory()) {
- lookupFileRec(results, *entry, filename, hidden, exhaustive);
+ //Breadth search (entries in the same level)
+ for (FSList::iterator entry = entries.begin(); entry != entries.end(); ++entry) {
+ if (entry->isDirectory()) {
+ children.push_back(*entry);
} else {
//TODO: here we assume all backends implement the lastPathComponent method. It is currently static,
// so it might be a good idea to include it inside the backend class. This would enforce its
// implementation by all ports.
- if(matchString(lastPathComponent(entry->getPath()), filename.c_str())) {
+ if(matchString(_realNode->getLastPathComponent(entry->getPath()), filename.c_str())) {
results.push_back(*entry);
+ matches++;
- if(!exhaustive) {
+ if (!exhaustive)
break;
- }
}
}
}
+
+ //Depth search (entries in lower levels)
+ for (FSList::iterator child = children.begin(); child != children.end(); ++child) {
+ matches += lookupFileRec(results, *child, filename, hidden, exhaustive);
+ }
+
+ return matches;
}
diff --git a/common/fs.h b/common/fs.h
index 6a2f049be1..7f634791d6 100644
--- a/common/fs.h
+++ b/common/fs.h
@@ -62,6 +62,8 @@ class FSList : public Common::Array<FilesystemNode> {};
* paths (MacOS 9 doesn't even have the notion of a "current directory").
* And if we ever want to support devices with no FS in the classical sense (Palm...),
* we can build upon this.
+ *
+ * This class acts as a wrapper around the AbstractFilesystemNode class defined in backends/fs.
*/
class FilesystemNode {
private:
@@ -80,9 +82,9 @@ public:
};
/**
- * Create a new invalid FilesystemNode. In other words, isValid() for that
- * node returns false, and if you try to get it's path, an assert is
- * triggered.
+ * Create a new pathless FilesystemNode. Since there's no path associated
+ * with this node, path-related operations (i.e. exists(), isDirectory(),
+ * getPath()) will always return false or raise an assertion.
*/
FilesystemNode();
@@ -116,10 +118,12 @@ public:
* Compare the name of this node to the name of another. Directories
* go before normal files.
*/
- bool operator< (const FilesystemNode& node) const;
+ bool operator<(const FilesystemNode& node) const;
/*
- * Indicates whether the object refered by this path exists in the filesystem or not.
+ * Indicates whether the object referred by this path exists in the filesystem or not.
+ *
+ * @return bool true if the path exists, false otherwise.
*/
virtual bool exists() const;
@@ -177,34 +181,53 @@ public:
FilesystemNode getParent() const;
/**
- * Indicates whether this path refers to a directory or not.
+ * Indicates whether the path refers to a directory or not.
*
- * @todo Currently we assume that a valid node that is not a directory
- * automatically is a file (ignoring things like symlinks). That might
- * actually be OK... but we could still add an isFile method. Or even replace
- * isValid and isDirectory by a getType() method that can return values like
+ * @todo Currently we assume that a node that is not a directory
+ * automatically is a file (ignoring things like symlinks or pipes).
+ * That might actually be OK... but we could still add an isFile method.
+ * Or even replace isDirectory by a getType() method that can return values like
* kDirNodeType, kFileNodeType, kInvalidNodeType.
*/
virtual bool isDirectory() const;
/**
- * Indicates whether this path can be read from or not.
+ * Indicates whether the object referred by this path can be read from or not.
+ *
+ * If the path refers to a directory, readability implies being able to read
+ * and list the directory entries.
+ *
+ * If the path refers to a file, readability implies being able to read the
+ * contents of the file.
+ *
+ * @return bool true if the object can be read, false otherwise.
*/
virtual bool isReadable() const;
/**
- * Indicates whether this path can be written to or not.
+ * Indicates whether the object referred by this path can be written to or not.
+ *
+ * If the path refers to a directory, writability implies being able to modify
+ * the directory entry (i.e. rename the directory, remove it or write files inside of it).
+ *
+ * If the path refers to a file, writability implies being able to write data
+ * to the file.
+ *
+ * @return bool true if the object can be written to, false otherwise.
*/
virtual bool isWritable() const;
/**
* Searches recursively for a filename inside the given directories.
*
+ * For each directory in the directory list a breadth-first search is performed,
+ * that is, the current directory entries are scanned before going into subdirectories.
+ *
* @param results List to put the matches in.
* @param fslist List of directories to search within.
* @param filename Name of the file to look for.
- * @param hidden Whether to search hidden files or not. Default: false
- * @param exhaustive Whether to continue searching after one match has been found. Default: false
+ * @param hidden Whether to search hidden files or not.
+ * @param exhaustive Whether to continue searching after one match has been found.
*
* @return true if matches could be found, false otherwise.
*/
@@ -213,11 +236,14 @@ public:
/**
* Searches recursively for a filename inside the given directory.
*
+ * The search is performed breadth-first, that is, the current directory entries
+ * are scanned before going into subdirectories.
+ *
* @param results List to put the matches in.
* @param FilesystemNode Directory to search within.
* @param filename Name of the file to look for.
- * @param hidden Whether to search hidden files or not. Default: false
- * @param exhaustive Whether to continue searching after one match has been found. Default: false
+ * @param hidden Whether to search hidden files or not.
+ * @param exhaustive Whether to continue searching after one match has been found.
*
* @return true if matches could be found, false otherwise.
*/
@@ -233,13 +259,18 @@ protected:
/**
* Searches recursively for a filename inside the given directory.
*
+ * The search is performed breadth-first, that is, the current directory entries
+ * are scanned before going into subdirectories.
+ *
* @param results List to put the matches in.
* @param FilesystemNode Directory to search within.
* @param filename Name of the file to look for.
* @param hidden Whether to search hidden files or not.
* @param exhaustive Whether to continue searching after one match has been found.
+ *
+ * @return The number of matches found.
*/
- void lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const;
+ int lookupFileRec(FSList &results, FilesystemNode &dir, Common::String &filename, bool hidden, bool exhaustive) const;
};
//} // End of namespace Common