Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ie4uinit.exe execution optional #1240

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ private void createIconResource() throws InterruptedException, IOException {
// During development if user changes the application icon, the same is not reflected immediately in Explorer.
// To fix this, a cache clearance of the Windows explorer is required.
private void clearExplorerCache() throws IOException, InterruptedException {
if (!executableOnPath("ie4uinit.exe")) {
Logger.logInfo("The application icon cache could not be cleared. As a result, the icon may not have been updated properly.");
return;
}
ProcessRunner clearCache = new ProcessRunner("ie4uinit");
clearCache.addArg(findCacheFlag());
clearCache.runProcess("Clear Explorer cache");
Expand All @@ -311,6 +315,26 @@ private String findCacheFlag() throws IOException, InterruptedException {
return flag;
}

/**
* Returns whether the passed executable is available on the PATH.
* For best result, the extension should be included in the executable, as "foo" will return true for "foo.bat".
* But running "foo" in a ProcessBuilder will look for "foo.exe" and fail to run.
*
* @param executable name of the executable to check
* @return true if the executable is available on the PATH.
*/
private boolean executableOnPath(String executable) {
try {
ProcessRunner whereProcess = new ProcessRunner("cmd.exe", "/c", "where", "/q", executable);
whereProcess.showSevereMessage(false);
int exit = whereProcess.runProcess("find executable");
return exit == 0;
} catch (IOException | InterruptedException e) {
Logger.logInfo(String.format("Unable to validate if %s is available on the PATH, assuming it is not.", executable));
return false;
}
}

@Override
List<String> getAdditionalSourceFiles() {
if (projectConfiguration.isSharedLibrary()) {
Expand Down
Loading