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
Copy link to clipboard
Copied
sSPPlugins->GetPluginFileSpecification(pluginRef, &outFileSpec) from SPPluginsSuite is probably what you are looking for
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!
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
Copy link to clipboard
Copied
What are the errors, specifically?
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...
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!!!
Copy link to clipboard
Copied
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