Removed the Common::File::removeFile() methods, and moved their implementation to the Common::DefaultSaveFileManager::removeSavefile() method, as per Marcus' appraisal and Max's approval.

svn-id: r29337
This commit is contained in:
David Corrales 2007-10-31 13:59:59 +00:00
parent b4f23c84f5
commit 2ac075e569
3 changed files with 13 additions and 39 deletions

View File

@ -120,7 +120,7 @@ Common::StringList DefaultSaveFileManager::listSavefiles(const char *regex) {
Common::String search(regex);
if (savePath.lookupFile(savefiles, search, false, true)) {
for (FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); file++) {
for (FSList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) {
results.push_back(file->getPath());
}
}
@ -219,7 +219,6 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename)
}
#endif
join_paths(filename, savePath, buf, sizeof(buf));
StdioSaveFile *sf = new StdioSaveFile(buf, true);
@ -235,10 +234,18 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename)
bool DefaultSaveFileManager::removeSavefile(const char *filename) {
char buf[256];
join_paths(filename, getSavePath(), buf, sizeof(buf));
Common::File file;
FilesystemNode savePath((const char *)buf);
return file.removeFile(savePath);
if (remove(buf) != 0) {
if (errno == EACCES)
setError(SFM_DIR_ACCESS, Common::String("Search or write permission denied"));
if (errno == ENOENT)
setError(SFM_DIR_NOENT, Common::String("A component of the path path does not exist, or the path is an empty string"));
return false;
} else {
return true;
}
}
#endif // !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)

View File

@ -423,36 +423,6 @@ bool File::open(const FilesystemNode &node, AccessMode mode) {
return true;
}
bool File::removeFile(const String &filename){
if (remove(filename.c_str()) != 0) {
if (errno == EACCES) {
//TODO: read-only file
}
if (errno == ENOENT) {
//TODO: non-existent file
}
return false;
} else {
return true;
}
}
bool File::removeFile(const FilesystemNode &node){
if (remove(node.getPath().c_str()) != 0) {
if (errno == EACCES) {
//TODO: read-only file
}
if (errno == ENOENT) {
//TODO: non-existent file
}
return false;
} else {
return true;
}
}
bool File::exists(const String &filename) {
FilesystemNode* file;
String fname = filename;

View File

@ -85,9 +85,6 @@ public:
virtual void close();
virtual bool removeFile(const String &filename);
virtual bool removeFile(const FilesystemNode &node);
/**
* Checks if the object opened a file successfully.
*