mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-21 11:42:02 +02:00
Fix remove dir under Windows
This commit is contained in:
parent
37ae88e9b2
commit
e5c6bb477a
@ -58,6 +58,17 @@ static ssize_t pread(int fd, void* buf, size_t size, off_t off)
|
|||||||
return -1;
|
return -1;
|
||||||
return read(fd, buf, size);
|
return read(fd, buf, size);
|
||||||
}
|
}
|
||||||
|
static int remove_file_or_dir(char const* path)
|
||||||
|
{
|
||||||
|
int rc = remove(path);
|
||||||
|
#ifdef WIN32
|
||||||
|
if (rc < 0 && errno == EACCESS)
|
||||||
|
rc = rmdir(path);
|
||||||
|
#endif
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define remove_file_or_dir(path) remove(path)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check if specified location is local for current node */
|
/* Check if specified location is local for current node */
|
||||||
@ -715,7 +726,7 @@ int fio_unlink(char const* path, fio_location location)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return remove(path);
|
return remove_file_or_dir(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1343,7 +1354,7 @@ void fio_communicate(int in, int out)
|
|||||||
SYS_CHECK(symlink(buf, buf + strlen(buf) + 1));
|
SYS_CHECK(symlink(buf, buf + strlen(buf) + 1));
|
||||||
break;
|
break;
|
||||||
case FIO_UNLINK: /* Remove file or directory (TODO: Win32) */
|
case FIO_UNLINK: /* Remove file or directory (TODO: Win32) */
|
||||||
SYS_CHECK(remove(buf));
|
SYS_CHECK(remove_file_or_dir(buf));
|
||||||
break;
|
break;
|
||||||
case FIO_MKDIR: /* Create direcory */
|
case FIO_MKDIR: /* Create direcory */
|
||||||
hdr.size = 0;
|
hdr.size = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user