OSDN Git Service

Change skip behavior on extracting.
[lha/lha.git] / src / lhext.c
index 5c2a53a..842b3e0 100644 (file)
@@ -30,7 +30,7 @@ static void add_dirinfo(char* name, LzHeader* hdr);
 static void adjust_dirinfo();
 
 #ifdef HAVE_LIBAPPLEFILE
-static boolean decode_macbinary(FILE *ofp, size_t size, const char *outPath);
+static boolean decode_macbinary(FILE *ofp, off_t size, const char *outPath);
 #endif
 
 /* ------------------------------------------------------------------------ */
@@ -198,6 +198,23 @@ open_with_make_path(name)
 }
 
 /* ------------------------------------------------------------------------ */
+static int
+symlink_with_make_path(realname, name)
+    const char     *realname;
+    const char     *name;
+{
+    int l_code;
+
+    l_code = symlink(realname, name);
+    if (l_code < 0) {
+        make_parent_path(name);
+        l_code = symlink(realname, name);
+    }
+
+    return l_code;
+}
+
+/* ------------------------------------------------------------------------ */
 static void
 adjust_info(name, hdr)
     char           *name;
@@ -415,11 +432,11 @@ extract_one(afp, hdr)
 
             if (skip_flg == TRUE) { /* if skip_flg */
                 if (stat(name, &stbuf) == 0 && force != TRUE) {
-                    if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) {
+                    /* if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) {*/
                         if (quiet != TRUE)
                             printf("%s : Skipped...\n", name);
                         return read_size;
-                    }
+                    /* } */
                 }
             }
             if (noexec) {
@@ -498,19 +515,20 @@ extract_one(afp, hdr)
                     if (up_flag == FALSE && force == FALSE) {
                         return read_size;
                     }
-                } else {
+                }
+
+                if (skip_flg == TRUE) { /* if skip_flg */
                     if (GETSTAT(name, &stbuf) == 0 && force != TRUE) {
-                        if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) {
+                        /* if (stbuf.st_mtime >= hdr->unix_last_modified_stamp) { */
                             if (quiet != TRUE)
                                 printf("%s : Skipped...\n", name);
                             return read_size;
-                        }
+                        /* } */
                     }
                 }
 
                 unlink(name);
-                make_parent_path(name);
-                l_code = symlink(hdr->realname, name);
+                l_code = symlink_with_make_path(hdr->realname, name);
                 if (l_code < 0) {
                     if (quiet != TRUE)
                         warning("Can't make Symbolic Link \"%s\" -> \"%s\"",
@@ -736,7 +754,7 @@ decode_macbinary(ofp, size, outPath)
     af_file_t *afp = NULL;
     FILE *ifp = NULL;
     unsigned char *datap;
-    off_t dlen;
+    size_t dlen;
 
     if ((afp = af_open(temporary_name)) != NULL) {
         /* fetch datafork */