2010-07-31 08:34:16 +00:00
|
|
|
/* 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.
|
2014-02-18 01:34:25 +00:00
|
|
|
*
|
2010-07-31 08:34:16 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:25 +00:00
|
|
|
*
|
2010-07-31 08:34:16 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2010-07-29 19:53:02 +00:00
|
|
|
|
2010-08-06 13:13:25 +00:00
|
|
|
/*
|
2010-07-31 09:53:02 +00:00
|
|
|
* This code is based on Broken Sword 2.5 engine
|
|
|
|
*
|
|
|
|
* Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
|
|
|
|
*
|
|
|
|
* Licensed under GNU GPL v2
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-30 09:02:39 +00:00
|
|
|
#include "sword25/kernel/resource.h"
|
|
|
|
#include "sword25/kernel/kernel.h"
|
|
|
|
#include "sword25/package/packagemanager.h"
|
2010-07-29 19:53:02 +00:00
|
|
|
|
2010-07-31 08:34:16 +00:00
|
|
|
namespace Sword25 {
|
|
|
|
|
2010-09-02 17:11:45 +00:00
|
|
|
Resource::Resource(const Common::String &fileName, RESOURCE_TYPES type) :
|
|
|
|
_type(type),
|
|
|
|
_refCount(0) {
|
2010-10-19 21:03:33 +00:00
|
|
|
PackageManager *pPM = Kernel::getInstance()->getPackage();
|
2011-01-23 15:01:24 +00:00
|
|
|
assert(pPM);
|
2010-07-29 19:53:02 +00:00
|
|
|
|
2010-10-15 12:18:19 +00:00
|
|
|
_fileName = pPM->getAbsolutePath(fileName);
|
2010-07-30 12:19:13 +00:00
|
|
|
}
|
2010-07-29 19:53:02 +00:00
|
|
|
|
2010-09-02 17:11:45 +00:00
|
|
|
void Resource::release() {
|
|
|
|
if (_refCount) {
|
|
|
|
--_refCount;
|
2010-07-31 08:34:16 +00:00
|
|
|
} else
|
2011-01-23 14:49:50 +00:00
|
|
|
warning("Released unlocked resource \"%s\".", _fileName.c_str());
|
2010-07-29 19:53:02 +00:00
|
|
|
}
|
2010-07-31 08:34:16 +00:00
|
|
|
|
|
|
|
} // End of namespace Sword25
|