00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <libheraia.h>
00026
00027 static void verify_preference_file_path_presence(gchar *pathname);
00028 static void verify_preference_file_name_presence(gchar *filename);
00029
00034 static void verify_preference_file_path_presence(gchar *pathname)
00035 {
00036 struct stat *buf = NULL;
00037 gint result = 0;
00038
00039 buf = (struct stat *) g_malloc0(sizeof(struct stat));
00040 result = g_stat(pathname, buf);
00041
00042 if (result != 0)
00043 {
00044 g_mkdir_with_parents(pathname, 488);
00045 }
00046 }
00047
00051 static void verify_preference_file_name_presence(gchar *filename)
00052 {
00053 FILE *fp = NULL;
00054
00055
00056
00057 fp = g_fopen(filename, "r");
00058
00059 if (fp == NULL)
00060 {
00061 fp = g_fopen(filename, "w");
00062 if (fp == NULL)
00063 {
00064 fprintf(stderr, "Unable to open and create the main preference file %s\n", filename);
00065 }
00066 else
00067 {
00068 fprintf(stderr, "Main preference file %s created successfully\n", filename);
00069 fclose(fp);
00070 }
00071 }
00072 else
00073 {
00074 fclose(fp);
00075 }
00076 }
00077
00082 void verify_preference_file(gchar *pathname, gchar *filename)
00083 {
00084
00085 verify_preference_file_path_presence(pathname);
00086 verify_preference_file_name_presence(filename);
00087
00088 }