+static int is_dir_exist(const char *fmt, ...)
+{
+ va_list arg;
+ struct stat st;
+ char path[4096];
+
+ va_start(arg, fmt);
+ vsnprintf(path, sizeof(path), fmt, arg);
+ va_end(arg);
+
+ memset(&st, 0, sizeof(st));
+ if (stat(path, &st) < 0)
+ {
+ return 0;
+ }
+
+ if (st.st_mode & S_IFDIR)
+ {
+ return 1;
+ }
+
+ return 0;
+}
+
+static void touch_new_file(char *filename)
+{
+ char *pos = NULL;
+ FILE *fp = NULL;
+
+ if (access(filename, F_OK) == -1)
+ {
+ for (pos = filename; *pos; pos++)
+ {
+ if (*pos == '/')
+ {
+ *pos = 0;
+ if (!is_dir_exist("%s", filename))
+ {
+ mkdir(filename, 0755);
+ }
+ *pos = '/';
+ }
+ }
+
+ fp = fopen(filename, "w+");
+ if (fp)
+ {
+ fclose(fp);
+ }
+ }
+}
+