mirror of https://github.com/axmolengine/axmol.git
Adds const in FileUtils
`const` was missing in some getters Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
This commit is contained in:
parent
2d2e15d275
commit
028deae846
|
@ -76,7 +76,7 @@ bool FileUtilsAndroid::init()
|
|||
return FileUtils::init();
|
||||
}
|
||||
|
||||
bool FileUtilsAndroid::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsAndroid::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
if (0 == strFilePath.length())
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ bool FileUtilsAndroid::isFileExist(const std::string& strFilePath)
|
|||
return bFound;
|
||||
}
|
||||
|
||||
bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath)
|
||||
bool FileUtilsAndroid::isAbsolutePath(const std::string& strPath) const
|
||||
{
|
||||
// On Android, there are two situations for full path.
|
||||
// 1) Files in APK, e.g. assets/path/path/file.png
|
||||
|
@ -235,7 +235,7 @@ unsigned char* FileUtilsAndroid::doGetFileData(const char* filename, const char*
|
|||
return pData;
|
||||
}
|
||||
|
||||
string FileUtilsAndroid::getWritablePath()
|
||||
string FileUtilsAndroid::getWritablePath() const
|
||||
{
|
||||
// Fix for Nexus 10 (Android 4.2 multi-user environment)
|
||||
// the path is retrieved through Java Context.getCacheDir() method
|
||||
|
|
|
@ -52,9 +52,10 @@ public:
|
|||
/* override funtions */
|
||||
bool init();
|
||||
virtual unsigned char* getFileData(const char* filename, const char* pszMode, unsigned long * pSize);
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
virtual bool isAbsolutePath(const std::string& strPath);
|
||||
|
||||
virtual std::string getWritablePath() const;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const;
|
||||
virtual bool isAbsolutePath(const std::string& strPath) const;
|
||||
|
||||
/** This function is android specific. It is used for TextureCache::addImageAsync().
|
||||
Don't use it in your codes.
|
||||
|
|
|
@ -42,14 +42,14 @@ class CC_DLL FileUtilsApple : public FileUtils
|
|||
{
|
||||
public:
|
||||
/* override funtions */
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename);
|
||||
virtual std::string getWritablePath() const override;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const override;
|
||||
virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) override;
|
||||
|
||||
virtual Dictionary* createDictionaryWithContentsOfFile(const std::string& filename);
|
||||
virtual bool writeToFile(Dictionary *dict, const std::string& fullPath);
|
||||
virtual Dictionary* createDictionaryWithContentsOfFile(const std::string& filename) override;
|
||||
virtual bool writeToFile(Dictionary *dict, const std::string& fullPath) override;
|
||||
|
||||
virtual Array* createArrayWithContentsOfFile(const std::string& filename);
|
||||
virtual Array* createArrayWithContentsOfFile(const std::string& filename) override;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -230,7 +230,7 @@ FileUtils* FileUtils::getInstance()
|
|||
}
|
||||
|
||||
|
||||
std::string FileUtilsApple::getWritablePath()
|
||||
std::string FileUtilsApple::getWritablePath() const
|
||||
{
|
||||
// save to document folder
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
|
@ -240,7 +240,7 @@ std::string FileUtilsApple::getWritablePath()
|
|||
return strRet;
|
||||
}
|
||||
|
||||
bool FileUtilsApple::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsApple::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
if(strFilePath.length() == 0)
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string
|
|||
|
||||
Dictionary* FileUtilsApple::createDictionaryWithContentsOfFile(const std::string& filename)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
|
||||
std::string fullPath = fullPathForFilename(filename);
|
||||
NSString* pPath = [NSString stringWithUTF8String:fullPath.c_str()];
|
||||
NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath];
|
||||
|
||||
|
@ -351,7 +351,7 @@ Array* FileUtilsApple::createArrayWithContentsOfFile(const std::string& filename
|
|||
// pPath = [pPath stringByDeletingPathExtension];
|
||||
// pPath = [[NSBundle mainBundle] pathForResource:pPath ofType:pathExtension];
|
||||
// fixing cannot read data using Array::createWithContentsOfFile
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(filename.c_str());
|
||||
std::string fullPath = fullPathForFilename(filename);
|
||||
NSString* path = [NSString stringWithUTF8String:fullPath.c_str()];
|
||||
NSArray* array = [NSArray arrayWithContentsOfFile:path];
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ bool FileUtilsEmscripten::init()
|
|||
return FileUtils::init();
|
||||
}
|
||||
|
||||
string FileUtilsEmscripten::getWritablePath()
|
||||
string FileUtilsEmscripten::getWritablePath() const
|
||||
{
|
||||
// Let's write it in the current working directory's data folder
|
||||
char cwd[FILENAME_MAX] = {0};
|
||||
|
@ -47,7 +47,7 @@ string FileUtilsEmscripten::getWritablePath()
|
|||
return path;
|
||||
}
|
||||
|
||||
bool FileUtilsEmscripten::isAbsolutePath(const std::string& strPath)
|
||||
bool FileUtilsEmscripten::isAbsolutePath(const std::string& strPath) const
|
||||
{
|
||||
if (strPath[0] == '/' || strPath.find(_defaultResRootPath) == 0)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ bool FileUtilsEmscripten::isAbsolutePath(const std::string& strPath)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool FileUtilsEmscripten::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsEmscripten::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
std::string strPath = strFilePath;
|
||||
if (strPath[0] != '/')
|
||||
|
|
|
@ -42,12 +42,13 @@ class CC_DLL FileUtilsEmscripten : public FileUtils
|
|||
{
|
||||
friend class FileUtils;
|
||||
FileUtilsEmscripten();
|
||||
|
||||
public:
|
||||
/* override funtions */
|
||||
bool init();
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
virtual bool isAbsolutePath(const std::string& strPath);
|
||||
virtual std::string getWritablePath() const;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const;
|
||||
virtual bool isAbsolutePath(const std::string& strPath) const;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -67,7 +67,7 @@ bool FileUtilsLinux::init()
|
|||
return FileUtils::init();
|
||||
}
|
||||
|
||||
string FileUtilsLinux::getWritablePath()
|
||||
string FileUtilsLinux::getWritablePath() const
|
||||
{
|
||||
struct stat st;
|
||||
stat(_writablePath.c_str(), &st);
|
||||
|
@ -78,7 +78,7 @@ string FileUtilsLinux::getWritablePath()
|
|||
return _writablePath;
|
||||
}
|
||||
|
||||
bool FileUtilsLinux::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsLinux::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
if (0 == strFilePath.length())
|
||||
{
|
||||
|
|
|
@ -46,8 +46,8 @@ class CC_DLL FileUtilsLinux : public FileUtils
|
|||
public:
|
||||
/* override funtions */
|
||||
bool init();
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
virtual std::string getWritablePath() const;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -84,7 +84,7 @@ FileUtilsQt5::init()
|
|||
}
|
||||
|
||||
std::string
|
||||
FileUtilsQt5::getWritablePath()
|
||||
FileUtilsQt5::getWritablePath() const
|
||||
{
|
||||
QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
|
||||
|
||||
|
@ -96,7 +96,7 @@ FileUtilsQt5::getWritablePath()
|
|||
return dir.path().toStdString();
|
||||
}
|
||||
|
||||
bool FileUtilsQt5::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsQt5::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
QString filePath = QString::fromStdString(strFilePath);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ bool FileUtilsTizen::init()
|
|||
return FileUtils::init();
|
||||
}
|
||||
|
||||
string FileUtilsTizen::getWritablePath()
|
||||
string FileUtilsTizen::getWritablePath() const
|
||||
{
|
||||
UiApp* pApp = UiApp::GetInstance();
|
||||
if (!pApp)
|
||||
|
@ -101,7 +101,7 @@ string FileUtilsTizen::getWritablePath()
|
|||
return path;
|
||||
}
|
||||
|
||||
bool FileUtilsTizen::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsTizen::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
std::string strPath = strFilePath;
|
||||
if (!isAbsolutePath(strPath))
|
||||
|
|
|
@ -47,8 +47,8 @@ class CC_DLL FileUtilsTizen : public FileUtils
|
|||
public:
|
||||
/* override funtions */
|
||||
bool init();
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
virtual std::string getWritablePath() const;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -91,7 +91,7 @@ bool FileUtilsWin32::init()
|
|||
return FileUtils::init();
|
||||
}
|
||||
|
||||
bool FileUtilsWin32::isFileExist(const std::string& strFilePath)
|
||||
bool FileUtilsWin32::isFileExist(const std::string& strFilePath) const
|
||||
{
|
||||
if (0 == strFilePath.length())
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ bool FileUtilsWin32::isFileExist(const std::string& strFilePath)
|
|||
return GetFileAttributesW(utf16Buf) != -1 ? true : false;
|
||||
}
|
||||
|
||||
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath)
|
||||
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const
|
||||
{
|
||||
if ( strPath.length() > 2
|
||||
&& ( (strPath[0] >= 'a' && strPath[0] <= 'z') || (strPath[0] >= 'A' && strPath[0] <= 'Z') )
|
||||
|
@ -182,7 +182,7 @@ std::string FileUtilsWin32::getFullPathForDirectoryAndFilename(const std::string
|
|||
return FileUtils::getFullPathForDirectoryAndFilename(unixDirectory, unixFilename);
|
||||
}
|
||||
|
||||
string FileUtilsWin32::getWritablePath()
|
||||
string FileUtilsWin32::getWritablePath() const
|
||||
{
|
||||
// Get full path of executable, e.g. c:\Program Files (x86)\My Game Folder\MyGame.exe
|
||||
char full_path[CC_MAX_PATH + 1];
|
||||
|
|
|
@ -45,9 +45,9 @@ class CC_DLL FileUtilsWin32 : public FileUtils
|
|||
public:
|
||||
/* override funtions */
|
||||
bool init();
|
||||
virtual std::string getWritablePath();
|
||||
virtual bool isFileExist(const std::string& strFilePath);
|
||||
virtual bool isAbsolutePath(const std::string& strPath);
|
||||
virtual std::string getWritablePath() const;
|
||||
virtual bool isFileExist(const std::string& strFilePath) const;
|
||||
virtual bool isAbsolutePath(const std::string& strPath) const;
|
||||
protected:
|
||||
/**
|
||||
* Gets resource file data
|
||||
|
|
Loading…
Reference in New Issue