Logo Search packages:      
Sourcecode: scummvm version File versions  Download package

bool DefaultSaveFileManager::removeSavefile ( const Common::String name  )  [virtual, inherited]

Removes the given savefile from the system.

Parameters:
name the name of the savefile to be removed.
Returns:
true if no error occurred, false otherwise.

Implements Common::SaveFileManager.

Definition at line 118 of file default-saves.cpp.

References DefaultSaveFileManager::checkPath(), Common::FSNode::getChild(), Common::SaveFileManager::getError(), Common::FSNode::getName(), Common::FSNode::getPath(), DefaultSaveFileManager::getSavePath(), Common::kNoError, Common::kPathDoesNotExist, Common::kWritePermissionDenied, and Common::SaveFileManager::setError().

                                                                        {
      Common::String savePathName = getSavePath();
      checkPath(Common::FSNode(savePathName));
      if (getError() != Common::kNoError)
            return false;

      // recreate FSNode since checkPath may have changed/created the directory
      Common::FSNode savePath(savePathName);

      Common::FSNode file = savePath.getChild(filename);

      // FIXME: remove does not exist on all systems. If your port fails to
      // compile because of this, please let us know (scummvm-devel or Fingolfin).
      // There is a nicely portable workaround, too: Make this method overloadable.
      if (remove(file.getPath().c_str()) != 0) {
#ifndef _WIN32_WCE
            if (errno == EACCES)
                  setError(Common::kWritePermissionDenied, "Search or write permission denied: "+file.getName());

            if (errno == ENOENT)
                  setError(Common::kPathDoesNotExist, "removeSavefile: '"+file.getName()+"' does not exist or path is invalid");
#endif
            return false;
      } else {
            return true;
      }
}


Generated by  Doxygen 1.6.0   Back to index