1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 /*
24 * This file is based on WME Lite.
25 * http://dead-code.org/redir.php?target=wmelite
26 * Copyright (c) 2011 Jan Nedoma
27 */
28
29 #include "engines/wintermute/base/file/base_file_entry.h"
30 #include "engines/wintermute/base/file/base_package.h"
31 #include "common/stream.h"
32 #include "common/substream.h"
33 #include "common/zlib.h"
34
35 namespace Wintermute {
36
createReadStream() const37 Common::SeekableReadStream *BaseFileEntry::createReadStream() const {
38 Common::SeekableReadStream *file = _package->getFilePointer();
39 if (!file) {
40 return nullptr;
41 }
42
43 bool compressed = (_compressedLength != 0);
44
45 if (compressed) {
46 file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); //
47 } else {
48 file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES);
49 }
50
51 file->seek(0);
52
53 return file;
54 }
55
56 //////////////////////////////////////////////////////////////////////////
BaseFileEntry()57 BaseFileEntry::BaseFileEntry() {
58 _package = nullptr;
59 _length = _compressedLength = _offset = _flags = 0;
60 _filename = "";
61
62 _timeDate1 = _timeDate2 = 0;
63
64 _journalTime = 0;
65 }
66
67
68 //////////////////////////////////////////////////////////////////////////
~BaseFileEntry()69 BaseFileEntry::~BaseFileEntry() {
70 _package = nullptr; // ref only
71 }
72
73 } // End of namespace Wintermute
74