src/Pure/System/isabelle_system.scala
changeset 74070 a69a13c4b049
parent 73987 fc363a3b690a
child 74142 0f051404f487
equal deleted inserted replaced
74068:62e4ec8cff38 74070:a69a13c4b049
   251   def move_file(src: Path, dst: Path): Unit = move_file(src.file, dst.file)
   251   def move_file(src: Path, dst: Path): Unit = move_file(src.file, dst.file)
   252 
   252 
   253 
   253 
   254   /* symbolic link */
   254   /* symbolic link */
   255 
   255 
   256   def symlink(src: Path, dst: Path, force: Boolean = false): Unit =
   256   def symlink(src: Path, dst: Path, force: Boolean = false, native: Boolean = false): Unit =
   257   {
   257   {
   258     val src_file = src.file
   258     val src_file = src.file
   259     val dst_file = dst.file
   259     val dst_file = dst.file
   260     val target = if (dst_file.isDirectory) new JFile(dst_file, src_file.getName) else dst_file
   260     val target = if (dst_file.isDirectory) new JFile(dst_file, src_file.getName) else dst_file
   261 
   261 
   262     if (force) target.delete
   262     if (force) target.delete
   263 
   263 
   264     def cygwin_link(): Unit =
   264     def cygwin_link(): Unit =
   265       isabelle.setup.Environment.cygwin_link(File.standard_path(src), target)
   265     {
       
   266       if (native) {
       
   267         error("Failed to create native symlink on Windows: " + quote(src_file.toString) +
       
   268           "\n(but it could work as Administrator)")
       
   269       }
       
   270       else isabelle.setup.Environment.cygwin_link(File.standard_path(src), target)
       
   271     }
       
   272 
   266 
   273 
   267     try { Files.createSymbolicLink(target.toPath, src_file.toPath) }
   274     try { Files.createSymbolicLink(target.toPath, src_file.toPath) }
   268     catch {
   275     catch {
   269       case _: UnsupportedOperationException if Platform.is_windows => cygwin_link()
   276       case _: UnsupportedOperationException if Platform.is_windows => cygwin_link()
   270       case _: FileSystemException if Platform.is_windows => cygwin_link()
   277       case _: FileSystemException if Platform.is_windows => cygwin_link()