示例#1
0
bool MapResource_save(const MapFormat& format, scene::Node& root, const char* path, const char* name)
{
  StringOutputStream fullpath(256);
  fullpath << path << name;

  if(path_is_absolute(fullpath.c_str()))
  {
    if(!file_exists(fullpath.c_str()) || file_saveBackup(fullpath.c_str()))
    {
      return MapResource_saveFile(format, root, Map_Traverse, fullpath.c_str());
    }

    globalErrorStream() << "failed to save a backup map file: " << makeQuoted(fullpath.c_str()) << "\n";
    return false;
  }

  globalErrorStream() << "map path is not fully qualified: " << makeQuoted(fullpath.c_str()) << "\n";
  return false;
}
示例#2
0
/**
 * Save a map file (outer function). This function tries to backup the map
 * file before calling MapResource_saveFile() to do the actual saving of
 * data.
 */
bool MapResource_save (const MapFormat& format, scene::Node& root, const std::string& path, const std::string& name)
{
    std::string fullpath = path + name;

    if (g_path_is_absolute(fullpath.c_str())) {

        // Save a backup if possible. This is done by renaming the original,
        // which won't work if the existing map is currently open by another process
        // in the background.
        if (file_exists(fullpath) && !file_saveBackup(fullpath)) {
            globalErrorStream() << "ERROR: could not rename: " << fullpath << " to backup." << "\n";
        }

        // Save the actual file
        return MapResource_saveFile(format, root, map::Map_Traverse, fullpath);
    } else {
        globalErrorStream() << "ERROR: map path is not fully qualified: " << fullpath << "\n";
        return false;
    }
}