fs.ml (2600B)
1 (* Unison file synchronizer: src/fs.ml *) 2 (* Copyright 1999-2020, Benjamin C. Pierce 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 *) 17 18 type fspath = Fspath.t 19 let mfspath = Fspath.m 20 type dir_handle = System.dir_handle 21 = { readdir : unit -> string; closedir : unit -> unit } 22 23 let path p = Fspath.toString p |> System.extendedPath 24 25 (****) 26 27 let symlink l f = System.symlink l (path f) 28 29 let readlink f = System.readlink (path f) 30 31 let chown f usr grp = System.chown (path f) usr grp 32 33 let chmod f mode = System.chmod (path f) mode 34 35 let utimes f t1 t2 = System.utimes (path f) t1 t2 36 37 let unlink f = System.unlink (path f) 38 39 let rmdir f = System.rmdir (path f) 40 41 let mkdir f mode = System.mkdir (path f) mode 42 43 let rename f f' = System.rename (path f) (path f') 44 45 let stat f = System.stat (path f) 46 47 let lstat f = System.lstat (path f) 48 49 let openfile f flags perms = System.openfile (path f) flags perms 50 51 let opendir f = System.opendir (path f) 52 53 let open_in_gen flags mode f = 54 System.open_in_gen flags mode (path f) 55 56 let open_out_gen flags mode f = 57 System.open_out_gen flags mode (path f) 58 59 (****) 60 61 let open_in_bin f = System.open_in_bin (path f) 62 63 let file_exists f = 64 try 65 ignore (stat f); true 66 with Unix.Unix_error ((Unix.ENOENT | Unix.ENOTDIR), _, _) -> 67 false 68 69 (****) 70 71 let clone_path f1 f2 = System.clone_path (path f1) (path f2) 72 let clone_file = System.clone_file 73 let copy_file = System.copy_file 74 75 (****) 76 77 exception XattrNotSupported = System.XattrNotSupported 78 79 let xattr_list f = System.xattr_list (path f) 80 let xattr_get f n = System.xattr_get (path f) n 81 let xattr_set f n v = System.xattr_set (path f) n v 82 let xattr_remove f n = System.xattr_remove (path f) n 83 84 let xattrUpdatesCTime = System.xattrUpdatesCTime 85 86 (****) 87 88 let acl_get_text f = System.acl_get_text (path f) 89 let acl_set_text f acl = System.acl_set_text (path f) acl 90 91 (****) 92 93 let hasInodeNumbers () = System.hasInodeNumbers () 94 let hasSymlink () = System.hasSymlink () 95 let hasCorrectCTime = System.hasCorrectCTime