aboutsummaryrefslogtreecommitdiffstats
path: root/mediaplugin/src/mediaplugins/include
diff options
context:
space:
mode:
Diffstat (limited to 'mediaplugin/src/mediaplugins/include')
-rw-r--r--mediaplugin/src/mediaplugins/include/core/plugin_core.h11
-rw-r--r--mediaplugin/src/mediaplugins/include/core/util.h46
2 files changed, 39 insertions, 18 deletions
diff --git a/mediaplugin/src/mediaplugins/include/core/plugin_core.h b/mediaplugin/src/mediaplugins/include/core/plugin_core.h
index 69cc7f19..0979b992 100644
--- a/mediaplugin/src/mediaplugins/include/core/plugin_core.h
+++ b/mediaplugin/src/mediaplugins/include/core/plugin_core.h
@@ -111,6 +111,9 @@ typedef struct{} thread_t;
typedef struct pluginCore_t {
int version;
+ void* PLUGIN_CALL (*memAlloc)(int size);
+ void PLUGIN_CALL (*memFree)(void* ptr);
+
void PLUGIN_CALL (*log)(int level, const char *msg, const char *context);
uint32_t PLUGIN_CALL (*ticksMillis)();
@@ -121,6 +124,14 @@ typedef struct pluginCore_t {
int64_t PLUGIN_CALL (*fileSeek)(fileStream_t *stream, int64_t pos, int whence);
int64_t PLUGIN_CALL (*fileSize)(fileStream_t *stream);
+ // Note: result string must be freed with memFree()
+ const char* PLUGIN_CALL (*pathToNative)(const char *path);
+ // Note: result string must be freed with memFree()
+ const char* PLUGIN_CALL (*pathToUTF8)(const char *path, BOOL useNativeDelim);
+ // Note: result string must be freed with memFree()
+ wchar_t* PLUGIN_CALL (*pathToWide)(const char *path, BOOL useNativeDelim);
+ BOOL PLUGIN_CALL (*pathIsFile)(const char *path);
+
thread_t* PLUGIN_CALL (*threadCreate)(int (PLUGIN_CALL *fn)(void *), void *data);
uint32_t PLUGIN_CALL (*threadCurrentID)();
uint32_t PLUGIN_CALL (*threadGetID)(thread_t *thread);
diff --git a/mediaplugin/src/mediaplugins/include/core/util.h b/mediaplugin/src/mediaplugins/include/core/util.h
index ba7ae2a4..6b402774 100644
--- a/mediaplugin/src/mediaplugins/include/core/util.h
+++ b/mediaplugin/src/mediaplugins/include/core/util.h
@@ -99,35 +99,45 @@ public:
//AudioFormatInfo copy();
};
-class IPath {
+class Path {
private:
std::string _filename;
public:
- IPath(const char *filename) :
- _filename(filename)
- {
- // TODO
- }
+ Path(const char *filename) :
+ _filename(filename) {}
- IPath(std::string filename) :
- _filename(filename)
- {
- // TODO
- }
+ Path(std::string filename) :
+ _filename(filename) {}
std::string toNative() const {
- // TODO
- return _filename;
+ const char* cstr = pluginCore->pathToNative(_filename.c_str());
+ std::string result(cstr);
+ pluginCore->memFree((void*)cstr);
+ return result;
+ }
+
+ std::string toUTF8(bool useNativeDelim = true) const {
+ const char* cstr = pluginCore->pathToUTF8(_filename.c_str(),
+ useNativeDelim ? TRUE : FALSE);
+ std::string result(cstr);
+ pluginCore->memFree((void*)cstr);
+ return result;
}
- std::string toUTF8() const {
- // TODO
- return _filename;
+// TODO: wchar_t sizes differ on Windows (2 byte)/Linux (4 byte).
+// USDX uses the Pascal WideChar type which is 2 bytes in size.
+#ifdef _WIN32
+ std::wstring toWide(bool useNativeDelim = true) const {
+ const wchar_t* cstr = pluginCore->pathToWide(_filename.c_str(),
+ useNativeDelim ? TRUE : FALSE);
+ std::wstring result(cstr);
+ pluginCore->memFree((void*)cstr);
+ return result;
}
+#endif
bool isFile() const {
- // TODO
- return true;
+ return pluginCore->pathIsFile(_filename.c_str());
}
};