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

get application path directory

New Here ,
Nov 15, 2010 Nov 15, 2010

Copy link to clipboard

Copied

hy,

i'm trying to create a plug-in that run an application located in the same directory of the plug-in file.

If i do

system("./Rec.app/Contents/MacOS/AlbumExpressRecord");

the application search the file in my home directory.

Is there a function in the SDK that say me wath is the path of Photoshop directory???

Thank you

TOPICS
SDK

Views

1.5K

Translate

Translate

Report

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
Adobe
Contributor ,
Nov 15, 2010 Nov 15, 2010

Copy link to clipboard

Copied

sSPPlugins->GetPluginFileSpecification(pluginRef, &outFileSpec) from SPPluginsSuite is probably what you are looking for

Votes

Translate

Translate

Report

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
New Here ,
Nov 16, 2010 Nov 16, 2010

Copy link to clipboard

Copied

hy thank you for your asnwer.

i do this things:

I take the Dissolve project.

Modify the "PluginMain" adding:

    SPPluginsSuite* sSPPlugins;
    // Use the Basic Suite as describe in the chapter of that name
    // and to acquire the suite
    SPErr error = sBasic->AcquireSuite( kSPPluginsSuite, kSPPluginsSuiteVersion, &sSPPlugins );
    if ( error ) goto error;
    sSPPlugins->GetPluginFileSpecification(pluginRef, &outFileSpec);

and including at the top

     #include "SPPlugs.h"
     #include "SPAdapts.h"

but i've many compilation error.

1) sBasic is not declarated in this scope

2) pluginRef was not declered in this scope.

What can i do? What is my pluginRef?

Thank you!

Votes

Translate

Translate

Report

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
New Here ,
Nov 16, 2010 Nov 16, 2010

Copy link to clipboard

Copied

I hope you can help me becouse  this plug-in is very simple, it must execute a file in the same  directory where the plugin is installed.

If i execute system("./Appname.app/Contents/MacOS/AppName"); the plugin search in my home directory (on windows and on MacOS).


i try to write:

     SPPluginsSuite* sSPPlugins;
        
     SPPluginRef fPluginRef = message->d.self;


    SPPlatformFileSpecification filespec;
    
     sSPPlugins->GetPluginFileSpecification(message->d.self, &fileSpec);
    
     filespec.mReference
    
     ai::FilePath path(platformFileSpec);
     std::cout << path.GetFullPath().as_Platform() << std::endl;

but i have several errors.

Thank you

Votes

Translate

Translate

Report

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
Participant ,
Nov 20, 2010 Nov 20, 2010

Copy link to clipboard

Copied

What are the errors, specifically?

Votes

Translate

Translate

Report

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
Community Beginner ,
Nov 21, 2010 Nov 21, 2010

Copy link to clipboard

Copied

An FSSpec is the best we can do? Please tell me there's a way that doesn't use deprecated types and supports 64-bit? (Sorry, that's more of a rhetorical question to Adobe than directed at you).

#if __LP64__

typedef struct SPPlatformFileSpecification { /* this handles unicode file names */

FSRef mReference;

}  SPPlatformFileSpecification;

#else

typedef struct SPPlatformFileSpecification { /* Various things are casting this to FSSpec, so make sure the layout matches */

/** The version number. */

FSVolumeRefNum vRefNum;

/** The unique identifier. */

SInt32 parID;

/** The file name string.  */

StrFileName name;

} SPPlatformFileSpecification;

#endif

typedef struct SPPlatformFileSpecificationW { /* this handles unicode file names */

FSRef mReference;

} SPPlatformFileSpecificationW;

------------------------------------------------------------------------------

So I guess we only get modern types if we're 64 bits. I haven't touched an FSSpec in the last 8 years...

Votes

Translate

Translate

Report

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
New Here ,
Nov 23, 2010 Nov 23, 2010

Copy link to clipboard

Copied

Hi guys,

i solve this problem.

This is the solution

#ifdef __APPLE__
        CFBundleRef mainBundle = CFBundleGetMainBundle();
        CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
        char path[PATH_MAX];
        if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
        {
            //error!
        }
        CFRelease(resourcesURL);
        chdir(path);
        printf("Current Path: %s",path);      

#endif

Thank you for your help!!!

Votes

Translate

Translate

Report

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
Community Beginner ,
Nov 23, 2010 Nov 23, 2010

Copy link to clipboard

Copied

LATEST

Ahh, I wondered about using NS/CFBundle, but wasn't sure.

If you're using Cocoa, that could pretty much be reduced to a single line:

#ifdef __APPLE__

    const char *path = [[[NSBundle mainBundle] resourcePath] fileSystemRepresentation];

     if (!path) {

            //error!

     }

     chdir(path);
     printf("Current Path: %s",path);     

#endif

Votes

Translate

Translate

Report

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