Skip to main content
Participant
January 27, 2021
Answered

[URGENT] Permission denied error while writing to a txt file using fopen() in ProjDumper example

  • January 27, 2021
  • 1 reply
  • 571 views

The goal of my AEGP plugin is to print out RGB values of all pixels in a frame to a txt file.
I'm trying to use ProjDumper example's implementation of using fopen() to write to a txt file, however, the plugin when run in debug environment returns 'Error: Permission Denied'


I've tried to give 'read & write' permission to Adobe After Effects 2020/Plugins folder and even the After Effects SDK/Examples/AEGP/ folder. But, I still get the same error.

Here's my code that's trying to write a file.

if (frameH){
   ERR(suites.WorldSuite3()->AEGP_FillOutPFEffectWorld(frameH, &pFrame));
   out = std::fopen("./test_ae_dump.txt", "w+");
   if (out) {
        for (int i = 0; i < dimen_h; i++) {
           for (int j = 0; j < dimen_w; j++) {
              PF_Pixel *myPixel = sampleIntegral32(pFrame, j, i);
              std::cout << "x: " << j << " | y: " << i << std::endl;
              std::cout << int(myPixel->red) << " | " << int(myPixel->green) << " | " << int(myPixel->blue) << std::endl;
              std::fprintf(out, "x: %d | y: %d \nr: %d | g: %d | b: %d", j, i, int(myPixel->red), int(myPixel->green), int(myPixel->blue));
           }
       }
       std::fclose(out);
    } else {
       std::cout << "FILE could be initiated" << out << std::endl;
       std::perror("Error");
    }
}

 
This is the final step in my plugin that I need working as soon as possible. Not sure what is causing this problem. Let me know if you need more information about my setup or anything else.

This topic has been closed for replies.
Correct answer Arie Stavchansky

What happens when you choose a path outside of Adobe's installation folder?  That your user created?

1 reply

Arie StavchanskyCorrect answer
Legend
January 27, 2021

What happens when you choose a path outside of Adobe's installation folder?  That your user created?

Ishan27Author
Participant
January 27, 2021

Okay, that solved it.
As you suggested, I used absolute path like this

out = std::fopen("/Users/ishan/Documents/test_ae_dump.txt", "w+");

and that did write to a new file at the stated location.
Thanks a lot!