AEGP_GetOutSpecFilePath
I'm trying to write an output module plugin for Mac and I have hit a brick wall trying to open and write to a file using the unicode path provided by After Effects.
Can anyone see what I am doing wrong here:
ERR(suites.IOOutSuite4()->AEGP_GetOutSpecFilePath(outH, &unicode_path_memH, &fileReservedB));
ERR(suites.MemorySuite1()->AEGP_LockMemHandle(unicode_path_memH, reinterpret_cast<void **>(&unicode_pathP)));
nsStringPath = [NSString stringWithCharacters:(unicode_pathP) length:AEGP_MAX_PATH_SIZE];
const char *string = [nsStringPath UTF8String];
NSLog (@"%s", string);
NSLog (@"%@",nsStringPath);
//check whether the output file exist, if not create a new one.
outputFileManager = [NSFileManager defaultManager];
if ([outputFileManager fileExistsAtPath: nsStringPath ] == NO)
{
NSLog (@"Output file does not exist, creating a new one");
[outputFileManager createFileAtPath: nsStringPath
contents: nil
attributes: nil];
if ([outputFileManager fileExistsAtPath: nsStringPath ] == NO)
{
NSLog (@"Why didn't that create a file at %@",nsStringPath);
}
}
outputFileHandle = [NSFileHandle fileHandleForWritingAtPath: nsStringPath];
if (outputFileHandle == nil)
{
NSLog (@"Output file still does not exist, creating a new one didn't work");
}
The NSLog entries show as:
9/2/17 3:39:47.119 PM After Effects[656]: /ColorManagement/*MWA/OutputTest/Characterize_00000.dpx
9/2/17 3:39:48.055 PM After Effects[656]: /ColorManagement/*MWA/OutputTest/Characterize_00000.dpx
9/2/17 3:40:43.509 PM After Effects[656]: Output file does not exist, creating a new one
9/2/17 3:40:52.085 PM After Effects[656]: Why didn't that create a file at /ColorManagement/*MWA/OutputTest/Characterize_00000.dpx
So it appears to me that I have put the unicode path into an NSString without mangling it, but it thinks the file does not exist and refusing to create one. I thought perhaps somebody didn't like the * in the file path (which I was using just to make the directory show up at the top of the list) but I tried it without it and it still fails.
First of all does the file exist when I am given this path? My plug in seems to create a sequence of empty files when I let it run.
Secondly should I not be using NSFileManager and NSFileHandle in a plugin? What is the simplest way to open and write to a file on a Mac using this unicode path?
Any help or suggestions would be greatly appreciated.
Thanks.
