Skip to main content
Inspiring
September 2, 2017
Answered

AEGP_GetOutSpecFilePath

  • September 2, 2017
  • 1 reply
  • 765 views

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.

This topic has been closed for replies.

1 reply

RGPattAuthor
Inspiring
September 2, 2017

Well... It seems POSIX works just fine:

        fileDesc = open(string, O_WRONLY);

       

        bytesWritten = write(fileDesc, &header, headerBytes);

       

        bytesWritten = write(fileDesc, bufferPtr, imageBytes);

       

        err = close(fileDesc);

Or at least it writes files.  I'm getting some junk in the files I still have to sort out, but...

RGPattAuthor
Inspiring
September 7, 2017

Actually none of this seems to be working any more.  I upgraded to OS 10.12 on a new iMac and I can see that the unicode_path_memH contains the path in it, but I cannot for the life of me figure out how to reliably extract a path that I can use with to open a file in OS 10.12.  Surely there is some simple way to do this.  I found a helpful bit of code in a post from several years ago that shows how to do it in Windows and just says use the appropriate function on the Mac.

Can anyone please help me.  I've been beating my head against the wall with this for several days.

Thanks.