more thorough File.set_executable, notably for Windows;
authorwenzelm
Mon, 04 Feb 2019 16:01:44 +0100
changeset 69789 2c3e5e58d93f
parent 69788 c175499a7537
child 69790 154cf64e403e
more thorough File.set_executable, notably for Windows;
src/Pure/Admin/build_cygwin.scala
src/Pure/Admin/build_release.scala
src/Pure/General/file.scala
src/Pure/Thy/export.scala
--- a/src/Pure/Admin/build_cygwin.scala	Mon Feb 04 15:45:40 2019 +0100
+++ b/src/Pure/Admin/build_cygwin.scala	Mon Feb 04 16:01:44 2019 +0100
@@ -35,7 +35,7 @@
 
         File.write(cygwin_isabelle + Path.explode("cygwin_mirror"), mirror)
 
-        File.executable(cygwin_exe)
+        File.set_executable(cygwin_exe, true)
         Isabelle_System.bash(File.bash_path(cygwin_exe) + " -h </dev/null >/dev/null").check
 
         val res =
--- a/src/Pure/Admin/build_release.scala	Mon Feb 04 15:45:40 2019 +0100
+++ b/src/Pure/Admin/build_release.scala	Mon Feb 04 16:01:44 2019 +0100
@@ -467,7 +467,7 @@
                   .replaceAllLiterally("{CLASSPATH}",
                     classpath.map("$ISABELLE_HOME/" + _).mkString(":"))
                   .replaceAllLiterally("/jdk/", "/" + jdk_component + "/"))
-              File.executable(isabelle_run)
+              File.set_executable(isabelle_run, true)
 
               val linux_app = isabelle_target + Path.explode("contrib/linux_app")
               File.move(linux_app + Path.explode("Isabelle"),
@@ -595,7 +595,7 @@
               File.write(isabelle_target + cygwin_bat,
                 File.read(cygwin_template + cygwin_bat)
                   .replaceAllLiterally("{MIRROR}", cygwin_mirror))
-              File.executable(isabelle_target + cygwin_bat)
+              File.set_executable(isabelle_target + cygwin_bat, true)
 
               for (name <- List("isabelle/postinstall", "isabelle/rebaseall")) {
                 val path = Path.explode(name)
@@ -635,7 +635,7 @@
 
               Bytes.write(release.dist_dir + isabelle_exe,
                 Bytes.read(sfx_exe) + Bytes(sfx_txt) + Bytes.read(exe_archive))
-              File.executable(release.dist_dir + isabelle_exe)
+              File.set_executable(release.dist_dir + isabelle_exe, true)
           }
         })
         progress.echo("DONE")
--- a/src/Pure/General/file.scala	Mon Feb 04 15:45:40 2019 +0100
+++ b/src/Pure/General/file.scala	Mon Feb 04 16:01:44 2019 +0100
@@ -349,9 +349,10 @@
     else path.file.canExecute
   }
 
-  def executable(path: Path)
+  def set_executable(path: Path, flag: Boolean)
   {
-    if (Platform.is_windows) Isabelle_System.bash("chmod a+x " + bash_path(path)).check
-    else path.file.setExecutable(true, false)
+    if (Platform.is_windows && flag) Isabelle_System.bash("chmod a+x " + bash_path(path)).check
+    else if (Platform.is_windows) Isabelle_System.bash("chmod a-x " + bash_path(path)).check
+    else path.file.setExecutable(flag, false)
   }
 }
--- a/src/Pure/Thy/export.scala	Mon Feb 04 15:45:40 2019 +0100
+++ b/src/Pure/Thy/export.scala	Mon Feb 04 16:01:44 2019 +0100
@@ -301,7 +301,7 @@
             progress.echo(export_prefix + "export " + path)
             Isabelle_System.mkdirs(path.dir)
             Bytes.write(path, entry.uncompressed(cache = store.xz_cache))
-            if (entry.executable) File.executable(path)
+            File.set_executable(path, entry.executable)
           }
         }
       }