Skip to content

Commit

Permalink
attempt to fix windows build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rhornung67 committed Aug 14, 2024
1 parent 8e79316 commit ba4e19a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/common/OutputUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,44 @@

#include<sys/types.h>
#include<sys/stat.h>

#if defined(_WIN32)
#include<io.h>

typedef int mode_t;

/// @Note If STRICT_UGO_PERMISSIONS is not defined, then setting Read for any
/// of User, Group, or Other will set Read for User and setting Write
/// will set Write for User. Otherwise, Read and Write for Group and
/// Other are ignored.
///
/// @Note For the POSIX modes that do not have a Windows equivalent, the modes
/// defined here use the POSIX values left shifted 16 bits.

static const mode_t S_ISUID = 0x08000000; ///< does nothing
static const mode_t S_ISGID = 0x04000000; ///< does nothing
static const mode_t S_ISVTX = 0x02000000; ///< does nothing
static const mode_t S_IRUSR = mode_t(_S_IREAD); ///< read by user
static const mode_t S_IWUSR = mode_t(_S_IWRITE); ///< write by user
static const mode_t S_IXUSR = 0x00400000; ///< does nothing
# ifndef STRICT_UGO_PERMISSIONS
static const mode_t S_IRGRP = mode_t(_S_IREAD); ///< read by *USER*
static const mode_t S_IWGRP = mode_t(_S_IWRITE); ///< write by *USER*
static const mode_t S_IXGRP = 0x00080000; ///< does nothing
static const mode_t S_IROTH = mode_t(_S_IREAD); ///< read by *USER*
static const mode_t S_IWOTH = mode_t(_S_IWRITE); ///< write by *USER*
static const mode_t S_IXOTH = 0x00010000; ///< does nothing
# else
static const mode_t S_IRGRP = 0x00200000; ///< does nothing
static const mode_t S_IWGRP = 0x00100000; ///< does nothing
static const mode_t S_IXGRP = 0x00080000; ///< does nothing
static const mode_t S_IROTH = 0x00040000; ///< does nothing
static const mode_t S_IWOTH = 0x00020000; ///< does nothing
static const mode_t S_IXOTH = 0x00010000; ///< does nothing
# endif

static const mode_t MS_MODE_MASK = 0x0000ffff; ///< low word

#endif

namespace rajaperf
Expand Down Expand Up @@ -104,7 +140,11 @@ std::string recursiveMkdir(const std::string& in_path)
* path before sliding along path_buf.
*/
if ( !outpath.empty() && pos < 0) {
#if defined(_WIN32)
if (_mkdir(path_buf, mode) != 0) {
#else
if (mkdir(path_buf, mode) != 0) {
#endif
getCout() << " Cannot create directory = "
<< path_buf << std::endl;
outpath = std::string();
Expand All @@ -129,7 +169,11 @@ std::string recursiveMkdir(const std::string& in_path)

/* make directory if not at end of path */
if (pos < length) {
#if defined(_WIN32)
if (_mkdir(path_buf, mode) != 0) {
#else
if (mkdir(path_buf, mode) != 0) {
#endif
getCout() << " Cannot create directory = "
<< path_buf << std::endl;
outpath = std::string();
Expand Down

0 comments on commit ba4e19a

Please sign in to comment.