CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/****************************************************************************
2
**
3
*A OpenFile.c ANUPQ source Eamonn O'Brien
4
**
5
*Y Copyright 1995-2001, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany
6
*Y Copyright 1995-2001, School of Mathematical Sciences, ANU, Australia
7
**
8
*/
9
10
#include "pq_defs.h"
11
#include "constants.h"
12
13
/* fopen file */
14
15
FILE *OpenFile(const char *file_name, const char *mode)
16
{
17
FILE *fp;
18
19
if ((fp = fopen(file_name, mode)) == NULL) {
20
printf("Cannot open %s\n", file_name);
21
if (!isatty(0))
22
exit(FAILURE);
23
}
24
25
return fp;
26
}
27
28
FILE *OpenFileOutput(const char *file_name)
29
{
30
return OpenFile(file_name, "w");
31
}
32
33
FILE *OpenFileInput(const char *file_name)
34
{
35
return OpenFile(file_name, "r");
36
}
37
38
/* open file for fread and fwrite */
39
40
FILE *OpenSystemFile(const char *file_name, const char *mode)
41
{
42
FILE *fp;
43
44
if ((fp = fopen(file_name, mode)) == NULL) {
45
perror(NULL);
46
printf("Cannot open %s\n", file_name);
47
exit(FAILURE);
48
}
49
50
setbuf(fp, NULL);
51
return fp;
52
}
53
54