Hi there,
I'm trying to get the current project path and store it to wstring variable, and later convert it to A_Char to show it on reportinfo.
Following code works correctly on Windows 7 64bit and project path is displayed with ReportInfo dialog box, but on macosx 10.6.8, projectPathW.length() is always nonzero even when no project is opened. And ReportInfo always shows empty string.
AEGP_ProjectH project;
AEGP_MemHandle pathH;
suites.ProjSuite5()->AEGP_GetProjectByIndex(0, &project);
if (project) {
err = suites.ProjSuite5()->AEGP_GetProjectPath(project, &pathH);
if (!err)
{
A_UTF16Char *pathText;
err = suites.MemorySuite1()->AEGP_LockMemHandle(pathH, (void**)&pathText);
if (!err)
{
wstring projectPathW((wchar_t*)pathText);
if (projectPathW.length() == 0)
{
suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id,"empty string");
}
else
{
char *fileName = (char *)malloc( AEGP_MAX_PATH_SIZE );
wcstombs( fileName, projectPathW.c_str(), AEGP_MAX_PATH_SIZE );
suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id,fileName);
free(fileName);
}
}
suites.MemorySuite1()->AEGP_UnlockMemHandle(pathH);
ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(pathH));
}
}
I'm coming in a bit late on this one... but it's worth noting that wchar_t is 16-bit on Win, but 32-bit on MacOS. So A_UTF16Char and wchar_t are not interchangable on MacOS. Search for the sample code copyConvertStringLiteralIntoUTF16() in the SDK for a not-so-pretty example of how to handle this.
Zac:
There are two two issues here:
Mac uses UTF-8 and Windows needs UTF-16. After Effects gives UTF-16 but it is easy to convert for Mac plug-ins. This is not a problem. We are used to that. wchar_t is an issue on the Mac so I aviod wchar_t and stick with UTF-16.
The real problem is that we do not get the GetProjectPath() in AE until rendering. That means we have no idea of that until too late. GetProjectPath() returns NULL.
North America
Europe, Middle East and Africa
Asia Pacific