changeset 2451:44b77654c406

Add DW_DIR_SEPARATOR for easy access to the separator characters. There is something similar in dwcompat.h but I don't want to require including dwcompat.h on Unix, in case dwcompat isn't built.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 10 Apr 2021 20:11:43 +0000
parents 2c03987c95bd
children 8a12b4caf6b9
files dw.h dwtest.c
diffstat 2 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Sat Apr 10 20:09:58 2021 +0000
+++ b/dw.h	Sat Apr 10 20:11:43 2021 +0000
@@ -347,8 +347,8 @@
 #include <pthread.h>
 #include <dlfcn.h>
 
-/* Unfortunately using we can't import Cocoa.h
- * or UIKit.h from C code, so we have to instead
+/* Unfortunately we can't import Cocoa.h or
+ * UIKit.h from C code, so we have to instead
  * use opaque types and use the values from
  * the headers here directly without using the
  * symbolic names.
@@ -1359,8 +1359,11 @@
 typedef CTIME *PCTIME;
 #endif
 
-#if defined(__OS2__) || (defined(__WIN32__) && !defined(GDK_WINDOWING_WIN32)) || (defined(WINNT) && !defined(GDK_WINDOWING_WIN32)) || defined(__EMX__)
+/* Define a few things missing on OS/2 and Windows */
+#if defined(__OS2__) || (defined(__WIN32__) && !defined(GDK_WINDOWING_WIN32)) || \
+    (defined(WINNT) && !defined(GDK_WINDOWING_WIN32)) || defined(__EMX__)
 typedef unsigned long DWTID;
+#define DW_DIR_SEPARATOR '\\'
 #endif
 
 /* Some dark mode constants for supported platforms */
@@ -1577,6 +1580,10 @@
 #define DW_FCF_COMPOSITED        0
 #endif
 
+#ifndef DW_DIR_SEPARATOR
+#define DW_DIR_SEPARATOR '/'
+#endif
+
 #ifndef API
 #define API
 #endif
--- a/dwtest.c	Sat Apr 10 20:09:58 2021 +0000
+++ b/dwtest.c	Sat Apr 10 20:11:43 2021 +0000
@@ -1151,11 +1151,7 @@
         int pos = (int)strlen(appdir);
         
         strncpy(pathbuff, appdir, 1024);
-#if defined(__OS2__) || defined(__WIN32__)
-        pathbuff[pos] = '\\';
-#else
-        pathbuff[pos] = '/';
-#endif
+        pathbuff[pos] = DW_DIR_SEPARATOR;
         pos++;
         strncpy(&pathbuff[pos], "test", 1024-pos);
         image = dw_pixmap_new_from_file(textbox2, pathbuff);
@@ -2151,11 +2147,7 @@
         int pos = (int)strlen(appdir);
 
         strncpy(pathbuff, appdir, 1024);
-#if defined(__OS2__) || defined(__WIN32__)
-        pathbuff[pos] = '\\';
-#else
-        pathbuff[pos] = '/';
-#endif
+        pathbuff[pos] = DW_DIR_SEPARATOR;
         pos++;
         strncpy(&pathbuff[pos], FOLDER_ICON_NAME, 1024-pos);
         foldericon = dw_icon_load_from_file(pathbuff);