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

--replace not working under Windows #217

Open
alainfrisch opened this issue Feb 26, 2016 · 0 comments
Open

--replace not working under Windows #217

alainfrisch opened this issue Feb 26, 2016 · 0 comments

Comments

@alainfrisch
Copy link

Under Windows, one needs to remove the original file before renaming the temporary one, or one gets Sys_error("File exists"). Before removing the original file, one needs to close the in-channel (which is a good idea anyway), or one gets Sys_error("foo.ml: Permission denied")

We currently use locally:

      let ic = open_in path in
      try
        indent_channel ic args config out;
        close_in ic;
        match out, need_move with
        | Some src, Some dst -> Sys.remove dst; Sys.rename src dst
        | _, _ -> ()
      with e ->
          close_in ic; raise e

but this should be improved to avoid the double-close when an error is raised by Sys.remove or Sys.rename.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant