Exemple #1
0
void
AddonManager::disable_addon(const AddonId& addon_id)
{
  log_debug << "disabling addon " << addon_id << std::endl;
  auto& addon = get_installed_addon(addon_id);
  if (!addon.is_enabled())
  {
    log_warning << "Tried disabling already disabled Add-On" << std::endl;
  }
  else
  {
    log_debug << "Removing archive \"" << addon.get_install_filename() << "\" from search path" << std::endl;
    if (PHYSFS_unmount(addon.get_install_filename().c_str()) == 0)
    {
      log_warning << "Could not remove " << addon.get_install_filename() << " from search path: "
                  << PHYSFS_getLastError() << std::endl;
    }
    else
    {
      if(addon.get_type() == Addon::LANGUAGEPACK)
      {
        PHYSFS_enumerateFilesCallback(addon.get_id().c_str(), remove_from_dictionary_path, NULL);
      }
      addon.set_enabled(false);
    }
  }
}
Exemple #2
0
int ex_fsys_unmount ( const char *_dir ) {
#if 0
    __PHYSFS_CHECK( PHYSFS_unmount(_dir) );
    return 0;
#else
    __PHYSFS_CHECK( PHYSFS_removeFromSearchPath(_dir) );
    return 0;
#endif
}
Exemple #3
0
	bool unmount(const std::string_view file)
	{
		if (PHYSFS_unmount(file.data()) != 0)
		{
			return true;
		}
		try
		{
			std::filesystem::path path(file);

			if (path.has_extension() == true)
			{
				path = path.replace_extension();
				if (PHYSFS_unmount(path.u8string().c_str()) != 0)
				{
					return true;
				}
			}
			path = path.replace_extension(".mpq");
			if (PHYSFS_unmount(path.u8string().c_str()) != 0)
			{
				return true;
			}
			path = path.replace_extension(".zip");
			if (PHYSFS_unmount(path.u8string().c_str()) != 0)
			{
				return true;
			}
			path = path.replace_extension(".7z");
			if (PHYSFS_unmount(path.u8string().c_str()) != 0)
			{
				return true;
			}
		}
		catch (std::exception&) {}
		return false;
	}
Exemple #4
0
void
AddonManager::unmount_old_addons()
{
  for (auto& addon : m_installed_addons) {
    if (addon->get_format() == Addon::ORIGINAL &&
        addon->get_type() != Addon::LANGUAGEPACK &&
        addon->is_enabled()) {
      if (PHYSFS_unmount(addon->get_install_filename().c_str()) == 0)
      {
        log_warning << "Could not remove " << addon->get_install_filename() << " from search path: "
                    << PHYSFS_getLastError() << std::endl;
      }
    }
  }
}
Exemple #5
0
void
AddonManager::add_installed_archive(const std::string& archive, const std::string& md5)
{
  const char* realdir = PHYSFS_getRealDir(archive.c_str());
  if (!realdir)
  {
    log_warning << "PHYSFS_getRealDir() failed for " << archive << ": "
                << PHYSFS_getLastError() << std::endl;
  }
  else
  {
    std::string os_path = FileSystem::join(realdir, archive);

    PHYSFS_mount(os_path.c_str(), NULL, 0);

    std::string nfo_filename = scan_for_info(os_path);

    if (nfo_filename.empty())
    {
      log_warning << "Couldn't find .nfo file for " << os_path << std::endl;
    }
    else
    {
      try
      {
        std::unique_ptr<Addon> addon = Addon::parse(nfo_filename);
        addon->set_install_filename(os_path, md5);
        m_installed_addons.push_back(std::move(addon));
      }
      catch (const std::runtime_error& e)
      {
        log_warning << "Could not load add-on info for " << archive << ": " << e.what() << std::endl;
      }
    }

    PHYSFS_unmount(os_path.c_str());
  }
}