示例#1
0
string configpath() {
  #ifdef _WIN32
  return userpath();
  #else
  return {userpath(), ".config/"};
  #endif
}
示例#2
0
Settings::Settings() {
  Markup::Node::operator=(BML::unserialize(string::read(locate({configpath(), "icarus/"}, "settings.bml"))));

  auto set = [&](const string& name, const string& value) {
    //create node and set to default value only if it does not already exist
    if(!operator[](name)) operator()(name).setValue(value);
  };

  set("Library/Location", {userpath(), "Emulation/"});

  set("icarus/Path", userpath());
  set("icarus/CreateManifests", false);
  set("icarus/UseDatabase", true);
  set("icarus/UseHeuristics", true);
}
示例#3
0
Settings::Settings() {
  root.append(activePath, "ActivePath");
  root.append(libraryPath, "LibraryPath");
  root.append(createManifests, "CreateManifests");
  root.append(useDatabase, "UseDatabase");
  root.append(useHeuristics, "UseHeuristics");
  append(root, "Settings");

  directory::create({configpath(), "icarus/"});
  load({configpath(), "icarus/settings.bml"});
  save({configpath(), "icarus/settings.bml"});

  if(!activePath) activePath = userpath();
  if(!libraryPath) libraryPath = {userpath(), "Emulation/"};
}
示例#4
0
// /home/username/.config/
// c:/users/username/appdata/roaming/
string configpath() {
  string result;
  #if defined(PLATFORM_WINDOWS)
  wchar_t path[PATH_MAX] = L"";
  SHGetFolderPathW(nullptr, CSIDL_APPDATA | CSIDL_FLAG_CREATE, nullptr, 0, path);
  result = (const char*)utf8_t(path);
  result.transform("\\", "/");
  #elif defined(PLATFORM_OSX)
  result = {userpath(), "Library/Application Support/"};
  #else
  result = {userpath(), ".config/"};
  #endif
  if(result.empty()) result = ".";
  if(result.endswith("/") == false) result.append("/");
  return result;
}
示例#5
0
文件: high.c 项目: blinrybot/gish
void loadscores(void)
  {
  int count,count2;
  int version;
  FILE *fp;
  char path[PATH_MAX];

  for (count=0;count<32;count++)
  for (count2=0;count2<16;count2++)
    {
    highscore[count][count2].time=0;
    strcpy(highscore[count][count2].name,"Empty");
    }

  if ((fp=fopen(userpath(path,NULL,"gish.his"),"rb"))!=NULL)
    {
    fread2(&version,4,1,fp);
    if (version==2)
      {
      for (count=0;count<32;count++)
      for (count2=0;count2<16;count2++)
        {
        fread2(&highscore[count][count2].time,4,1,fp);
        fread2(highscore[count][count2].name,1,32,fp);
        }
      }
    fclose(fp);
    }
  }
