Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2007-02-14 15:23:35 -0500
committerAndrew Niefer2007-02-14 15:23:35 -0500
commitb635d2a2ac90614a225657020c945c214346fa92 (patch)
treee290e91e759e586cc5bb06a99e5a6c957c1dd282 /bundles/org.eclipse.equinox.executable/library/eclipseCommon.c
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/library/eclipseCommon.c')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseCommon.c25
1 files changed, 15 insertions, 10 deletions
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