Removed more bullshit useless dumb code

This commit is contained in:
2021-01-23 02:06:04 +01:00
parent 2e19b9ff5b
commit 35bea57d10
21 changed files with 52 additions and 1654 deletions

View File

@ -177,7 +177,7 @@ void File::rewindDirectory(void)
_p->rewindDirectory();
}
File FS::open(const String& path, const char* mode)
File FS::open(const std::string& path, const char* mode)
{
return open(path.c_str(), mode);
}
@ -199,7 +199,7 @@ bool FS::exists(const char* path)
return _impl->exists(path);
}
bool FS::exists(const String& path)
bool FS::exists(const std::string& path)
{
return exists(path.c_str());
}
@ -212,7 +212,7 @@ bool FS::remove(const char* path)
return _impl->remove(path);
}
bool FS::remove(const String& path)
bool FS::remove(const std::string& path)
{
return remove(path.c_str());
}
@ -225,7 +225,7 @@ bool FS::rename(const char* pathFrom, const char* pathTo)
return _impl->rename(pathFrom, pathTo);
}
bool FS::rename(const String& pathFrom, const String& pathTo)
bool FS::rename(const std::string& pathFrom, const std::string& pathTo)
{
return rename(pathFrom.c_str(), pathTo.c_str());
}
@ -239,7 +239,7 @@ bool FS::mkdir(const char *path)
return _impl->mkdir(path);
}
bool FS::mkdir(const String &path)
bool FS::mkdir(const std::string &path)
{
return mkdir(path.c_str());
}
@ -252,7 +252,7 @@ bool FS::rmdir(const char *path)
return _impl->rmdir(path);
}
bool FS::rmdir(const String &path)
bool FS::rmdir(const std::string &path)
{
return rmdir(path.c_str());
}

View File

@ -89,22 +89,22 @@ public:
FS(FSImplPtr impl) : _impl(impl) { }
File open(const char* path, const char* mode = FILE_READ);
File open(const String& path, const char* mode = FILE_READ);
File open(const std::string& path, const char* mode = FILE_READ);
bool exists(const char* path);
bool exists(const String& path);
bool exists(const std::string& path);
bool remove(const char* path);
bool remove(const String& path);
bool remove(const std::string& path);
bool rename(const char* pathFrom, const char* pathTo);
bool rename(const String& pathFrom, const String& pathTo);
bool rename(const std::string& pathFrom, const std::string& pathTo);
bool mkdir(const char *path);
bool mkdir(const String &path);
bool mkdir(const std::string &path);
bool rmdir(const char *path);
bool rmdir(const String &path);
bool rmdir(const std::string &path);
protected:

View File

@ -388,6 +388,19 @@ boolean VFSFileImpl::isDirectory(void)
return _isDirectory;
}
namespace {
bool string_starts_with(std::string const &fullString, std::string const &begin) {
return fullString.rfind(begin, 0) == 0;
}
bool string_ends_with(std::string const &fullString, std::string const &ending) {
if (fullString.length() >= ending.length()) {
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
} else {
return false;
}
}
}
FileImplPtr VFSFileImpl::openNextFile(const char* mode)
{
if(!_isDirectory || !_d) {
@ -400,9 +413,9 @@ FileImplPtr VFSFileImpl::openNextFile(const char* mode)
if(file->d_type != DT_REG && file->d_type != DT_DIR) {
return openNextFile(mode);
}
String fname = String(file->d_name);
String name = String(_path);
if(!fname.startsWith("/") && !name.endsWith("/")) {
std::string fname = std::string(file->d_name);
std::string name = std::string(_path);
if(!string_starts_with(fname, "/") && !string_ends_with(name, "/")) {
name += "/";
}
name += fname;