18 |
* MA 02110-1301 USA * |
* MA 02110-1301 USA * |
19 |
***************************************************************************/ |
***************************************************************************/ |
20 |
|
|
21 |
|
#define _BSD_SOURCE 1 /* for realpath() */ |
22 |
|
|
23 |
#include <algorithm> |
#include <algorithm> |
24 |
#include <cassert> |
#include <cassert> |
25 |
#include <cstdio> |
#include <cstdio> |
120 |
dmsg(2, ("linuxsampler: Deactivate\n")); |
dmsg(2, ("linuxsampler: Deactivate\n")); |
121 |
} |
} |
122 |
|
|
123 |
|
static String RealPath(const String& path) |
124 |
|
{ |
125 |
|
String out = path; |
126 |
|
char* cpath = NULL; |
127 |
|
#ifdef _WIN32 |
128 |
|
cpath = (char*)malloc(MAX_PATH); |
129 |
|
GetFullPathName(path.c_str(), MAX_PATH, cpath, NULL); |
130 |
|
#else |
131 |
|
cpath = realpath(path.c_str(), NULL); |
132 |
|
#endif |
133 |
|
if (cpath) { |
134 |
|
out = cpath; |
135 |
|
free(cpath); |
136 |
|
} |
137 |
|
return out; |
138 |
|
} |
139 |
|
|
140 |
String PluginLv2::PathToState(const String& path) { |
String PluginLv2::PathToState(const String& path) { |
141 |
if (MapPath) { |
if (MapPath) { |
142 |
char* cstr = MapPath->abstract_path(MapPath->handle, path.c_str()); |
char* cstr = MapPath->abstract_path(MapPath->handle, path.c_str()); |
150 |
String PluginLv2::PathFromState(const String& path) { |
String PluginLv2::PathFromState(const String& path) { |
151 |
if (MapPath) { |
if (MapPath) { |
152 |
char* cstr = MapPath->absolute_path(MapPath->handle, path.c_str()); |
char* cstr = MapPath->absolute_path(MapPath->handle, path.c_str()); |
153 |
const String abstract_path(cstr); |
// Resolve symbolic links so SFZ sample paths load correctly |
154 |
|
const String absolute_path(RealPath(cstr)); |
155 |
free(cstr); |
free(cstr); |
156 |
return abstract_path; |
return absolute_path; |
157 |
} |
} |
158 |
return path; |
return path; |
159 |
} |
} |