6 Replies Latest reply on May 26, 2010 5:36 AM by John Hawkinson

    [CS4/JS] Cannot find Folder.appData on a Mac

    Ian Proudfoot Level 3

      I'm using ExtendScript with InDesign CS4. Developing on Windows, but the users will also use Macs.

      Everything works well on both platforms but I get inconsistent results with File and Folder objects on the Mac.

       

      So this works perfectly on Windows:

       

      var savePng = new File (Folder.appData +'/ProjectName/Resources/save.png');

       

      But it fails on the Mac. Yes I believe that I have followed the instructions in the JavaScript tools Guide, so what am I missing. I admit to having very little experience of the way the Mac uses file and folder paths so perhaps it's obvious to some of you?

       

      Thank you

       

      Ian

        • 1. Re: [CS4/JS] Cannot find Folder.appData on a Mac
          John Hawkinson Level 5

          How does it fail?

           

          On this Mac, the JavaScript console says:

           

          Folder.appData
          Result: /Library/Application%20Support
          

           

          And "/Library/Application Support" should not be writable by normal users (only the superuser). Why did you want appData? Do you need persistant storage across multiple users?

          • 2. Re: [CS4/JS] Cannot find Folder.appData on a Mac
            John Hawkinson Level 5

            Also, if it's any help:

             

            { var p=Folder, pr=p.reflect.properties; for (i in pr)  $.writeln(pr[i]+"\t"+p[pr[i]])}

             

             

             

            prototype[object Folder]
            fsMacintosh
            current/Applications/Adobe%20InCopy%20CS3/Adobe%20InCopy%20CS3.app/Contents/MacOS
            startup/Applications/Adobe%20InCopy%20CS3/Adobe%20InCopy%20CS3.app/Contents/MacOS
            appPackage/Applications/Adobe%20InCopy%20CS3/Adobe%20InCopy%20CS3.app
            system/System
            trash~/.Trash
            temp/private/var/folders/Sp/SpQckt-vHf01M0CWQR9UjE+++TM/TemporaryItems
            userData~/Library/Application%20Support
            appData/Library/Application%20Support
            commonFiles/Library/Application%20Support
            myDocuments~/Documents
            desktop~/Desktop
            reflect[object Reflection]
            argumentsnull
            length1
            arity1
            nameFolder
            __proto__

             

             

            (Yes, I cheated, this is InCopy CS3 not InDesign CS4. It's handy and in front of me, and I'm pretty sure it's effectively the same for this purpose.)

            1 person found this helpful
            • 3. Re: [CS4/JS] Cannot find Folder.appData on a Mac
              Ian Proudfoot Level 3

              Hi John,

               

              It fails with a 'File or folder does not exist' error.

               

              The problem is that the file really is located in the path shown below, but it can't be found.

               

              /Library/Application%20Support/ProjectName/Resources/save.png

               

              My reason for using that location is so that all of the resources such as the png files that are used by ScriptUI dialogs and various XML configuration files are located in one place. Would you suggest a different location? is there a typical or best way to 'install' a complex ExtendScript application so that it all works well on Mac and Windows?

               

              Thanks for your help,

               

              Ian

              • 4. Re: [CS4/JS] Cannot find Folder.appData on a Mac
                John Hawkinson Level 5

                Oh, I think you're being tripped up by the URL-encoding/escaping. Try using Folder.appData.fsName instead (to get spaces instead of %20s).

                 

                I don't have a good suggestion on location, nor am I sure about Best Practice. That seems a reasonable place to install, but my first guess was you were having a permissions problem writing to a file there. Obviousy that's not it though.

                • 5. Re: [CS4/JS] Cannot find Folder.appData on a Mac
                  Muppet Mark-QAl63s Level 4

                  Try using Folder property 'userData' instead of 'appData' this should direct you to '~/Library/Application Support' note the tilde '~' Im guessing you should not have problems permission in the users home environment. You code worked for me without decoding the path but Im logged in as admin so I do have access to '/Library/Application Support' at system level.

                  1 person found this helpful
                  • 6. Re: [CS4/JS] Cannot find Folder.appData on a Mac
                    John Hawkinson Level 5

                    Hmm.mmm.mmm. savePng.parent.getFiles() will tell you if the pathname is being resolved properly (it should give you a list of files in

                    the parent directory). If that fails, try walking up the tree (.parent, .parent.parent, etc.) to see where it's breaking?