fopen woes in xcode

Hey everyone. I’ve been trying to get gl2ps working so I can export vector images. It seemed to work fine except it didn’t actually create any files.

So I backed up a few steps and tried getting any fopen commands to run, and they dont seem to work either. this is what I’m trying to run:

  
  
FILE * pFile;  
		  pFile = fopen ("myfile.txt","w");  
		  if (pFile!=NULL)  
		  {  
			fputs ("fopen example",pFile);  
			printf( "success" );  
			fclose (pFile);  
		  }  
  

It prints success, but it doesnt create any files… has anyone else ran into this? or any thoughts on what might be going on? I’m so confused.

Thanks!

you know that theo’s ofxVectorGraphics does outputting and works on all platforms?

for saving files, note with care that mac apps are in “.app” packages that are three levels deep. if you explore package contents, you’ll find your stuff. if you want to save to the level of where you click, it’s like: …/…/…/ caludio and I saw this the other day with the issue he posted on the forum re: raw files. this is why we use the data folder, so mac apps look for …/…/…/data while all other platforms look for data.

you can try using ofToDataPath(). It returns a string, so with fopen you will need to convert to char * using c_str(). it will take any file name and make it be found / saved in the data folder. like:

  
  
  
FILE * pFile;  
        pFile = fopen (ofToDataPath("myfile.txt").c_str(),"w");  
        if (pFile!=NULL)  
        {  
         fputs ("fopen example",pFile);  
         printf( "success" );  
         fclose (pFile);  
        }   
  

ciao!
zach

Ahhhhh… awesome. thanks zach!

Yeah i would use theo’s except i really need transparency

ahh yeah - I think maybe version 2 we will have to add pdf support for ofxVectorGraphics - then alpha won’t be a problem.

:slight_smile: