From ba4e19ad9823cae11725cff476b13e5116f792f7 Mon Sep 17 00:00:00 2001 From: Rich Hornung Date: Wed, 14 Aug 2024 15:26:24 -0700 Subject: [PATCH] attempt to fix windows build errors --- src/common/OutputUtils.cpp | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/common/OutputUtils.cpp b/src/common/OutputUtils.cpp index e49775579..087728d28 100644 --- a/src/common/OutputUtils.cpp +++ b/src/common/OutputUtils.cpp @@ -21,8 +21,44 @@ #include #include + #if defined(_WIN32) #include + +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 @@ -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(); @@ -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();