[TSAM-8601] corrected folder creation logic 54/91054/1
authorshubham kumar <shubham.srib@samsung.com>
Wed, 5 Oct 2016 11:55:20 +0000 (17:25 +0530)
committershubham kumar <shubham.srib@samsung.com>
Wed, 5 Oct 2016 11:55:20 +0000 (17:25 +0530)
Change-Id: Ia7b80f8213ce35bca2b1dc323447f035fa2de5c0
Signed-off-by: shubham kumar <shubham.srib@samsung.com>
src/common/file-operation/mf-miniunzip.c

index 12f2846..35e39ec 100644 (file)
@@ -48,44 +48,7 @@ int mf_create_new_dir(const char* dirname)
 
 int mf_create_dir(char *newdir)
 {
-       char *buffer ;
-       char *p;
-       int  len = (int)strlen(newdir);
-
-       if (len <= 0) {
-               return 0;
-       }
-
-       buffer = (char*)malloc(len+1);
-       strncpy(buffer,newdir, strlen(newdir));
-
-       if (buffer[len-1] == '/') {
-               buffer[len-1] = '\0';
-       }
-       if (mf_create_new_dir(buffer) == 0) {
-               free(buffer);
-               return 1;
-       }
-
-       p = buffer+1;
-       while (1) {
-               char hold;
-
-               while(*p && *p != '\\' && *p != '/')
-                       p++;
-               hold = *p;
-               *p = 0;
-               if ((mf_create_new_dir(buffer) == -1) && (errno == ENOENT)) {
-                       mf_debug("couldn't create directory %s\n",buffer);
-                       free(buffer);
-                       return 0;
-               }
-               if (hold == 0) {
-                       break;
-               }
-               *p++ = hold;
-       }
-       free(buffer);
+       mf_create_new_dir(newdir);
        return 1;
 }
 
@@ -260,11 +223,10 @@ int mf_do_extract_currentfile(unzFile uf, const int* popt_extract_without_path,
 
                        if ((skip==0) && (err==UNZ_OK)) {
                                fout=fopen(write_filename,"wb");
-
                                /* some zipfile don't contain directory alone before file */
                                if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
-                                               (filename_withoutpath!=(char*)filename_inzip)) {
-                                       char c=*(filename_withoutpath-1);
+                                               strcmp(filename_withoutpath, filename_inzip)) {
+                                       char c = *(filename_withoutpath-1);
                                        *(filename_withoutpath-1)='\0';
                                        mf_create_dir(write_filename);
                                        *(filename_withoutpath-1)=c;