aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/file
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
committerEinar Johan Trøan Sømåen2012-07-26 15:59:26 +0200
commitef11f9d0c53cbdd9d88a99143de6f43f34d7e24d (patch)
tree8dfaee0ba16e18a8e3772dd5afc9123d5c4e78d2 /engines/wintermute/base/file
parent38507fa9895620639d8733dbb4e085dfb2282a33 (diff)
downloadscummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.gz
scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.tar.bz2
scummvm-rg350-ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d.zip
WINTERMUTE: Run Astyle with add-braces to break one-line statements into easier-to-read-code.
Diffstat (limited to 'engines/wintermute/base/file')
-rw-r--r--engines/wintermute/base/file/base_disk_file.cpp11
-rw-r--r--engines/wintermute/base/file/base_file_entry.cpp4
-rw-r--r--engines/wintermute/base/file/base_package.cpp18
-rw-r--r--engines/wintermute/base/file/base_save_thumb_file.cpp27
4 files changed, 44 insertions, 16 deletions
diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp
index bb8504d2f4..7d805aedb5 100644
--- a/engines/wintermute/base/file/base_disk_file.cpp
+++ b/engines/wintermute/base/file/base_disk_file.cpp
@@ -41,7 +41,9 @@ namespace WinterMute {
void correctSlashes(char *fileName) {
for (size_t i = 0; i < strlen(fileName); i++) {
- if (fileName[i] == '\\') fileName[i] = '/';
+ if (fileName[i] == '\\') {
+ fileName[i] = '/';
+ }
}
}
@@ -51,8 +53,9 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) {
// specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen)
// Absolute path: TODO: Add specific fallbacks here.
- if (filename.contains(':'))
+ if (filename.contains(':')) {
error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str());
+ }
// Relative path:
if (filename.contains('\\')) {
@@ -132,7 +135,9 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) {
magic2 = file->readUint32LE();
bool compressed = false;
- if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true;
+ if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) {
+ compressed = true;
+ }
if (compressed) {
uint32 dataOffset, compSize, uncompSize;
diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp
index 8282079c86..7bf635b858 100644
--- a/engines/wintermute/base/file/base_file_entry.cpp
+++ b/engines/wintermute/base/file/base_file_entry.cpp
@@ -61,7 +61,9 @@ public:
Common::SeekableReadStream *BaseFileEntry::createReadStream() const {
Common::SeekableReadStream *file = _package->getFilePointer();
- if (!file) return NULL;
+ if (!file) {
+ return NULL;
+ }
// TODO: Cleanup
bool compressed = (_compressedLength != 0);
diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp
index f2d2378c6a..b41ae3c1bd 100644
--- a/engines/wintermute/base/file/base_package.cpp
+++ b/engines/wintermute/base/file/base_package.cpp
@@ -64,7 +64,9 @@ static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset)
uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead);
f->seek((int32)startPos, SEEK_SET);
uint32 actuallyRead = f->read(buf, toRead);
- if (actuallyRead != toRead) return false;
+ if (actuallyRead != toRead) {
+ return false;
+ }
for (uint32 i = 0; i < toRead - 8; i++)
if (!memcmp(buf + i, signature, 8)) {
@@ -85,8 +87,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool
_priority = 0;
bool boundToExe = false;
Common::SeekableReadStream *stream = file.createReadStream();
- if (!stream)
+ if (!stream) {
return;
+ }
if (searchSignature) {
uint32 offset;
if (!findPackageSignature(stream, &offset)) {
@@ -121,7 +124,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool
assert(hdr._numDirs == 1);
for (uint32 i = 0; i < hdr._numDirs; i++) {
BasePackage *pkg = new BasePackage();
- if (!pkg) return;
+ if (!pkg) {
+ return;
+ }
pkg->_fsnode = file;
pkg->_boundToExe = boundToExe;
@@ -136,7 +141,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool
delete[] pkgName;
pkgName = NULL;
- if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk
+ if (!hdr._masterIndex) {
+ pkg->_cd = 0; // override CD to fixed disk
+ }
_packages.push_back(pkg);
// read file entries
@@ -242,8 +249,9 @@ Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common::
upcName.toUppercase();
Common::HashMap<Common::String, Common::ArchiveMemberPtr>::const_iterator it;
it = _files.find(upcName.c_str());
- if (it != _files.end())
+ if (it != _files.end()) {
return it->_value->createReadStream();
+ }
return NULL;
}
diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp
index 0a0d0cac09..e067241589 100644
--- a/engines/wintermute/base/file/base_save_thumb_file.cpp
+++ b/engines/wintermute/base/file/base_save_thumb_file.cpp
@@ -53,7 +53,9 @@ BaseSaveThumbFile::~BaseSaveThumbFile() {
bool BaseSaveThumbFile::open(const Common::String &filename) {
close();
- if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED;
+ if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) {
+ return STATUS_FAILED;
+ }
char *tempFilename = new char[strlen(filename.c_str()) - 8];
strcpy(tempFilename, filename.c_str() + 9);
@@ -70,7 +72,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) {
BasePersistenceManager *pm = new BasePersistenceManager(_gameRef);
Common::String slotFilename = pm->getFilenameForSlot(slot);
- if (!pm) return STATUS_FAILED;
+ if (!pm) {
+ return STATUS_FAILED;
+ }
if (DID_FAIL(pm->initLoad(slotFilename))) {
delete pm;
@@ -84,7 +88,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) {
memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize);
_size = pm->_thumbnailDataSize;
res = STATUS_OK;
- } else res = STATUS_FAILED;
+ } else {
+ res = STATUS_FAILED;
+ }
delete pm;
return res;
@@ -105,7 +111,9 @@ bool BaseSaveThumbFile::close() {
//////////////////////////////////////////////////////////////////////////
bool BaseSaveThumbFile::read(void *buffer, uint32 size) {
- if (!_data || _pos + size > _size) return STATUS_FAILED;
+ if (!_data || _pos + size > _size) {
+ return STATUS_FAILED;
+ }
memcpy(buffer, (byte *)_data + _pos, size);
_pos += size;
@@ -116,7 +124,9 @@ bool BaseSaveThumbFile::read(void *buffer, uint32 size) {
//////////////////////////////////////////////////////////////////////////
bool BaseSaveThumbFile::seek(uint32 pos, int whence) {
- if (!_data) return STATUS_FAILED;
+ if (!_data) {
+ return STATUS_FAILED;
+ }
uint32 newPos = 0;
@@ -132,8 +142,11 @@ bool BaseSaveThumbFile::seek(uint32 pos, int whence) {
break;
}
- if (newPos > _size) return STATUS_FAILED;
- else _pos = newPos;
+ if (newPos > _size) {
+ return STATUS_FAILED;
+ } else {
+ _pos = newPos;
+ }
return STATUS_OK;
}