foxygit / fake-08-xbox360 Log in
commit 620634c51f2ae37179f620cc4d64d055596c8c22
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Mon Oct 24 22:58:23 2022 -0600
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sat Aug 26 19:20:43 2023 -0600

    Get windows libretro build working

    add macro for windows mkdir
    detect windows directory slashes
---
 platform/libretro/libretrohosthelpers.h |  5 +++++
 source/filehelpers.cpp                  | 14 ++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/platform/libretro/libretrohosthelpers.h b/platform/libretro/libretrohosthelpers.h
index e898bf3..b18a872 100644
--- a/platform/libretro/libretrohosthelpers.h
+++ b/platform/libretro/libretrohosthelpers.h
@@ -1,5 +1,10 @@
 #include <string.h>

+#if (defined(_WIN32) || defined(__WIN32__))
+#include <direct.h> /* _mkdir */
+#define mkdir(A, B) _mkdir(A)
+#endif
+
 void setInputState(
     uint8_t kDown,
     uint8_t kHeld,
diff --git a/source/filehelpers.cpp b/source/filehelpers.cpp
index fc9a6fc..9af5385 100644
--- a/source/filehelpers.cpp
+++ b/source/filehelpers.cpp
@@ -66,10 +66,10 @@ std::vector<unsigned char> get_file_buffer(std::string filename){

 //https://stackoverflow.com/a/8518855
 std::string getDirectory(const std::string& fname){
-     size_t pos = fname.find_last_of("\\/");
-     return (std::string::npos == pos)
-         ? ""
-         : fname.substr(0, pos);
+    size_t pos = fname.find_last_of("\\/");
+    return (std::string::npos == pos)
+        ? ""
+        : fname.substr(0, pos);
 }

 bool isAbsolutePath (std::string const &path) {
@@ -79,12 +79,14 @@ bool isAbsolutePath (std::string const &path) {

     if (path[0] == '/') {
         return true;
-    }
+    }

     size_t colonPos = path.find_first_of(":");
     size_t slashPos = path.find_first_of("/");
+    size_t backSlashPos = path.find_first_of("\\");

-    if (colonPos != std::string::npos && slashPos == (colonPos + 1)){
+    if (colonPos != std::string::npos &&
+        (slashPos == (colonPos + 1) || backSlashPos == (colonPos + 1))){
         return true;
     }