Skip to content

Commit d7bd04b

Browse files
author
Oleh Kulykov
committed
1722286171
1 parent 77df22c commit d7bd04b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/plzma_path_utils.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ namespace pathUtils {
104104
template<>
105105
inline bool pathExists(const char * LIBPLZMA_NONNULL path, bool * LIBPLZMA_NULLABLE isDir) noexcept {
106106
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
107+
# if defined(LIBPLZMA_MINGW)
108+
if (::_access(path, F_OK) == 0) {
109+
# else
107110
if (::_access(path, 0) == 0) {
111+
# endif
108112
if (isDir) {
109113
struct _stat statbuf;
110114
if ((::_stat(path, &statbuf) == 0) && (S_ISDIR(statbuf.st_mode))) {
@@ -188,7 +192,11 @@ namespace pathUtils {
188192
template<>
189193
inline bool pathReadable(const wchar_t * LIBPLZMA_NONNULL path) noexcept {
190194
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
195+
# if defined(defined(LIBPLZMA_MINGW))
196+
return (::_waccess(path, R_OK) == 0);
197+
# else
191198
return (::_waccess(path, 4) == 0);
199+
# endif
192200
#else
193201
assert(0);
194202
return false;
@@ -198,7 +206,11 @@ namespace pathUtils {
198206
template<>
199207
inline bool pathReadable(const char * LIBPLZMA_NONNULL path) noexcept {
200208
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
209+
# if defined(LIBPLZMA_MINGW)
210+
return (::_access(path, R_OK) == 0);
211+
# else
201212
return (::_access(path, 4) == 0);
213+
# endif
202214
#elif defined(LIBPLZMA_POSIX)
203215
return (::access(path, R_OK) == 0);
204216
#endif
@@ -210,7 +222,11 @@ namespace pathUtils {
210222
template<>
211223
inline bool pathWritable(const wchar_t * LIBPLZMA_NONNULL path) noexcept {
212224
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
225+
# if defined(LIBPLZMA_MINGW)
226+
return (::_waccess(path, W_OK) == 0);
227+
# else
213228
return (::_waccess(path, 2) == 0);
229+
# endif
214230
#else
215231
assert(0);
216232
return false;
@@ -220,7 +236,11 @@ namespace pathUtils {
220236
template<>
221237
inline bool pathWritable(const char * LIBPLZMA_NONNULL path) noexcept {
222238
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
239+
# if defined(LIBPLZMA_MINGW)
240+
return (::_access(path, W_OK) == 0);
241+
# else
223242
return (::_access(path, 2) == 0);
243+
# endif
224244
#elif defined(LIBPLZMA_POSIX)
225245
return (::access(path, W_OK) == 0);
226246
#endif
@@ -232,7 +252,11 @@ namespace pathUtils {
232252
template<>
233253
inline bool pathReadableAndWritable(const wchar_t * LIBPLZMA_NONNULL path) noexcept {
234254
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
255+
# if defined(LIBPLZMA_MINGW)
256+
return (::_waccess(path, R_OK | W_OK) == 0);
257+
# else
235258
return (::_waccess(path, 6) == 0);
259+
# endif
236260
#else
237261
assert(0);
238262
return false;
@@ -242,7 +266,11 @@ namespace pathUtils {
242266
template<>
243267
inline bool pathReadableAndWritable(const char * LIBPLZMA_NONNULL path) noexcept {
244268
#if defined(LIBPLZMA_MSC) || defined(LIBPLZMA_MINGW)
269+
# if defined(LIBPLZMA_MINGW)
270+
return (::_access(path, R_OK | W_OK) == 0);
271+
# else
245272
return (::_access(path, 6) == 0);
273+
# endif
246274
#elif defined(LIBPLZMA_POSIX)
247275
return (::access(path, R_OK | W_OK) == 0);
248276
#endif

0 commit comments

Comments
 (0)