Compare commits
No commits in common. "e77b61b1d98e7e418837a4096c8dd14c40f3b092" and "d11b690708b0684e02195f3f7cbdebf547d8f17f" have entirely different histories.
e77b61b1d9
...
d11b690708
@ -18,18 +18,9 @@ namespace cellar {
|
||||
bottle_error,
|
||||
bottle_anonymous,
|
||||
bottle_labelled,
|
||||
bottle_symlink,
|
||||
bottle_steam
|
||||
bottle_symlink
|
||||
};
|
||||
|
||||
enum bottle_manager {
|
||||
manager_error,
|
||||
manager_cellar,
|
||||
manager_steam
|
||||
};
|
||||
|
||||
extern std::string bottle_home;
|
||||
|
||||
/**
|
||||
* Bottles are the internal name for WINE prefixes. In addition to standard WINE contents,
|
||||
* bottles contain a configuration file managed by cellar, which labels the bottle as well
|
||||
@ -39,7 +30,6 @@ namespace cellar {
|
||||
public:
|
||||
// public members
|
||||
bottle_type type;
|
||||
bottle_manager manager;
|
||||
json config;
|
||||
string path;
|
||||
string canonical_path;
|
||||
|
@ -21,8 +21,6 @@ namespace cellar {
|
||||
cog.outl("extern void {0} (int, vector<string>);".format(item[1]))
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
|
||||
extern void setup_bottle_home();
|
||||
}
|
||||
namespace commands {
|
||||
extern map<string, cellar::commands::CommandFunction> bottles_commands();
|
||||
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace cellar {
|
||||
namespace steam {
|
||||
extern std::vector<std::string> find_steam_libraries();
|
||||
}
|
||||
}
|
26
include/internal/steam.hpp.cog
Normal file
26
include/internal/steam.hpp.cog
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "commands.hpp"
|
||||
|
||||
namespace cellar {
|
||||
namespace steam {
|
||||
extern std::vector<std::string> find_steam_libraries();
|
||||
extern void test_command(int argc, std::vector<std::string> argv);
|
||||
/*[[[cog
|
||||
import cog
|
||||
|
||||
with open("src/steam/commands.txt") as commandsfile:
|
||||
for line in commandsfile:
|
||||
item = line.strip().split(" ")
|
||||
cog.outl("extern void {0} (int, vector<string>);".format(item[1]))
|
||||
]]]*/
|
||||
//[[[end]]]
|
||||
}
|
||||
namespace commands {
|
||||
extern std::map<std::string,cellar::commands::CommandFunction> steam_commands();
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@ void cellar::bottles::print_active_bottle(int argc, vector<string> argv) {
|
||||
string bottlepath = active_bottle.canonical_path;
|
||||
stringstream outstr;
|
||||
bool cellar_managed = true;
|
||||
bool external_managed = false;
|
||||
if (active_bottle.type == bottle_symlink) {
|
||||
outstr << "symlink to ";
|
||||
string homedir = getenv("HOME");
|
||||
@ -25,8 +24,6 @@ void cellar::bottles::print_active_bottle(int argc, vector<string> argv) {
|
||||
if (active_bottle.canonical_path.substr(0, bottlerack.length()) == bottlerack) {
|
||||
bottlepath.replace(0, bottlerack.length() + 1, ""); // should convert "/home/someone/.wine.example" to ".wine.example"
|
||||
active_bottle = bottlemap[bottlepath];
|
||||
active_bottle.set_config("manager", "cellar");
|
||||
active_bottle.save_config();
|
||||
} else {
|
||||
outstr << active_bottle.canonical_path;
|
||||
cellar_managed = false;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
@ -34,21 +33,6 @@ Bottle::Bottle() {
|
||||
// strings handle themselves
|
||||
config = json({});
|
||||
type = bottle_anonymous;
|
||||
manager = manager_error;
|
||||
}
|
||||
|
||||
std::string cellar::bottles::bottle_home;
|
||||
|
||||
/**
|
||||
* @brief Sets up bottle home.
|
||||
* Called once from early mainloop.
|
||||
* @todo Have this not be an effectively hardcoded path. Respect xdg paths.
|
||||
*/
|
||||
void cellar::bottles::setup_bottle_home() {
|
||||
stringstream sstr_bottle_home;
|
||||
sstr_bottle_home << std::getenv("HOME");
|
||||
sstr_bottle_home << "/.local/share/cellar/bottles";
|
||||
bottle_home = sstr_bottle_home.str();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,40 +45,21 @@ Bottle::Bottle(string patharg) {
|
||||
config = json({});
|
||||
path = patharg;
|
||||
|
||||
//boost::filesystem::file_status path_status = boost::filesystem::symlink_status(path);
|
||||
//bool symlink = boost::filesystem::is_symlink(path_status);
|
||||
auto path_status = std::filesystem::path(path);
|
||||
auto path_canon = std::filesystem::canonical(path_status);
|
||||
canonical_path = path_canon.string();
|
||||
boost::filesystem::file_status path_status = boost::filesystem::symlink_status(path);
|
||||
bool symlink = boost::filesystem::is_symlink(path_status);
|
||||
|
||||
if (std::filesystem::is_symlink(path_canon)) {
|
||||
if (symlink) {
|
||||
boost::filesystem::path realpath = boost::filesystem::canonical(path);
|
||||
canonical_path = realpath.string();
|
||||
type = bottle_symlink;
|
||||
} else {
|
||||
canonical_path = path;
|
||||
try {
|
||||
load_config();
|
||||
auto cur_manager = get_config("manager");
|
||||
if (cur_manager == "cellar") {
|
||||
manager = manager_cellar;
|
||||
|
||||
if (get_config("name") != "") {
|
||||
if (load_config()) {
|
||||
type = bottle_labelled;
|
||||
} else {
|
||||
type = bottle_anonymous;
|
||||
}
|
||||
} else if (path_canon.parent_path() == bottle_home) {
|
||||
manager = manager_cellar;
|
||||
set_config("manager", "cellar"); // migrate from older cellar (or correct for something weird happening)
|
||||
save_config();
|
||||
|
||||
if (get_config("name") != "") {
|
||||
type = bottle_labelled;
|
||||
} else {
|
||||
type = bottle_anonymous;
|
||||
}
|
||||
} else if (cur_manager == "steam") {
|
||||
type = bottle_steam;
|
||||
manager = manager_steam;
|
||||
}
|
||||
}
|
||||
catch (const exception &exc) {
|
||||
type = bottle_error;
|
||||
@ -198,9 +163,6 @@ void cellar::bottles::print_bottles(int argc, vector<string> argv) {
|
||||
case bottle_labelled:
|
||||
outstr << bottle.config["name"];
|
||||
break;
|
||||
case bottle_steam:
|
||||
outstr << "Steam managed bottle for " << bottle.config["name"];
|
||||
break;
|
||||
default:
|
||||
outstr << "broken or unsupported wine bottle";
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "internal/bottles.hpp"
|
||||
#include "cellar.hpp"
|
||||
#include "commands.hpp"
|
||||
#include "output.hpp"
|
||||
@ -46,7 +45,6 @@ int main(int argc, char* argv[]) {
|
||||
cout << "\n(try \"cellar help\" if you're confused)" << endl;
|
||||
return 0;
|
||||
}
|
||||
cellar::bottles::setup_bottle_home();
|
||||
try {
|
||||
const string desc = "bottle management tool for WINE connoisseurs";
|
||||
const string versionstr = version::short_version();
|
||||
@ -72,7 +70,7 @@ int main(int argc, char* argv[]) {
|
||||
dryrun = dryrunarg.getValue();
|
||||
verbose = dryrun || verbosearg.getValue();
|
||||
|
||||
// TODO: i'm sure stdlib has come a long way in formatting strings since this ancient hack was put in
|
||||
// BULLSHIT: trying to use str.format on this string causes bizarre compiler errors
|
||||
/*[[[cog
|
||||
import cog
|
||||
|
||||
@ -105,7 +103,7 @@ int main(int argc, char* argv[]) {
|
||||
if (bottlechoice.substr(0,1) == "/" || bottlechoice.substr(0,1) == ".") { // absolute or relative path
|
||||
bottles::active_bottle = bottles::Bottle(bottlechoice);
|
||||
} else if (bottlechoice.substr(0,1) == "~") { // "absolute" path in home directory, not expanded by the shell for some reason (i've seen some shit)
|
||||
// this is a naive replacement and will fail if the user tries something like ~nicole/.wine
|
||||
// this is a naive replacement and will fail if the user tries something like ~nick/.wine
|
||||
// i'm figuring at that point if you're doing that, you'll also recognize if your shell
|
||||
// isn't actually expanding your path...
|
||||
bottlechoice.replace(0,1,getenv("HOME"));
|
||||
|
@ -44,9 +44,7 @@ std::map<std::string, cellar::bottles::Bottle> cellar::steam::get_app_bottles()
|
||||
}
|
||||
|
||||
auto curbottle = cellar::bottles::Bottle((pth_appid / "pfx").string());
|
||||
curbottle.type = cellar::bottles::bottle_steam;
|
||||
curbottle.set_config("name", str_gamename);
|
||||
curbottle.set_config("manager", "steam");
|
||||
curbottle.save_config();
|
||||
result[std::string("steam:" + pth_appid.filename().string())] = curbottle;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user