added finding proper path for database #14
Merged@github-juk3n wants to merge
13-add-storing-data-in-fluffy-folder into mainMerged as
55849948b41a.3 files changed
modified
README.md +35 -1 | @@ -1 +1,35 @@ | ||
| 1 | -# fluffy | |
| \ No newline at end of file | ||
| 1 | +# fluffy - terminal game launcher | |
| 2 | + | |
| 3 | +(only on linux) | |
| 4 | + | |
| 5 | +Fluffy's goal is to provide simple and fast possibility to run games from user defined directories and store all the required paths in one place. | |
| 6 | + | |
| 7 | +## Usage | |
| 8 | + | |
| 9 | +### Command-line options | |
| 10 | + | |
| 11 | +- fluffy show - show list of games | |
| 12 | + | |
| 13 | +```console | |
| 14 | +user:~/some/path$ fluffy show | |
| 15 | +game_name: /path/to/your/game | |
| 16 | +``` | |
| 17 | + | |
| 18 | +- fluffy add <game_name> <game_path> - add a game | |
| 19 | + | |
| 20 | +```console | |
| 21 | +user:~/some/path$ fluffy add game_name path/to/your/game | |
| 22 | +``` | |
| 23 | + | |
| 24 | +- fluffy rm <game_name> - remove a game | |
| 25 | + | |
| 26 | +```console | |
| 27 | +user:~/some/path$ fluffy rm game_name | |
| 28 | +``` | |
| 29 | + | |
| 30 | +- fluffy - runs a fluffy gui from which the game can be run | |
| 31 | + | |
| 32 | + | |
| 33 | +## Installation | |
| 34 | + | |
| 35 | +(work in progress) | |
| @@ -1 +1,35 @@ | |||
| 1 | -# fluffy | ||
| \ No newline at end of file | \ No newline at end of file | ||
| 1 | +# fluffy - terminal game launcher | ||
| 2 | + | ||
| 3 | +(only on linux) | ||
| 4 | + | ||
| 5 | +Fluffy's goal is to provide simple and fast possibility to run games from user defined directories and store all the required paths in one place. | ||
| 6 | + | ||
| 7 | +## Usage | ||
| 8 | + | ||
| 9 | +### Command-line options | ||
| 10 | + | ||
| 11 | +- fluffy show - show list of games | ||
| 12 | + | ||
| 13 | +```console | ||
| 14 | +user:~/some/path$ fluffy show | ||
| 15 | +game_name: /path/to/your/game | ||
| 16 | +``` | ||
| 17 | + | ||
| 18 | +- fluffy add <game_name> <game_path> - add a game | ||
| 19 | + | ||
| 20 | +```console | ||
| 21 | +user:~/some/path$ fluffy add game_name path/to/your/game | ||
| 22 | +``` | ||
| 23 | + | ||
| 24 | +- fluffy rm <game_name> - remove a game | ||
| 25 | + | ||
| 26 | +```console | ||
| 27 | +user:~/some/path$ fluffy rm game_name | ||
| 28 | +``` | ||
| 29 | + | ||
| 30 | +- fluffy - runs a fluffy gui from which the game can be run | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +## Installation | ||
| 34 | + | ||
| 35 | +(work in progress) | ||
added
screenshots/fluffy_0_1.png +0 -0 | new file mode 100644 | ||
| Binary files /dev/null and b/screenshots/fluffy_0_1.png differ | ||
| new file mode 100644 | |||
| Binary files /dev/null and b/screenshots/fluffy_0_1.png differ | Binary files /dev/null and b/screenshots/fluffy_0_1.png differ | ||
modified
src/main.cpp +5 -3 | @@ -28,7 +28,7 @@ std::string database_initialization_command = | ||
| 28 | 28 | |
| 29 | 29 | std::string select_all_games_command = "SELECT * FROM games;"; |
| 30 | 30 | |
| 31 | -bool debugRun = true; | |
| 31 | +bool debugRun = false; | |
| 32 | 32 | |
| 33 | 33 | void printMessage(std::string message) { |
| 34 | 34 | if (debugRun) { |
| @@ -169,12 +169,14 @@ auto runConsoleApp(sqlite3* database) -> void { | ||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | auto main(int argc, char const *argv[]) -> int { |
| 172 | - bool newCreation = not std::filesystem::exists("data.db"); | |
| 172 | + auto appPath{ std::filesystem::path(argv[0])}; | |
| 173 | + auto databasePath{ std::filesystem::path(appPath.parent_path().string() + "/data.db")}; | |
| 174 | + bool newCreation = not std::filesystem::exists(databasePath.string()); | |
| 173 | 175 | char *messageError; |
| 174 | 176 | sqlite3 *database; |
| 175 | 177 | sqlite3_stmt *stmt; |
| 176 | 178 | int exit = 0; |
| 177 | - exit = sqlite3_open("data.db", &database); | |
| 179 | + exit = sqlite3_open(databasePath.c_str(), &database); | |
| 178 | 180 | |
| 179 | 181 | if (exit) { |
| 180 | 182 | std::cerr << "Error opening database" << sqlite3_errmsg(database) |
| @@ -28,7 +28,7 @@ std::string database_initialization_command = | |||
| 28 | 28 | ||
| 29 | std::string select_all_games_command = "SELECT * FROM games;"; | 29 | std::string select_all_games_command = "SELECT * FROM games;"; |
| 30 | 30 | ||
| 31 | -bool debugRun = true; | 31 | +bool debugRun = false; |
| 32 | 32 | ||
| 33 | void printMessage(std::string message) { | 33 | void printMessage(std::string message) { |
| 34 | if (debugRun) { | 34 | if (debugRun) { |
| @@ -169,12 +169,14 @@ auto runConsoleApp(sqlite3* database) -> void { | |||
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | auto main(int argc, char const *argv[]) -> int { | 171 | auto main(int argc, char const *argv[]) -> int { |
| 172 | - bool newCreation = not std::filesystem::exists("data.db"); | 172 | + auto appPath{ std::filesystem::path(argv[0])}; |
| 173 | + auto databasePath{ std::filesystem::path(appPath.parent_path().string() + "/data.db")}; | ||
| 174 | + bool newCreation = not std::filesystem::exists(databasePath.string()); | ||
| 173 | char *messageError; | 175 | char *messageError; |
| 174 | sqlite3 *database; | 176 | sqlite3 *database; |
| 175 | sqlite3_stmt *stmt; | 177 | sqlite3_stmt *stmt; |
| 176 | int exit = 0; | 178 | int exit = 0; |
| 177 | - exit = sqlite3_open("data.db", &database); | 179 | + exit = sqlite3_open(databasePath.c_str(), &database); |
| 178 | 180 | ||
| 179 | if (exit) { | 181 | if (exit) { |
| 180 | std::cerr << "Error opening database" << sqlite3_errmsg(database) | 182 | std::cerr << "Error opening database" << sqlite3_errmsg(database) |