#include "fsCResourceNamePathAdjuster.h"
#include <Corrade/Utility/Directory.h>
#include <fsCore/src/fsCAppSettings.h>
#include <fsCore/fsIHardware.h>
#include <fsCore/fsIFile.h>
//#if defined fsPlayStore
// #include <fsCommerce/impl/marmalade/google/fsCExpansionFile.h>
//#endif
void fsCResourceNamePathAdjuster::savedDataFolderCreateDo() const
{
fsIFile::systemFolderCreate(savedDataFullFolderPathGet());
}
fsStr fsCResourceNamePathAdjuster::savedDataFullFolderPathGet() const<--- The member function 'fsCResourceNamePathAdjuster::savedDataFullFolderPathGet' can be static.
{
return mHardware->appDataFolderGet() + savedDataFolderGet();
}
void fsCResourceNamePathAdjuster::savedDataPathAdjustDo(fsStr& pPath,
fsCResourceName::eResourceLocation pLocation) const
{
if (pLocation == fsCResourceName::eRES_LOCATION_USER_SETTINGS)
{
pPath = savedDataFullFolderPathGet() + pPath;
}
}
void fsCResourceNamePathAdjuster::audioExtensionAdjustDo(fsStr& pPath,
fsCResourceName::eResourceLocation pLocation) const
{
if (fsStr::npos != pPath.rfind(".wav"))
{
pPath.eraseFromLast(".");
pPath += ".mp3";
}
}
void fsCResourceNamePathAdjuster::pathAdjustDo(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const
{
if (fsStr::npos == pPath.find("c:"))
{
pPath.replaceAll("\\", mPathSeparator);
if (pLocation == fsCResourceName::eRES_LOCATION_ASSETS)
{
// "resources" alone isn't a reliable "already adjusted?" check on its own: this
// function inserts a capitalised "Resources" segment below, and (before this fix)
// never downcased the result, so a path already run through here once - now
// containing ".../Resources/..." - would fail this same lowercase check on a second
// pass and get the current-directory + "Resources" prefix prepended again, doubling
// the path. The explicit "/users/" check (matching raylib's equivalent) and the
// downcase() below (also matching raylib) together make this idempotent.
if (pPath.find("/users/") == fsStr::npos && pPath.find("resources") == fsStr::npos)
{
pPath = fsStr(Corrade::Utility::Directory::current().c_str()) +
mPathSeparator + "Resources" + mPathSeparator + pPath;
}
}
pPath.downcase();
}
}
fsCResourceNamePathAdjuster::fsCResourceNamePathAdjuster()
{
}
fsCResourceNamePathAdjuster::~fsCResourceNamePathAdjuster()
{
}