示例#6
0
void Application::initPaths(const char *basename) {
  char temp[PATH_MAX];

  if(realpath(basename, temp)) {
    //remove program name
    strtr(temp, "\\", "/");
    for(signed i = strlen(temp) - 1; i >= 0; i--) {
      if(temp[i] == '/') {
        temp[i] = 0;
        break;
      }
    }

    if(strend(temp, "/") == false) strcat(temp, "/");
    config().path.base = temp;
  } else {
    config().path.base = "";
  }

  if(userpath(temp)) {
    strtr(temp, "\\", "/");
    if(strend(temp, "/") == false) strcat(temp, "/");
    config().path.user = temp;
  } else {
    config().path.user = "";
  }

  char cwd[PATH_MAX];
  config().path.startup = getcwd(cwd);
}
示例#7
0
文件: dl.hpp 项目: vonmoltke/vmsnes
inline bool library::open(const string& name, const string& path) {
  if(handle) close();
  if(path) handle = (uintptr_t)dlopen(string(path, "lib", name, ".dylib"), RTLD_LAZY);
  if(!handle) handle = (uintptr_t)dlopen(string(userpath(), ".local/lib/lib", name, ".dylib"), RTLD_LAZY);
  if(!handle) handle = (uintptr_t)dlopen(string("/usr/local/lib/lib", name, ".dylib"), RTLD_LAZY);
  if(!handle) handle = (uintptr_t)dlopen(string("lib", name, ".dylib"), RTLD_LAZY);
  return handle;
}
示例#8
0
void Settings::save() {
  string path = { userpath(), ".config/" };
  mkdir(path, 0755);
  path.append("phoenix/");
  mkdir(path, 0755);
  path.append("gtk.cfg");
  configuration::save(path);
}
示例#9
0
string realpath(const char *name) {
  char path[PATH_MAX];
  if(::realpath(name, path)) {
    string result(path);
    result.transform("\\", "/");
    return result;
  }
  return userpath();
}
示例#10
0
QString NewProject::getCurrentPath()
{
    QSettings settings(publisherKey, ASideGuiKey, this);
    QVariant  lastfile = settings.value(workspaceKey);
    QString userpath("");
    if(lastfile.canConvert(QVariant::String)) {
        userpath = lastfile.toString();
        userpath = QDir::fromNativeSeparators(userpath);
        /* "/" gets converted to user OS version */
        userpath = userpath.mid(0,userpath.lastIndexOf("/")+1);
    }
    return userpath;
}
示例#11
0
ConfigurationManager::ConfigurationManager() {
  config = this;

  userInterface.append(userInterface.showStatusBar, "ShowStatusBar");
  append(userInterface, "UserInterface");

  library.append(library.location, "Location");
  append(library, "Library");

  video.append(video.driver, "Driver");
  video.append(video.synchronize, "Synchronize");
  video.append(video.scale, "Scale");
  video.append(video.aspectCorrection, "AspectCorrection");
  video.append(video.filter, "Filter");
  video.append(video.colorEmulation, "ColorEmulation");
  video.append(video.saturation, "Saturation");
  video.append(video.gamma, "Gamma");
  video.append(video.luminance, "Luminance");
  video.overscan.append(video.overscan.mask, "Mask");
  video.overscan.append(video.overscan.horizontal, "Horizontal");
  video.overscan.append(video.overscan.vertical, "Vertical");
  video.append(video.overscan, "Overscan");
  append(video, "Video");

  audio.append(audio.driver, "Driver");
  audio.append(audio.device, "Device");
  audio.append(audio.synchronize, "Synchronize");
  audio.append(audio.mute, "Mute");
  audio.append(audio.volume, "Volume");
  audio.append(audio.frequency, "Frequency");
  audio.append(audio.latency, "Latency");
  audio.append(audio.resampler, "Resampler");
  append(audio, "Audio");

  input.append(input.driver, "Driver");
  append(input, "Input");

  timing.append(timing.video, "Video");
  timing.append(timing.audio, "Audio");
  append(timing, "Timing");

  load(locate({configpath(), "tomoko/"}, "settings.bml"));
  if(!library.location) library.location = {userpath(), "Emulation/"};
  if(!video.driver) video.driver = ruby::Video::safestDriver();
  if(!audio.driver) audio.driver = ruby::Audio::safestDriver();
  if(!input.driver) input.driver = ruby::Input::safestDriver();
  save(locate({configpath(), "tomoko/"}, "settings.bml"));
}
示例#12
0
文件: high.c 项目: blinrybot/gish
void savescores(void)
  {
  int count,count2;
  int version;
  FILE *fp;
  char path[PATH_MAX];

  if ((fp=fopen(userpath(path,NULL,"gish.his"),"wb"))!=NULL)
    {
    version=2;
    fwrite2(&version,4,1,fp);
    for (count=0;count<32;count++)
    for (count2=0;count2<16;count2++)
      {
      fwrite2(&highscore[count][count2].time,4,1,fp);
      fwrite2(highscore[count][count2].name,1,32,fp);
      }
    fclose(fp);
    }
  }
示例#13
0
  void find_userdir() const
  {
    std::string userdir;
    if (m_forced_userdir)
    {
      userdir = *m_forced_userdir;
    }
    else if (const char* env_userdir = getenv("SUPERTUX2_USER_DIR"))
    {
      userdir = env_userdir;
    }
    else
    {
		userdir = PHYSFS_getPrefDir("SuperTux","supertux2");
    }
	//Kept for backwards-compatability only, hence the silence
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
	std::string physfs_userdir = PHYSFS_getUserDir();
#pragma GCC diagnostic pop

#ifdef _WIN32
	std::string olduserdir = FileSystem::join(physfs_userdir, PACKAGE_NAME);
#else
	std::string olduserdir = FileSystem::join(physfs_userdir, "." PACKAGE_NAME);
#endif
	if (FileSystem::is_directory(olduserdir)) {
	  boost::filesystem::path olduserpath(olduserdir);
	  boost::filesystem::path userpath(userdir);

	  boost::filesystem::directory_iterator end_itr;

	  bool success = true;

	  // cycle through the directory
	  for (boost::filesystem::directory_iterator itr(olduserpath); itr != end_itr; ++itr) {
		try
		{
		  boost::filesystem::rename(itr->path().string().c_str(), userpath / itr->path().filename());
		}
		catch (const boost::filesystem::filesystem_error& err)
		{
		  success = false;
		  log_warning << "Failed to move contents of config directory: " << err.what() << std::endl;
		}
	  }
	  if (success) {
	    try
		{
		  boost::filesystem::remove_all(olduserpath);
		}
		catch (const boost::filesystem::filesystem_error& err)
		{
		  success = false;
		  log_warning << "Failed to remove old config directory: " << err.what();
		}
	  }
	  if (success) {
	    log_info << "Moved old config dir " << olduserdir << " to " << userdir << std::endl;
	  }
	}

    if (!FileSystem::is_directory(userdir))
    {
	  FileSystem::mkdir(userdir);
	  log_info << "Created SuperTux userdir: " << userdir << std::endl;
    }

    if (!PHYSFS_setWriteDir(userdir.c_str()))
    {
      std::ostringstream msg;
      msg << "Failed to use userdir directory '"
          <<  userdir << "': " << PHYSFS_getLastErrorCode();
      throw std::runtime_error(msg.str());
    }

    PHYSFS_mount(userdir.c_str(), NULL, 0);
  }
