Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Enthusiast ,
May 26, 2010 May 26, 2010

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

TOPICS
Scripting
3.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2010 May 26, 2010

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2010 May 26, 2010

Also, if it's any help:

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

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.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 26, 2010 May 26, 2010

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2010 May 26, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 26, 2010 May 26, 2010

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 26, 2010 May 26, 2010
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines