add code for OS-specific path separator
authorJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 17 Sep 2002 05:37:21 +0000 (05:37 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 17 Sep 2002 05:37:21 +0000 (05:37 +0000)
src/flac/file.c

index 0a9f3bd..29c8643 100644 (file)
 #include <string.h> /* for strrchr() */
 #include "file.h"
 
+#if defined unix || defined __CYGWIN__ || defined __CYGWIN32__
+static const char path_separator_ = '/';
+#elif defined WIN32 || defined _MSC_VER || defined __MINGW32__
+static const char path_separator_ = '\\';
+#else
+#error Can't determine native path separator
+#endif
+
 void flac__file_copy_metadata(const char *srcpath, const char *destpath)
 {
        struct stat srcstat;
@@ -64,12 +72,9 @@ const char *flac__file_get_basename(const char *srcpath)
 {
        const char *p;
 
-       p = strrchr(srcpath, '\\');
-       if(0 == p) {
-               p = strrchr(srcpath, '/');
-               if(0 == p)
-                       return srcpath;
-       }
+       p = strrchr(srcpath, path_separator_);
+       if(0 == p)
+               return srcpath;
        return ++p;
 }