Quantcast
Channel: Adobe Community : Popular Discussions - InDesign SDK
Viewing all articles
Browse latest Browse all 78596

Problem with FileUtils::CopyFile() CS4 Mac

$
0
0

Hi all,

 

I'm trying to copy some files from within my plugin into the Script Folder but the files don't get copied. I can create files within the folder and I also reach the files within the plugin (I think). Where is my mistake?

 

 

// The code     const int MAXITEMS = 12;                    PMString scriptfiles[MAXITEMS] = {               "scriptfile01.jsx",               "scriptfile02.jsx",               "scriptfile03.jsx",               "scriptfile04.jsx",               "scriptfile05.jsx",               "scriptfile06.jsx",               "scriptfile07.jsx",               "scriptfile08.jsx",               "scriptfile09.jsx",               "scriptfile10.jsx",               "scriptfile11.jsx",               "scriptfile12.jsx"};                    PMString newscriptfiles[MAXITEMS] = {               "newscriptfile01.jsx",               "newscriptfile02.jsx",               "newscriptfile03.jsx",               "newscriptfile04.jsx",               "newscriptfile05.jsx",               "newscriptfile06.jsx",               "newscriptfile07.jsx",               "newscriptfile08.jsx",               "newscriptfile09.jsx",               "newscriptfile10.jsx",               "newscriptfile11.jsx",               "newscriptfile12.jsx"};          


for (int i = 0; i < MAXITEMS ; i++) {               


// go to the the source files
               IDFile theSource;//scriptfiles[i];                              FileUtils::GetPackageFolder(&theSource);               FileUtils::AppendPath(&theSource, PMString("Versions"));                              FileUtils::AppendPath(&theSource, PMString("A"));                              FileUtils::AppendPath(&theSource, PMString("Resources"));                              FileUtils::AppendPath(&theSource, PMString(scriptfiles[i]));


// if i call the files within the package
// he seems to find them
                              //PMString filename = theSource.GetFileName();               //CAlert::InformationAlert(filename);


// go to the the target files
                                             IDFile theTarget;               FileUtils::GetAppInstallationFolder(&theTarget);               FileUtils::AppendPath(&theTarget, PMString("Scripts"));                              FileUtils::AppendPath(&theTarget, PMString("Scripts Panel"));               FileUtils::AppendPath(&theTarget, PMString("MPO Launcher"));


//if the folder doesn't exist
               FileUtils::CreateFolderIfNeeded(theTarget,kTrue);


// get the new names
               PMString fn( newscriptfiles[i]);                              FileUtils::AppendPath(&theTarget, fn);


// if i use OpenFile it creates the files
//FileUtils::OpenFile(theTarget, "w");


// and this doesnt work. Why?
FileUtils::CopyFile(theSource, theTarget);
}

Viewing all articles
Browse latest Browse all 78596

Trending Articles