Opruiming
[sgc.git] / file.c
blobe23b84262864840f9ff0dfee4e89b252136bd4cf
1 #include "sgc.h"
3 gchar **testList = NULL;
5 void fileOpen(gchar *filename) {
6 gchar *contents;
7 GError *error = NULL;
8 gsize length;
10 if (g_file_get_contents(filename, &contents, &length, &error) != FALSE) {
11 testList = g_strsplit(contents, "\n", MAXTESTS);
12 g_free(contents);
13 } else {
14 g_error_free(error);
17 if (testList == NULL) {
18 testList = g_strsplit("xu1\nci2", "\n", MAXTESTS);
22 void fileSave(gchar *filename) {
23 if (testList != NULL) {
24 gchar *contents = g_strjoinv("\n", testList);
25 GError *error = NULL;
26 if (g_file_set_contents(filename, contents, -1, &error) == FALSE) {
27 g_error_free(error);
32 void fileClose() {
33 if (testList != NULL) {
34 g_strfreev(testList);