[FIX] remove screenshot directory prior to creation
authorNikita Kalyazin <n.kalyazin@samsung.com>
Wed, 18 Sep 2013 08:23:44 +0000 (12:23 +0400)
committerNikita Kalyazin <n.kalyazin@samsung.com>
Wed, 18 Sep 2013 08:25:00 +0000 (12:25 +0400)
Solves this issue (which actually is a warning):
[ERR] (start_profiling):Failed to create directory for screenshot : errno(17)

Change-Id: Ic7c4dbaca43b7dd58c5583ce3aff81f6ae9144b1
Signed-off-by: Nikita Kalyazin <n.kalyazin@samsung.com>
daemon/daemon.c

index 633cd36..a9df087 100644 (file)
@@ -410,11 +410,11 @@ int start_profiling()
 
        // remove previous screen capture files
        remove_indir(SCREENSHOT_DIR);
-       if(mkdir(SCREENSHOT_DIR, 0777) < 0)
-       {
-               LOGE("Failed to create directory for screenshot : errno(%d)\n", errno);
-       }
-
+       if (unlink(SCREENSHOT_DIR) == -1)
+               LOGW("Cannot remove screenshot dir: %s\n", strerror(errno));
+       if (mkdir(SCREENSHOT_DIR, 0777) == -1)
+               LOGW("Failed to create directory for screenshot : %s\n",
+                    strerror(errno));
 
 #ifndef LOCALTEST
        smack_lsetlabel(SCREENSHOT_DIR, "*", SMACK_LABEL_ACCESS);