diff options
| author | Martin Owens <doctormo@gmail.com> | 2017-07-02 14:47:03 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2017-07-02 14:47:03 +0000 |
| commit | 7dc5626af3eb924fa381c46491cd49178a78cd73 (patch) | |
| tree | e50a3b98ce1393b7a06efbd11425f8c458b0cbbb /src/extension/init.cpp | |
| parent | pyc files are generated when testing modules, ignore them (diff) | |
| download | inkscape-7dc5626af3eb924fa381c46491cd49178a78cd73.tar.gz inkscape-7dc5626af3eb924fa381c46491cd49178a78cd73.zip | |
Move directory scanners to new get_filenames(...) calls
Diffstat (limited to 'src/extension/init.cpp')
| -rw-r--r-- | src/extension/init.cpp | 66 |
1 files changed, 4 insertions, 62 deletions
diff --git a/src/extension/init.cpp b/src/extension/init.cpp index a40196a74..9830b0176 100644 --- a/src/extension/init.cpp +++ b/src/extension/init.cpp @@ -117,7 +117,6 @@ namespace Extension { the extension directory and parsed */ #define SP_MODULE_EXTENSION "inx" -static void build_module_from_domain(Domain domain); static void check_extensions(); /** @@ -154,8 +153,7 @@ update_pref(Glib::ustring const &pref_path, * Invokes the init routines for internal modules. * * This should be a list of all the internal modules that need to initialized. This is just a - * convinent place to put them. Also, this function calls build_module_from_domain to parse the - * Inkscape extensions directory. + * convinent place to put them. */ void init() @@ -246,8 +244,9 @@ init() Internal::Filter::Filter::filters_all(); - build_module_from_domain(USER); - build_module_from_domain(SYSTEM); + for(auto &filename: get_filenames(EXTENSIONS, {SP_MODULE_EXTENSION})) { + build_from_file(filename.c_str()); + } /* this is at the very end because it has several catch-alls * that are possibly over-ridden by other extensions (such as @@ -267,63 +266,6 @@ init() ); } -/** - * \return none - * \brief This function parses a directory for files of SP_MODULE_EXTENSION - * type and loads them. - * \param dirname The directory that should be searched for modules - * - * Here is just a basic function that moves through a directory. It looks at every entry, and - * compares its filename with SP_MODULE_EXTENSION. Of those that pass, build_from_file is called - * with their filenames. - */ -static void -build_module_from_domain(Domain domain) -{ - char const *dirname = get_path(domain, EXTENSIONS); - - if (!dirname) { - g_warning("%s", _("Null external module directory name. Modules will not be loaded.")); - return; - } - - if (!Glib::file_test(std::string(dirname), Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)) { - return; - } - - // TODO: We may have to get to why this is needed, since it seems redundent. - Inkscape::Extension::Extension::search_path.push_back(dirname); - - GError *err; - GDir *directory = g_dir_open(dirname, 0, &err); - if (!directory) { - gchar *safeDir = Inkscape::IO::sanitizeString(dirname); - g_warning(_("Modules directory (%s) is unavailable. External modules in that directory will not be loaded."), safeDir); - g_free(safeDir); - return; - } - - gchar *filename; - while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) { - if (strlen(filename) < strlen(SP_MODULE_EXTENSION)) { - continue; - } - - if (strcmp(SP_MODULE_EXTENSION, filename + (strlen(filename) - strlen(SP_MODULE_EXTENSION)))) { - continue; - } - - gchar *pathname = g_build_filename(dirname, filename, (char *) NULL); - build_from_file(pathname); - g_free(pathname); - } - - g_dir_close(directory); - - return; -} - - static void check_extensions_internal(Extension *in_plug, gpointer in_data) { |
