struct cfh cfh = { 0 };
struct lfh lfh = { 0 };
- char *temp;
+ char *temp, *p;
int j;
uint64_t src_used, dst_used;
}
- if (cfh.ext_attrs & EXT_ATTR_DIR || cfh.name[cfh.name_len - 1] == '/') {
+ if (cfh.ext_attrs & EXT_ATTR_DIR || (p = strrchr (cfh.name, '/'))) {
+ if (p) { *p = '\0'; }
+
if (state->exdir) {
- if (!(temp = malloc (strlen (state->exdir) + 1 + cfh.name_len + 1))) {
+ if (!(temp = malloc (strlen (state->exdir) + 1 + strlen (cfh.name) + 1))) {
report_at (program_name, 0, REPORT_ERROR, "not enough free memory for name");
+
+ if (p) { *p = '/'; }
break;
}
sprintf (temp, "%s%c%s", state->exdir, ch, cfh.name);
- if (!is_relative (temp + strlen (state->exdir) + 1, cfh.name_len)) {
+ if (!is_relative (temp + strlen (state->exdir) + 1, strlen (cfh.name))) {
free (temp);
free (cfh.name);
} else {
- if (!(temp = malloc (cfh.name_len + 1))) {
+ if (!(temp = malloc (strlen (cfh.name) + 1))) {
report_at (program_name, 0, REPORT_ERROR, "not enough free memory for name");
- free (cfh.name);
-
- if (cfh.comment) { free (cfh.comment); }
- if (cfh.extra) { free (cfh.extra); }
- memset (&cfh, 0, sizeof (cfh));
+ if (p) { *p = '/'; }
break;
}
sprintf (temp, "%s", cfh.name);
- if (!is_relative (temp, cfh.name_len)) {
+ if (!is_relative (temp, strlen (cfh.name))) {
free (temp);
free (cfh.name);
}
- if (temp[strlen (temp) - 1] == '/') {
- temp[strlen (temp) - 1] = '\0';
- }
-
#if defined (unix) || defined (__unix) || defined (__unix__) || defined (__APPLE__)
if (!stat (temp, &sb)) {
- if (S_ISDIR (sb.st_mode)) {
+ if (!S_ISDIR (sb.st_mode)) {
- free (temp);
- free (cfh.name);
+ report_at (program_name, 0, REPORT_ERROR, "%s exists but is not a directory", temp);
- if (cfh.comment) { free (cfh.comment); }
- if (cfh.extra) { free (cfh.extra); }
-
- memset (&cfh, 0, sizeof (cfh));
- continue;
+ free (temp);
+ break;
}
-
- report_at (program_name, 0, REPORT_ERROR, "%s exists but is not a directory", temp);
-
- free (temp);
- break;
+ } else {
+ printf (" creating: %s%c\n", temp, ch);
}
#elif defined (_WIN32)
if (dwAttrib != INVALID_FILE_ATTRIBUTES) {
- if (dwAttrib & FILE_ATTRIBUTE_DIRECTORY) {
+ if (!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) {
- free (temp);
- free (cfh.name);
-
- if (cfh.comment) { free (cfh.comment); }
- if (cfh.extra) { free (cfh.extra); }
+ report_at (program_name, 0, REPORT_ERROR, "%s exists but is not a directory", temp);
- memset (&cfh, 0, sizeof (cfh));
- continue;
+ free (temp);
+ break;
+ } else {
+ printf (" creating: %s%c\n", temp, ch);
}
-
- report_at (program_name, 0, REPORT_ERROR, "%s exists but is not a directory", temp);
-
- free (temp);
- break;
}
#endif
- printf (" creating: %s%c\n", temp, ch);
-
if (make_directory (temp)) {
report_at (program_name, 0, REPORT_ERROR, "failed to create %s", state->exdir);
}
+ if (p) { *p = '/'; }
free (temp);
- continue;
+
+ if (cfh.ext_attrs & EXT_ATTR_DIR || cfh.name[cfh.name_len - 1] == '/') {
+
+ free (cfh.name);
+
+ if (cfh.comment) { free (cfh.comment); }
+ if (cfh.extra) { free (cfh.extra); }
+
+ memset (&cfh, 0, sizeof (cfh));
+ continue;
+
+ }
}