SURFEX v8.1
General documentation of Surfex
save.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <unistd.h>
6 
7 
8 void save_ (const char * p, const char * f, const int * p_len, const unsigned long int f_len)
9 {
10  char _f[f_len+1];
11  FILE * fp;
12 
13  memset (_f, 0, sizeof (_f));
14  memcpy (_f, f, f_len);
15 
16  fp = fopen (_f, "w");
17  fwrite (p, 1, *p_len, fp);
18  fclose (fp);
19 }
20 
21 void load_ (char * p, const char * f, int * p_len, const unsigned long int f_len)
22 {
23  char _f[f_len+1];
24  FILE * fp;
25  struct stat st;
26  int size;
27 
28  memset (_f, 0, sizeof (_f));
29  memcpy (_f, f, f_len);
30 
31  stat (_f, &st);
32  size = st.st_size;
33 
34  fp = fopen (_f, "r");
35  fread (p, 1, size, fp);
36  fclose (fp);
37 
38  *p_len = size;
39 
40 }
static long size
Definition: bytes_io.c:262
void load_(char *p, const char *f, int *p_len, const unsigned long int f_len)
Definition: save.c:21
FILE * fp
Definition: opfla_perfmon.c:24
void save_(const char *p, const char *f, const int *p_len, const unsigned long int f_len)
Definition: save.c:8