First NIT release and new clean mercurial repository
[nit.git] / lib / standard / file_nit.h
1 #ifndef __FILE_H
2 #define __FILE_H
3 /* This file is part of NIT ( http://www.nitlanguage.org ).
4 *
5 * Copyright 2004-2008 Jean Privat <jean@pryen.org>
6 * Copyright 2008 Floréal Morandat <morandat@lirmm.fr>
7 *
8 * This file is free software, which comes along with NIT. This software is
9 * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 * PARTICULAR PURPOSE. You can modify it is you want, provided this header
12 * is kept unaltered, and a notification of the changes is added.
13 * You are allowed to redistribute it and sell it, alone or is a part of
14 * another product.
15 */
16
17 #include <sys/stat.h>
18 #include <unistd.h>
19 #include <stdio.h>
20 #include <sys/types.h>
21
22 extern int string_NativeString_NativeString_file_exists_0(char *f);
23 extern void *string_NativeString_NativeString_file_stat_0(char *f);
24 extern void *file_NativeFile_NativeFile_file_stat_0(FILE *f);
25
26 #define file_NativeFile_NativeFile_io_read_2(p, b, l) fread((b), 1, (l), (FILE*)(p))
27 #define file_NativeFile_NativeFile_io_write_2(p, b, l) fwrite((b), 1, (l), (FILE*)(p))
28 #define file_NativeFile_NativeFile_io_close_0(self) fclose((FILE*)(self))
29
30 #define file_NativeFileCapable_NativeFileCapable_io_open_read_1(self, p0) fopen((p0), "r")
31
32 #define file_NativeFileCapable_NativeFileCapable_io_open_write_1(self, p0) fopen((p0), "w")
33 #define file_NativeFileCapable_NativeFileCapable_native_stdin_0(self) stdin
34 #define file_NativeFileCapable_NativeFileCapable_native_stdout_0(self) stdout
35 #define file_NativeFileCapable_NativeFileCapable_native_stderr_0(self) stderr
36 #define file_FileStat_FileStat_mode_0(self) (((struct stat*)self)->st_mode)
37 #define file_FileStat_FileStat_atime_0(self) (((struct stat*)self)->st_atime)
38 #define file_FileStat_FileStat_ctime_0(self) (((struct stat*)self)->st_ctime)
39 #define file_FileStat_FileStat_mtime_0(self) (((struct stat*)self)->st_mtime)
40 #define file_FileStat_FileStat_size_0(self) (((struct stat*)self)->st_size)
41
42 #define string_NativeString_NativeString_file_mkdir_0(p) (mkdir(p, 0777))
43 #endif
44