Warning, /graphics/krita/3rdparty/ext_mlt/0001-macOS-allow-finding-plugins-outside-bundles.patch is written in an unsupported language. File is not indexed.

0001 From 38ef302db9ae8b41c5158f4b44fbbe1ef8636b60 Mon Sep 17 00:00:00 2001
0002 From: Ivan Yossi <ghevan@gmail.com>
0003 Date: Fri, 26 Jan 2024 19:57:17 +0100
0004 Subject: [PATCH 1/2] [macOS] allow finding plugins outside bundles
0005 
0006 This allows to load mlt plugins from install directory when the
0007 .app is missing Plugins and Resources locations.
0008 
0009 The patch is not robust, its designed to change from one static
0010 location to another when running krita.app from a kritadev environment
0011 when the bundle dirs are missing: this only happens when running
0012 krita.app from install directory after building.
0013 
0014 changes are:
0015 i/bin/krita.app/Contents/Plugins/mlt -> i/lib/mlt
0016 i/bin/krita.app/Contents/Resources/mlt -> i/share/mlt
0017 ---
0018  src/framework/mlt_factory.c | 25 +++++++++++++++++++++++++
0019  1 file changed, 25 insertions(+)
0020 
0021 diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c
0022 index 16469aa1..bee8eb9f 100644
0023 --- a/src/framework/mlt_factory.c
0024 +++ b/src/framework/mlt_factory.c
0025 @@ -52,6 +52,7 @@
0026  #endif
0027  #ifdef __APPLE__
0028  #include <mach-o/dyld.h>
0029 +#include <dirent.h>
0030  /** the default subdirectory of the libdir for holding modules (plugins) */
0031  #define PREFIX_LIB "/PlugIns/mlt"
0032  /** the default subdirectory of the install prefix for holding module (plugin) data */
0033 @@ -64,6 +65,24 @@
0034  #endif
0035  #endif
0036  
0037 +#ifdef __APPLE__
0038 +void mlt_apple_relocate_mltdirectory(char **path, char* basepath, char* altpath)
0039 +{
0040 +       DIR *pdir = opendir(*path);
0041 +
0042 +       if ( !pdir ) {
0043 +               memset(*path,0,strlen(*path));
0044 +
0045 +               size_t size = strlen(basepath);
0046 +               strncpy( *path, basepath, size - 23);
0047 +               strcat( *path, altpath);
0048 +       } else {
0049 +               closedir(pdir);
0050 +       }
0051 +       return;
0052 +}
0053 +#endif
0054 +
0055  /** holds the full path to the modules directory - initialized and retained for the entire session */
0056  static char *mlt_directory = NULL;
0057  /** a global properties list for holding environment config data and things needing session-oriented cleanup */
0058 @@ -182,12 +201,18 @@ mlt_repository mlt_factory_init(const char *directory)
0059                  mlt_directory = calloc(1, size + strlen(PREFIX_DATA) + 1);
0060                  strcpy(mlt_directory, exedir);
0061                  strcat(mlt_directory, PREFIX_DATA);
0062 +#ifdef __APPLE__
0063 +                mlt_apple_relocate_mltdirectory(&mlt_directory, exedir, "/share/mlt");
0064 +#endif 
0065                  mlt_properties_set(global_properties, "MLT_DATA", mlt_directory);
0066                  free(mlt_directory);
0067              }
0068              mlt_directory = calloc(1, size + strlen(PREFIX_LIB) + 1);
0069              strcpy(mlt_directory, exedir);
0070              strcat(mlt_directory, PREFIX_LIB);
0071 +#ifdef __APPLE__
0072 +            mlt_apple_relocate_mltdirectory(&mlt_directory, exedir, "/lib/mlt");
0073 +#endif
0074          }
0075  #endif
0076  
0077 -- 
0078 2.23.0.windows.1
0079