Skip to content

Commit e0d1f8d

Browse files
committed
Adding usage of home folder directory to store the database
The database is now stored in a created folder called '.kissebook' which is located in '/home/username/.kissebook' In order to preserve an existing database, create the directory '.kissebook' with dot in the beginning and copy 'kisslib.db' from the application directory.
1 parent 9323613 commit e0d1f8d

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

kiss-front-jessie.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
#include <sqlite3.h>
1717

1818
//GNU
19-
#include <dirent.h>
20-
#include <unistd.h> // access
19+
#include <dirent.h> // readdir, closedir
20+
#include <unistd.h> // access, fork, execlp
21+
#include <sys/stat.h>
2122

2223
// gettext
2324
#include <locale.h>
@@ -157,6 +158,14 @@ int main(int argc, char *argv[]) {
157158
bindtextdomain("KISSebook", "");
158159
textdomain("KISSebook");
159160

161+
char homePath[512];
162+
sprintf(homePath, "%s/.kissebook", getenv("HOME"));
163+
mkdir(homePath, S_IRWXU);
164+
if (chdir(homePath) != 0) {
165+
fprintf(stderr, "Cannot set application working directory to \"%s\", quitting.\n\n", homePath);
166+
return -1;
167+
}
168+
160169
GtkApplication *app;
161170
int status;
162171

kiss-front.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
#include <sqlite3.h>
1717

1818
//GNU
19-
#include <dirent.h>
20-
#include <unistd.h> // access
19+
#include <dirent.h> // readdir, closedir
20+
#include <unistd.h> // access, fork, execlp
21+
#include <sys/stat.h>
2122

2223
// gettext
2324
#include <locale.h>
@@ -157,6 +158,14 @@ int main(int argc, char *argv[]) {
157158
bindtextdomain("KISSebook", "");
158159
textdomain("KISSebook");
159160

161+
char homePath[512];
162+
sprintf(homePath, "%s/.kissebook", getenv("HOME"));
163+
mkdir(homePath, S_IRWXU);
164+
if (chdir(homePath) != 0) {
165+
fprintf(stderr, "Cannot set application working directory to \"%s\", quitting.\n\n", homePath);
166+
return -1;
167+
}
168+
160169
GtkApplication *app;
161170
int status;
162171

kisslib

408 Bytes
Binary file not shown.

kisslib-jessie

472 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)