Add _cdio_strdup_fixpath for absolute paths handling in MinGW
* MinGW may provide absolute paths in the form /c/directory/... to native calls that require instead c:/directory
This commit is contained in:
@@ -38,6 +38,8 @@
|
||||
#include "inttypes.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include <cdio/types.h>
|
||||
#include <cdio/util.h>
|
||||
@@ -136,6 +138,29 @@ _cdio_strdup_upper (const char str[])
|
||||
return new_str;
|
||||
}
|
||||
|
||||
/* Convert MinGW/MSYS paths that start in "/c/..." to "c:/..."
|
||||
so that they can be used with fopen(), stat(), etc. */
|
||||
char *
|
||||
_cdio_strdup_fixpath (const char path[])
|
||||
{
|
||||
char *new_path = NULL;
|
||||
|
||||
if (path)
|
||||
{
|
||||
new_path = strdup (path);
|
||||
#if defined(_WIN32)
|
||||
if (new_path && (strlen (new_path) >= 3) && (new_path[0] == '/') &&
|
||||
(new_path[2] == '/') && (isalpha (new_path[1])))
|
||||
{
|
||||
new_path[0] = new_path[1];
|
||||
new_path[1] = ':';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return new_path;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
cdio_to_bcd8 (uint8_t n)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user