Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2007-02-14 20:23:35 +0000
committerAndrew Niefer2007-02-14 20:23:35 +0000
commitb635d2a2ac90614a225657020c945c214346fa92 (patch)
treee290e91e759e586cc5bb06a99e5a6c957c1dd282 /bundles/org.eclipse.equinox.executable
parent5cde27421dd0d4bfe2db0eb50319e8bc908139d8 (diff)
downloadrt.equinox.framework-b635d2a2ac90614a225657020c945c214346fa92.tar.gz
rt.equinox.framework-b635d2a2ac90614a225657020c945c214346fa92.tar.xz
rt.equinox.framework-b635d2a2ac90614a225657020c945c214346fa92.zip
bug 173103
Diffstat (limited to 'bundles/org.eclipse.equinox.executable')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipse.c76
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseCommon.c25
2 files changed, 90 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipse.c b/bundles/org.eclipse.equinox.executable/library/eclipse.c
index df78efe98..c89d710e7 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipse.c
@@ -299,6 +299,7 @@ static _TCHAR** parseArgList( _TCHAR *data );
static _TCHAR* formatVmCommandMsg( _TCHAR* args[], _TCHAR* vmArgs[], _TCHAR* progArgs[] );
static _TCHAR* getDefaultOfficialName();
static _TCHAR* findStartupJar();
+static _TCHAR* findSplash(_TCHAR* splashArg);
static _TCHAR** getRelaunchCommand( _TCHAR **vmCommand );
#ifdef _WIN32
@@ -385,7 +386,10 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
/* If the showsplash option was given and we are using JNI */
if (!noSplash && showSplashArg && launchMode == LAUNCH_JNI)
{
- showSplash(showSplashArg);
+ _TCHAR *bitmap = findSplash(showSplashArg);
+ showSplash(bitmap);
+ if (bitmap != showSplashArg)
+ free(bitmap);
}
/* not using JNI launching, need some shared data */
@@ -884,6 +888,76 @@ _TCHAR* getProgramDir( )
return NULL;
}
+static _TCHAR* findSplash(_TCHAR* splashArg) {
+ struct _stat stats;
+ _TCHAR *ch;
+ _TCHAR *path, *prefix;
+ int length;
+
+ if (splashArg == NULL)
+ return NULL;
+
+ splashArg = _tcsdup(splashArg);
+ length = _tcslen(splashArg);
+ /* _tstat doesn't seem to like dirSeparators on the end */
+ while (splashArg[length - 1] == dirSeparator) {
+ splashArg[--length] = 0;
+ }
+
+ /* does splashArg exist */
+ if (_tstat(splashArg, &stats) == 0) {
+ /* pointing to a file */
+ if (stats.st_mode & S_IFREG) {
+ /* file, use it*/
+ 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;
+ }
+ free(ch);
+ }
+ free(splashArg);
+ return NULL;
+ }
+
+ /* doesn't exist, separate into path & prefix and look for a /path/prefix_<version> */
+ ch = _tcsrchr( splashArg, dirSeparator );
+ if (ch != NULL) {
+ if (splashArg[0] == dirSeparator || (_tcslen(splashArg) > 2 && splashArg[1] == _T_ECLIPSE(':')))
+ { /*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;
+ }
+ 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;
+ }
+ return NULL;
+}
+
static _TCHAR* findStartupJar(){
_TCHAR * file;
_TCHAR * pluginsPath;
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c b/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
index 5458912e8..f0d27d9c8 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
@@ -22,6 +22,7 @@
#include <dirent.h>
#include <limits.h>
#endif
+#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -254,19 +255,23 @@ _TCHAR* findFile( _TCHAR* path, _TCHAR* prefix)
int count;
#endif
+ path = _tcsdup(path);
+ pathLength = _tcslen(path);
+
+ /* strip dirSeparators off the end */
+ while (path[pathLength - 1] == dirSeparator) {
+ path[--pathLength] = 0;
+ }
+
/* does path exist? */
- if( _tstat(path, &stats) != 0 )
+ if( _tstat(path, &stats) != 0 ) {
+ free(path);
return NULL;
-
- pathLength = _tcslen(path);
+ }
#ifdef _WIN32
fileName = malloc( (_tcslen(path) + 1 + _tcslen(prefix) + 3) * sizeof(_TCHAR));
- fileName = _tcscpy(fileName, path);
- fileName[pathLength] = dirSeparator;
- fileName[pathLength + 1] = 0;
- _tcscat(fileName, prefix);
- _tcscat(fileName, _T_ECLIPSE("_*"));
+ _stprintf(fileName, _T_ECLIPSE("%s%c%s_*"), path, dirSeparator, prefix);
prefix = fileName;
handle = FindFirstFile(prefix, &data);
@@ -299,7 +304,7 @@ _TCHAR* findFile( _TCHAR* path, _TCHAR* prefix)
result[pathLength + 1] = 0;
_tcscat(result, candidate);
free(candidate);
- return result;
}
- return NULL;
+ free(path);
+ return result;
}

Back to the top