Constified some Filesystem module methods

This commit is contained in:
Alex Szpakowski
2013-03-17 03:54:11 -03:00
parent 129ae0f4eb
commit a2cb35f4e3
2 changed files with 14 additions and 14 deletions
+7 -7
View File
@@ -174,12 +174,12 @@ bool Filesystem::setupWriteDirectory()
return true; return true;
} }
File *Filesystem::newFile(const char *filename) File *Filesystem::newFile(const char *filename) const
{ {
return new File(filename); return new File(filename);
} }
FileData *Filesystem::newFileData(void *data, unsigned int size, const char *filename) FileData *Filesystem::newFileData(void *data, unsigned int size, const char *filename) const
{ {
FileData *fd = new FileData(size, std::string(filename)); FileData *fd = new FileData(size, std::string(filename));
@@ -189,7 +189,7 @@ FileData *Filesystem::newFileData(void *data, unsigned int size, const char *fil
return fd; return fd;
} }
FileData *Filesystem::newFileData(const char *b64, const char *filename) FileData *Filesystem::newFileData(const char *b64, const char *filename) const
{ {
int size = strlen(b64); int size = strlen(b64);
int outsize = 0; int outsize = 0;
@@ -270,21 +270,21 @@ const char *Filesystem::getSaveDirectory()
return save_path_full.c_str(); return save_path_full.c_str();
} }
bool Filesystem::exists(const char *file) bool Filesystem::exists(const char *file) const
{ {
if (PHYSFS_exists(file)) if (PHYSFS_exists(file))
return true; return true;
return false; return false;
} }
bool Filesystem::isDirectory(const char *file) bool Filesystem::isDirectory(const char *file) const
{ {
if (PHYSFS_isDirectory(file)) if (PHYSFS_isDirectory(file))
return true; return true;
return false; return false;
} }
bool Filesystem::isFile(const char *file) bool Filesystem::isFile(const char *file) const
{ {
return exists(file) && !isDirectory(file); return exists(file) && !isDirectory(file);
} }
@@ -523,7 +523,7 @@ int Filesystem::getLastModified(lua_State *L)
return 1; return 1;
} }
int64 Filesystem::getSize(const char *filename) int64 Filesystem::getSize(const char *filename) const
{ {
File file(filename); File file(filename);
int64 size = file.getSize(); int64 size = file.getSize();
+7 -7
View File
@@ -147,7 +147,7 @@ public:
/** /**
* Creates a new file. * Creates a new file.
**/ **/
File *newFile(const char *filename); File *newFile(const char *filename) const;
/** /**
* Creates a new FileData object. Data will be copied. * Creates a new FileData object. Data will be copied.
@@ -155,13 +155,13 @@ public:
* @param size The size of the data. * @param size The size of the data.
* @param filename The full filename used to file type identification. * @param filename The full filename used to file type identification.
**/ **/
FileData *newFileData(void *data, unsigned int size, const char *filename); FileData *newFileData(void *data, unsigned int size, const char *filename) const;
/** /**
* Creates a new FileData object from base64 data. * Creates a new FileData object from base64 data.
* @param b64 The base64 data. * @param b64 The base64 data.
**/ **/
FileData *newFileData(const char *b64, const char *filename); FileData *newFileData(const char *b64, const char *filename) const;
/** /**
* Gets the current working directory. * Gets the current working directory.
@@ -190,20 +190,20 @@ public:
* or not. * or not.
* @param file The filename to check. * @param file The filename to check.
**/ **/
bool exists(const char *file); bool exists(const char *file) const;
/** /**
* Checks if an existing file really is a directory. * Checks if an existing file really is a directory.
* @param file The filename to check. * @param file The filename to check.
**/ **/
bool isDirectory(const char *file); bool isDirectory(const char *file) const;
/** /**
* Checks if an existing file really is a file, * Checks if an existing file really is a file,
* and not a directory. * and not a directory.
* @param file The filename to check. * @param file The filename to check.
**/ **/
bool isFile(const char *file); bool isFile(const char *file) const;
/** /**
* Creates a directory. Write dir must be set. * Creates a directory. Write dir must be set.
@@ -292,7 +292,7 @@ public:
* Gets the size of a file in bytes. * Gets the size of a file in bytes.
* @param filename The name of the file. * @param filename The name of the file.
**/ **/
int64 getSize(const char *filename); int64 getSize(const char *filename) const;
/** /**
* Text file line-reading iterator function used and * Text file line-reading iterator function used and