From 8a2019a4f2252ad5f0d04cd768b2e8d238f50cf8 Mon Sep 17 00:00:00 2001 From: Gurpreet Paul Date: Tue, 6 Aug 2019 17:46:30 +0100 Subject: [PATCH] Updated to be non-posix compatible --- .../co/libly/hydride/utils/LibraryLoader.java | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/co/libly/hydride/utils/LibraryLoader.java b/src/main/java/co/libly/hydride/utils/LibraryLoader.java index 9684a9f..9e4aa06 100644 --- a/src/main/java/co/libly/hydride/utils/LibraryLoader.java +++ b/src/main/java/co/libly/hydride/utils/LibraryLoader.java @@ -292,21 +292,26 @@ static File createTempDirectory() { return hydrideDirectory; } - private void setPermissions(File file) throws IOException{ - Set perms = new HashSet<>(); - perms.add(PosixFilePermission.OWNER_READ); - perms.add(PosixFilePermission.OWNER_WRITE); - perms.add(PosixFilePermission.OWNER_EXECUTE); - - perms.add(PosixFilePermission.OTHERS_READ); - perms.add(PosixFilePermission.OTHERS_WRITE); - perms.add(PosixFilePermission.OTHERS_EXECUTE); - - perms.add(PosixFilePermission.GROUP_READ); - perms.add(PosixFilePermission.GROUP_WRITE); - perms.add(PosixFilePermission.GROUP_EXECUTE); - - Files.setPosixFilePermissions(file.toPath(), perms); + private void setPermissions(File file) throws IOException { + if (isPosixCompliant()) { + Set perms = new HashSet<>(); + perms.add(PosixFilePermission.OWNER_READ); + perms.add(PosixFilePermission.OWNER_WRITE); + perms.add(PosixFilePermission.OWNER_EXECUTE); + + perms.add(PosixFilePermission.OTHERS_READ); + perms.add(PosixFilePermission.OTHERS_WRITE); + perms.add(PosixFilePermission.OTHERS_EXECUTE); + + perms.add(PosixFilePermission.GROUP_READ); + perms.add(PosixFilePermission.GROUP_WRITE); + perms.add(PosixFilePermission.GROUP_EXECUTE); + Files.setPosixFilePermissions(file.toPath(), perms); + } else { + file.setWritable(true); + file.setReadable(true); + file.setExecutable(true); + } } /**