Skip to content

Commit

Permalink
Fix Require.java for SeleniumHQ#14088
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad8x8 authored Jun 18, 2024
1 parent dec42aa commit 93ebe03
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions java/src/org/openqa/selenium/internal/Require.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

package org.openqa.selenium.internal;

import static java.nio.file.LinkOption.NOFOLLOW_LINKS;

import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
Expand Down Expand Up @@ -364,9 +368,24 @@ public File isDirectory() {
return file;
}

public boolean isWindowsAppExecutionAlias() {
if (!FileSystems.getDefault().supportedFileAttributeViews().contains("dos")) {
return false;
}
final int WINDOWS_FILE_ATTRIBUTE_REPARSE_POINT = 0x400;
try {
int fileAttrs = (int) Files.getAttribute(file.toPath(), "dos:attributes", NOFOLLOW_LINKS);
return (fileAttrs & WINDOWS_FILE_ATTRIBUTE_REPARSE_POINT) != 0;
} catch (IOException e) {
return false;
}
}

public File isExecutable() {
isFile();
if (!file.canExecute()) {
if (!isWindowsAppExecutionAlias()) {
isFile();
}
if (!Files.isExecutable(file.toPath())) {
throw new IllegalStateException(
String.format(MUST_BE_EXECUTABLE, name, file.getAbsolutePath()));
}
Expand Down

0 comments on commit 93ebe03

Please sign in to comment.