diff options
author | Nikita Nemkin | 2021-08-12 13:21:06 +0000 |
---|---|---|
committer | Sravan Kumar Lakkimsetti | 2021-08-13 10:54:27 +0000 |
commit | 77d581a19fa8f51448063d43bf3c0548f6dc3160 (patch) | |
tree | bfd8c11a49b0b1a8bcc839d7d139675fb211ee6f | |
parent | 83a5587641097f0e88b5c6699aed67384987a680 (diff) | |
download | rt.equinox.framework-77d581a19fa8f51448063d43bf3c0548f6dc3160.tar.gz rt.equinox.framework-77d581a19fa8f51448063d43bf3c0548f6dc3160.tar.xz rt.equinox.framework-77d581a19fa8f51448063d43bf3c0548f6dc3160.zip |
Bug 114567 - [launcher] Splash screen support for other image formats (Part 2)
Extend the list of potential splash screen image files to include
splash.png, splash.jpg, splash.jpeg, splash.gif, splash.bmp.
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
Change-Id: Ic06df273480e56cf60e20300a194ff392dffffe8
Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.framework/+/183963
Tested-by: Equinox Bot <equinox-bot@eclipse.org>
Reviewed-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
4 files changed, 61 insertions, 46 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF index 586eb8a83..e51c25b5b 100644 --- a/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.launcher;singleton:=true -Bundle-Version: 1.6.200.qualifier +Bundle-Version: 1.6.300.qualifier Main-Class: org.eclipse.equinox.launcher.Main Bundle-ClassPath: . Bundle-Vendor: %providerName diff --git a/bundles/org.eclipse.equinox.launcher/pom.xml b/bundles/org.eclipse.equinox.launcher/pom.xml index c64033692..70e8d21b4 100644 --- a/bundles/org.eclipse.equinox.launcher/pom.xml +++ b/bundles/org.eclipse.equinox.launcher/pom.xml @@ -19,6 +19,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.launcher</artifactId> - <version>1.6.200-SNAPSHOT</version> + <version>1.6.300-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java index 522fae7cb..d37984add 100644 --- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java +++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java @@ -160,7 +160,12 @@ public class Main { private static final String OVERRIDE_VMARGS = "--launcher.overrideVmargs"; //$NON-NLS-1$ private static final String NL = "-nl"; //$NON-NLS-1$ private static final String ENDSPLASH = "-endsplash"; //$NON-NLS-1$ - private static final String SPLASH_IMAGE = "splash.bmp"; //$NON-NLS-1$ + private static final String[] SPLASH_IMAGES = {"splash.png", //$NON-NLS-1$ + "splash.jpg", //$NON-NLS-1$ + "splash.jpeg", //$NON-NLS-1$ + "splash.gif", //$NON-NLS-1$ + "splash.bmp", //$NON-NLS-1$ + }; private static final String CLEAN = "-clean"; //$NON-NLS-1$ private static final String NOEXIT = "-noExit"; //$NON-NLS-1$ private static final String OS = "-os"; //$NON-NLS-1$ @@ -2335,8 +2340,8 @@ public class Main { * Build an array of path suffixes based on the given NL which is suitable * for splash path searching. The returned array contains paths in order * from most specific to most generic. So, in the FR_fr locale, it will return - * "nl/fr/FR/splash.bmp", then "nl/fr/splash.bmp", and finally "splash.bmp". - * (we always search the root) + * candidates in "nl/fr/FR/", then "nl/fr/", and finally in the root. + * Candidate names are defined in SPLASH_IMAGES and include splash.png, splash.jpg, etc. */ private static String[] buildNLVariants(String locale) { //build list of suffixes for loading resource bundles @@ -2344,14 +2349,18 @@ public class Main { ArrayList<String> result = new ArrayList<>(4); int lastSeparator; while (true) { - result.add("nl" + File.separatorChar + nl.replace('_', File.separatorChar) + File.separatorChar + SPLASH_IMAGE); //$NON-NLS-1$ + for (String name : SPLASH_IMAGES) { + result.add("nl" + File.separatorChar + nl.replace('_', File.separatorChar) + File.separatorChar + name); //$NON-NLS-1$ + } lastSeparator = nl.lastIndexOf('_'); if (lastSeparator == -1) break; nl = nl.substring(0, lastSeparator); } //add the empty suffix last (most general) - result.add(SPLASH_IMAGE); + for (String name : SPLASH_IMAGES) { + result.add(name); + } return result.toArray(new String[result.size()]); } diff --git a/features/org.eclipse.equinox.executable.feature/library/eclipse.c b/features/org.eclipse.equinox.executable.feature/library/eclipse.c index f3ab12442..79356d3da 100644 --- a/features/org.eclipse.equinox.executable.feature/library/eclipse.c +++ b/features/org.eclipse.equinox.executable.feature/library/eclipse.c @@ -273,6 +273,9 @@ home directory."); #define EE_FILENAME _T_ECLIPSE("-Dee.filename=") #define EE_HOME_VAR _T_ECLIPSE("${ee.home}") +/* Splash screen names to look for when -showsplash points to a directory or plugin */ +#define SPLASH_IMAGES _T_ECLIPSE("splash.png\0" "splash.jpg\0" "splash.jpeg\0" "splash.gif\0" "splash.bmp\0" "\0") + /* Define the variables to receive the option values. */ static int needConsole = 0; /* True: user wants a console */ static int debug = 0; /* True: output debugging info */ @@ -1393,8 +1396,8 @@ _TCHAR* getProgramDir( ) static _TCHAR* findSplash(_TCHAR* splashArg) { struct _stat stats; - _TCHAR *ch; - _TCHAR *path, *prefix; + _TCHAR *ch, *prefix; + _TCHAR *path, *dir, *name; size_t length; if (splashArg == NULL) @@ -1403,7 +1406,7 @@ static _TCHAR* findSplash(_TCHAR* splashArg) { splashArg = _tcsdup(splashArg); length = _tcslen(splashArg); /* _tstat doesn't seem to like dirSeparators on the end */ - while (IS_DIR_SEPARATOR(splashArg[length - 1])) { + while (length && IS_DIR_SEPARATOR(splashArg[length - 1])) { splashArg[--length] = 0; } @@ -1415,49 +1418,52 @@ static _TCHAR* findSplash(_TCHAR* splashArg) { return splashArg; } else if (stats.st_mode & S_IFDIR) { /*directory, look for splash.bmp*/ - ch = malloc( (length + 12) * sizeof(_TCHAR)); - _stprintf( ch, _T_ECLIPSE("%s%c%s"), splashArg, dirSeparator, _T_ECLIPSE("splash.bmp") ); - if (_tstat(ch, &stats) == 0 && (stats.st_mode & S_IFREG)) { - free(splashArg); - return ch; + dir = splashArg; + splashArg = NULL; + } else { + free(splashArg); + return NULL; + } + } else { + /* doesn't exist, separate into path & prefix and look for a /path/prefix_<version> */ + ch = lastDirSeparator( splashArg ); + if (ch != NULL) { + if (IS_ABSOLUTE(splashArg)) { + /*absolute path*/ + path = _tcsdup(splashArg); + path[ch - splashArg] = 0; + } else { + /* relative path, prepend with programDir */ + path = malloc( (_tcslen(programDir) + ch - splashArg + 2) * sizeof(_TCHAR)); + *ch = 0; + _stprintf(path, _T_ECLIPSE("%s%c%s"), programDir, dirSeparator, splashArg); + *ch = dirSeparator; } - free(ch); + prefix = ch + 1; + } else { + /* No separator, treat splashArg as the prefix and look in the plugins dir */ + path = malloc( (_tcslen(programDir) + 9) * sizeof(_TCHAR)); + _stprintf(path, _T_ECLIPSE("%s%c%s"), programDir, dirSeparator, _T_ECLIPSE("plugins")); + prefix = splashArg; } + dir = findFile(path, prefix); + free(path); free(splashArg); - return NULL; + path = prefix = splashArg = NULL; } - /* doesn't exist, separate into path & prefix and look for a /path/prefix_<version> */ - ch = lastDirSeparator( splashArg ); - if (ch != NULL) { - if (IS_ABSOLUTE(splashArg)) - { /*absolute path*/ - path = _tcsdup(splashArg); - path[ch - splashArg] = 0; - } else { - /* relative path, prepend with programDir */ - path = malloc( (_tcslen(programDir) + ch - splashArg + 2) * sizeof(_TCHAR)); - *ch = 0; - _stprintf(path, _T_ECLIPSE("%s%c%s"), programDir, dirSeparator, splashArg); - *ch = dirSeparator; + /* directory, look for splash image */ + length = _tcslen(dir); + for (name = SPLASH_IMAGES; *name; name += _tcslen(name) + 1) { + ch = malloc((length + 1 + _tcslen(name) + 1) * sizeof(_TCHAR)); + _stprintf(ch, _T_ECLIPSE("%s%c%s"), dir, dirSeparator, name); + if (_tstat(ch, &stats) == 0 && (stats.st_mode & S_IFREG)) { + free(dir); + return ch; } - prefix = _tcsdup(ch + 1); - } else { - /* No separator, treat splashArg as the prefix and look in the plugins dir */ - path = malloc( (_tcslen(programDir) + 9) * sizeof(_TCHAR)); - _stprintf(path, _T_ECLIPSE("%s%c%s"), programDir, dirSeparator, _T_ECLIPSE("plugins")); - prefix = _tcsdup(splashArg); - } - - ch = findFile(path, prefix); - free(path); - free(prefix); - free(splashArg); - if (ch != NULL) { - path = malloc((_tcslen(ch) + 12) * sizeof(_TCHAR)); - _stprintf( path, _T_ECLIPSE("%s%c%s"), ch, dirSeparator, _T_ECLIPSE("splash.bmp") ); - return path; + free(ch); } + free(dir); return NULL; } |