Skip to content

Commit

Permalink
Fix - copy device name when make path on windows. (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba-- authored Oct 30, 2018
1 parent 6026a35 commit 64aa7b4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
#include "miniz.h"
#include "zip.h"

#ifndef HAS_DEVICE
#define HAS_DEVICE(P) 0
#endif

#ifndef FILESYSTEM_PREFIX_LEN
#define FILESYSTEM_PREFIX_LEN(P) 0
#endif
Expand Down Expand Up @@ -75,10 +79,17 @@ static int mkpath(const char *path) {
char const *p;
char npath[MAX_PATH + 1];
int len = 0;
int has_device = HAS_DEVICE(path);

memset(npath, 0, MAX_PATH + 1);
for (p = path; *p && len < MAX_PATH; p++) {
if (ISSLASH(*p) && len > 0) {
if (has_device) {
// only on windows
npath[0] = path[0];
npath[1] = path[1];
len = 2;
}
for (p = path + len; *p && len < MAX_PATH; p++) {
if (ISSLASH(*p) && ((!has_device && len > 0) || (has_device && len > 2))) {
if (MKDIR(npath) == -1)
if (errno != EEXIST)
return -1;
Expand Down

0 comments on commit 64aa7b4

Please sign in to comment.