Commit 7f1abc84 authored by Josh Coalson's avatar Josh Coalson
Browse files

add code for OS-specific path separator

parent b776793a
...@@ -33,6 +33,14 @@ ...@@ -33,6 +33,14 @@
#include <string.h> /* for strrchr() */ #include <string.h> /* for strrchr() */
#include "file.h" #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) void flac__file_copy_metadata(const char *srcpath, const char *destpath)
{ {
struct stat srcstat; struct stat srcstat;
...@@ -64,12 +72,9 @@ const char *flac__file_get_basename(const char *srcpath) ...@@ -64,12 +72,9 @@ const char *flac__file_get_basename(const char *srcpath)
{ {
const char *p; const char *p;
p = strrchr(srcpath, '\\'); p = strrchr(srcpath, path_separator_);
if(0 == p) { if(0 == p)
p = strrchr(srcpath, '/'); return srcpath;
if(0 == p)
return srcpath;
}
return ++p; return ++p;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment