aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorTobia Tesan2016-02-29 15:00:15 +0100
committerTobia Tesan2016-03-01 20:40:45 +0100
commit63e6473467700395725c893ff24b0e3926dac451 (patch)
tree79ba026002c0b6d458a3231416d3aeb4b17e2c58 /engines
parentcf3887d1d26bb9f4352982989c355a4265d08888 (diff)
downloadscummvm-rg350-63e6473467700395725c893ff24b0e3926dac451.tar.gz
scummvm-rg350-63e6473467700395725c893ff24b0e3926dac451.tar.bz2
scummvm-rg350-63e6473467700395725c893ff24b0e3926dac451.zip
WINTERMUTE: Add BasicSourceListingProvider class
Diffstat (limited to 'engines')
-rw-r--r--engines/wintermute/debugger/listing_providers/basic_source_listing_provider.cpp92
-rw-r--r--engines/wintermute/debugger/listing_providers/basic_source_listing_provider.h44
-rw-r--r--engines/wintermute/module.mk1
3 files changed, 137 insertions, 0 deletions
diff --git a/engines/wintermute/debugger/listing_providers/basic_source_listing_provider.cpp b/engines/wintermute/debugger/listing_providers/basic_source_listing_provider.cpp
new file mode 100644
index 0000000000..30d29ee23e
--- /dev/null
+++ b/engines/wintermute/debugger/listing_providers/basic_source_listing_provider.cpp
@@ -0,0 +1,92 @@
+/* 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.
+ *
+ */
+
+#include "basic_source_listing_provider.h"
+#include "engines/wintermute/base/base_file_manager.h"
+
+namespace Wintermute {
+BasicSourceListingProvider::BasicSourceListingProvider() : _fsDirectory(nullptr) {
+}
+
+BasicSourceListingProvider::~BasicSourceListingProvider() {
+}
+
+SourceListing *BasicSourceListingProvider::getListing(const Common::String &filename, ErrorCode &_err) {
+ _err = OK;
+ if (!_fsDirectory) {
+ _err = SOURCE_PATH_NOT_SET;
+ return nullptr;
+ };
+
+ Common::String unixFilename;
+
+ for (uint i = 0; i < filename.size(); i++) {
+ if (filename[i] == '\\') {
+ unixFilename.insertChar('/', unixFilename.size());
+ } else {
+ unixFilename.insertChar(filename[i], unixFilename.size());
+ }
+ }
+
+ Common::SeekableReadStream *file = _fsDirectory->createReadStreamForMember(unixFilename);
+ Common::Array<Common::String> strings;
+
+ if (!file) {
+ _err = NO_SUCH_SOURCE;
+ } else {
+ if (file->err()) {
+ _err = UNKNOWN_ERROR;
+ }
+ while (!file->eos()) {
+ strings.push_back(file->readLine());
+ if (file->err()) {
+ _err = UNKNOWN_ERROR;
+ }
+ }
+ }
+
+ if (_err == OK) {
+ return new SourceListing(strings);
+ } else {
+ return nullptr;
+ }
+}
+
+ErrorCode BasicSourceListingProvider::setPath(const Common::String &path) {
+ if (path == "")
+ return ILLEGAL_PATH;
+ delete _fsDirectory;
+ Common::FSNode node(path);
+ if (node.exists() && node.isDirectory()) {
+ _fsDirectory = new Common::FSDirectory(node, 64);
+ return OK;
+ } else {
+ return COULD_NOT_OPEN;
+ }
+}
+
+Common::String BasicSourceListingProvider::getPath() const {
+ if (!_fsDirectory) return "";
+ return _fsDirectory->getFSNode().getPath();
+}
+
+}
diff --git a/engines/wintermute/debugger/listing_providers/basic_source_listing_provider.h b/engines/wintermute/debugger/listing_providers/basic_source_listing_provider.h
new file mode 100644
index 0000000000..e242205578
--- /dev/null
+++ b/engines/wintermute/debugger/listing_providers/basic_source_listing_provider.h
@@ -0,0 +1,44 @@
+/* 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.
+ *
+ */
+
+#ifndef BASIC_SOURCE_LISTING_PROVIDER_H_
+#define BASIC_SOURCE_LISTING_PROVIDER_H_
+
+#include "engines/wintermute/debugger/listing_provider.h"
+#include "source_listing_provider.h"
+#include "source_listing.h"
+#include "common/fs.h"
+
+namespace Wintermute {
+
+class BasicSourceListingProvider : public SourceListingProvider {
+ Common::FSDirectory *_fsDirectory;
+public:
+ BasicSourceListingProvider();
+ virtual ~BasicSourceListingProvider();
+ SourceListing *getListing(const Common::String &filename, ErrorCode &err);
+ ErrorCode setPath(const Common::String &path);
+ Common::String getPath() const;
+};
+
+}
+#endif /* BASIC_SOURCE_LISTING_PROVIDER_H_ */
diff --git a/engines/wintermute/module.mk b/engines/wintermute/module.mk
index 24a8ae2bcf..1947a3f20b 100644
--- a/engines/wintermute/module.mk
+++ b/engines/wintermute/module.mk
@@ -95,6 +95,7 @@ MODULE_OBJS := \
debugger/error.o \
debugger/listing_providers/blank_listing.o \
debugger/listing_providers/blank_listing_provider.o \
+ debugger/listing_providers/basic_source_listing_provider.o \
debugger/listing_providers/source_listing.o \
debugger/listing.o \
debugger/script_monitor.o \