]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/otherlibs/unix/truncate.c
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / otherlibs / unix / truncate.c
1 /***********************************************************************/
2 /*                                                                     */
3 /*                           Objective Caml                            */
4 /*                                                                     */
5 /*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         */
6 /*                                                                     */
7 /*  Copyright 1996 Institut National de Recherche en Informatique et   */
8 /*  en Automatique.  All rights reserved.  This file is distributed    */
9 /*  under the terms of the GNU Library General Public License, with    */
10 /*  the special exception on linking described in file ../../LICENSE.  */
11 /*                                                                     */
12 /***********************************************************************/
13
14 /* $Id: truncate.c 7849 2007-02-09 13:31:15Z doligez $ */
15
16 #include <sys/types.h>
17 #include <mlvalues.h>
18 #include <fail.h>
19 #include <io.h>
20 #include "unixsupport.h"
21 #ifdef HAS_UNISTD
22 #include <unistd.h>
23 #endif
24
25 #ifdef HAS_TRUNCATE
26
27 CAMLprim value unix_truncate(value path, value len)
28 {
29   if (truncate(String_val(path), Long_val(len)) == -1)
30     uerror("truncate", path);
31   return Val_unit;
32 }
33
34 CAMLprim value unix_truncate_64(value path, value len)
35 {
36   if (truncate(String_val(path), File_offset_val(len)) == -1)
37     uerror("truncate", path);
38   return Val_unit;
39 }
40
41 #else
42
43 CAMLprim value unix_truncate(value path, value len)
44 { invalid_argument("truncate not implemented"); }
45
46 CAMLprim value unix_truncate_64(value path, value len)
47 { invalid_argument("truncate not implemented"); }
48
49 #endif