示例#14
0
string Utility::libraryPath() {
  string path = string::read({configpath(), "dasShiny/library.cfg"}).strip().transform("\\", "/");
  if(path.empty()) path = {userpath(), "Emulation/Nintendo DS/"};
  if(!path.endswith("/")) path.append("/");
  return path;
}
示例#15
0
string Utility::libraryPath() {
  string path = string::read({configpath(), "higan/library.bml"}).strip().ltrim<1>("Path: ").transform("\\", "/");
  if(path.empty()) path = {userpath(), "Emulation/"};
  if(path.endsWith("/") == false) path.append("/");
  return path;
}
示例#16
0
AdvancedSettings::AdvancedSettings() {
  driverTitle.setFont(program->titleFont);
  driverTitle.setText("Driver Selection");
  videoLabel.setText("Video:");
  audioLabel.setText("Audio:");
  inputLabel.setText("Input:");
  libraryTitle.setFont(program->titleFont);
  libraryTitle.setText("Game Library Path");
  libraryLabel.setText("Path:");
  libraryPath.setEditable(false);
  string path = string::read({configpath(), "higan/library.bml"}).strip().ltrim<1>("Path: ").transform("\\", "/");
  if(path.empty()) path = {userpath(), "Emulation/"};
  if(path.endswith("/") == false) path.append("/");
  libraryPath.setText(path);
  libraryBrowse.setText("Browse ...");
  infoLabel.setFont(program->boldFont);
  infoLabel.setText({
    Emulator::Name, " v", Emulator::Version, "\n",
    "  ", Emulator::Profile, " Profile\n",
    "  Author: ", Emulator::Author, "\n",
    "  License: ", Emulator::License, "\n",
    "  Website: ", Emulator::Website
  });

  lstring list;

  list.split(";", video.availableDrivers());
  for(unsigned n = 0; n < list.size(); n++) {
    videoDriver.append(list[n]);
    if(list[n] == config->video.driver) videoDriver.setSelection(n);
  }

  list.split(";", audio.availableDrivers());
  for(unsigned n = 0; n < list.size(); n++) {
    audioDriver.append(list[n]);
    if(list[n] == config->audio.driver) audioDriver.setSelection(n);
  }

  list.split(";", input.availableDrivers());
  for(unsigned n = 0; n < list.size(); n++) {
    inputDriver.append(list[n]);
    if(list[n] == config->input.driver) inputDriver.setSelection(n);
  }

  append(driverTitle, {~0, 0}, 5);
  append(driverLayout, {~0, 0}, 15);
    driverLayout.append(videoLabel, {0, 0}, 5);
    driverLayout.append(videoDriver, {~0, 0}, 5);
    driverLayout.append(audioLabel, {0, 0}, 5);
    driverLayout.append(audioDriver, {~0, 0}, 5);
    driverLayout.append(inputLabel, {0, 0}, 5);
    driverLayout.append(inputDriver, {~0, 0});
  append(libraryTitle, {~0, 0}, 5);
  append(libraryLayout, {~0, 0}, 15);
    libraryLayout.append(libraryLabel, {0, 0}, 5);
    libraryLayout.append(libraryPath, {~0, 0}, 5);
    libraryLayout.append(libraryBrowse, {80, 0});
  if(Intrinsics::platform() != Intrinsics::Platform::OSX) {
    append(spacer, {~0, ~0});
    append(infoLabel, {~0, 0});
  }

  videoDriver.onChange = [&] { config->video.driver = videoDriver.text(); };
  audioDriver.onChange = [&] { config->audio.driver = audioDriver.text(); };
  inputDriver.onChange = [&] { config->input.driver = inputDriver.text(); };

  libraryBrowse.onActivate = [&] {
    string path = BrowserWindow().setParent(*settings).setPath(userpath()).directory();
    if(path.empty()) return;
    file::write({configpath(), "higan/library.bml"}, {"Path: ", path, "\n"});
    libraryPath.setText(path);
  };
}
示例#17
0
void Settings::load() {
  string path = { userpath(), ".config/phoenix/gtk.cfg" };
  configuration::load(path);
}