Browse Source

Made sure /etc directories exists

Fredrik Haikarainen 10 years ago
parent
commit
cbb147b4e7
1 changed files with 20 additions and 1 deletions
  1. 20
    1
      src/light.c

+ 20
- 1
src/light.c View File

5
 #include <string.h>
5
 #include <string.h>
6
 #include <unistd.h>
6
 #include <unistd.h>
7
 #include <getopt.h>
7
 #include <getopt.h>
8
+#include <sys/stat.h>
9
+#include <errno.h>
8
 
10
 
9
 void light_defaultConfig()
11
 void light_defaultConfig()
10
 {
12
 {
205
 
207
 
206
 LIGHT_BOOL light_initialize(int argc, char** argv)
208
 LIGHT_BOOL light_initialize(int argc, char** argv)
207
 {
209
 {
210
+  int mkdirVal;
211
+
208
   light_defaultConfig();
212
   light_defaultConfig();
209
   if(!light_parseArguments(argc, argv))
213
   if(!light_parseArguments(argc, argv))
210
   {
214
   {
216
   {
220
   {
217
       return TRUE;
221
       return TRUE;
218
   }
222
   }
219
-  
223
+
224
+  /* Make sure we have a valid /etc/light directory, as well as /etc/light/mincap */
225
+  mkdirVal = mkdir("/etc/light", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
226
+  if(mkdirVal != 0 && errno != EEXIST)
227
+  {
228
+    LIGHT_ERR("/etc/light does not exist and could not be created");
229
+    return FALSE;
230
+  }
231
+
232
+  mkdirVal = mkdir("/etc/light/mincap", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
233
+  if(mkdirVal != 0 && errno != EEXIST)
234
+  {
235
+    LIGHT_ERR("/etc/light/mincap does not exist and could not be created");
236
+    return FALSE;
237
+  }
238
+
220
   /* Make sure we have a valid controller before we proceed */
239
   /* Make sure we have a valid controller before we proceed */
221
   if(light_Configuration.controllerMode == LIGHT_AUTO)
240
   if(light_Configuration.controllerMode == LIGHT_AUTO)
222
   {
241
   {