Skip to content

Commit

Permalink
Rename Windows open/remove functions
Browse files Browse the repository at this point in the history
  • Loading branch information
derobins committed Mar 18, 2024
1 parent 73f788a commit 6bb220b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 10 additions & 8 deletions src/H5system.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,16 +514,17 @@ H5_get_utf16_str(const char *s)
} /* end H5_get_utf16_str() */

/*-------------------------------------------------------------------------
* Function: Wopen_utf8
* Function: Wopen
*
* Purpose: UTF-8 equivalent of open(2) for use on Windows
* Purpose: Equivalent of open(2) for use on Windows. Necessary to
* handle code pages and Unicode on that platform.
*
* Return: Success: A POSIX file descriptor
* Failure: -1
*-------------------------------------------------------------------------
*/
int
Wopen_utf8(const char *path, int oflag, ...)
Wopen(const char *path, int oflag, ...)
{
int fd = -1; /* POSIX file descriptor to be returned */
wchar_t *wpath = NULL; /* UTF-16 version of the path */
Expand Down Expand Up @@ -573,19 +574,20 @@ Wopen_utf8(const char *path, int oflag, ...)
H5MM_xfree(wpath);

return fd;
} /* end Wopen_utf8() */
} /* end Wopen() */

/*-------------------------------------------------------------------------
* Function: Wremove_utf8
* Function: Wremove
*
* Purpose: UTF-8 equivalent of remove(3) for use on Windows.
* Purpose: Equivalent of remove(3) for use on Windows. Necessary to
* handle code pages and Unicode on that platform.
*
* Return: Success: 0
* Failure: -1
*-------------------------------------------------------------------------
*/
int
Wremove_utf8(const char *path)
Wremove(const char *path)
{
wchar_t *wpath = NULL; /* UTF-16 version of the path */
int ret = -1;
Expand Down Expand Up @@ -619,7 +621,7 @@ Wremove_utf8(const char *path)
H5MM_xfree(wpath);

return ret;
} /* end Wremove_utf8() */
} /* end Wremove() */

#endif /* H5_HAVE_WIN32_API */

Expand Down
12 changes: 6 additions & 6 deletions src/H5win32defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct timezone {
};
#endif

#define HDcreat(S, M) Wopen_utf8(S, O_CREAT | O_TRUNC | O_RDWR, M)
#define HDcreat(S, M) Wopen(S, O_CREAT | O_TRUNC | O_RDWR, M)
#define HDflock(F, L) Wflock(F, L)
#define HDfstat(F, B) _fstati64(F, B)
#define HDftell(F) _ftelli64(F)
Expand All @@ -59,13 +59,13 @@ struct timezone {
*/
#if (defined(_MSC_VER) && !defined(_MSVC_TRADITIONAL)) || _MSVC_TRADITIONAL
/* Using the MSVC traditional preprocessor */
#define HDopen(S, F, ...) Wopen_utf8(S, F, __VA_ARGS__)
#define HDopen(S, F, ...) Wopen(S, F, __VA_ARGS__)
#else
/* Using a standards conformant preprocessor */
#define HDopen(S, F, ...) Wopen_utf8(S, F, ##__VA_ARGS__)
#define HDopen(S, F, ...) Wopen(S, F, ##__VA_ARGS__)
#endif

#define HDremove(S) Wremove_utf8(S)
#define HDremove(S) Wremove(S)
#define HDsetenv(N, V, O) Wsetenv(N, V, O)
#define HDsetvbuf(F, S, M, Z) setvbuf(F, S, M, (Z > 1 ? Z : 2))
#define HDsleep(S) Sleep(S * 1000)
Expand All @@ -89,8 +89,8 @@ H5_DLL int Wsetenv(const char *name, const char *value, int overwrite);
H5_DLL int Wflock(int fd, int operation);
H5_DLL herr_t H5_expand_windows_env_vars(char **env_var);
H5_DLL wchar_t *H5_get_utf16_str(const char *s);
H5_DLL int Wopen_utf8(const char *path, int oflag, ...);
H5_DLL int Wremove_utf8(const char *path);
H5_DLL int Wopen(const char *path, int oflag, ...);
H5_DLL int Wremove(const char *path);
H5_DLL int H5_get_win32_times(H5_timevals_t *tvs);
H5_DLL char *H5_strndup(const char *s, size_t n);
H5_DLL char *Wstrcasestr_wrap(const char *haystack, const char *needle);
Expand Down

0 comments on commit 6bb220b

Please sign in to comment.