SU2
Functions
io.c File Reference

Various file I/O functions. More...

#include <GKlib.h>

Functions

FILE * gk_fopen (char *fname, char *mode, const char *msg)
 
void gk_fclose (FILE *fp)
 
gk_idx_t gk_getline (char **lineptr, size_t *n, FILE *stream)
 
char ** gk_readfile (char *fname, gk_idx_t *r_nlines)
 
int32_t * gk_i32readfile (char *fname, gk_idx_t *r_nlines)
 
int64_t * gk_i64readfile (char *fname, gk_idx_t *r_nlines)
 
int32_t * gk_i32readfilebin (char *fname, ssize_t *r_nelmnts)
 
int64_t * gk_i64readfilebin (char *fname, ssize_t *r_nelmnts)
 
float * gk_freadfilebin (char *fname, ssize_t *r_nelmnts)
 
size_t gk_fwritefilebin (char *fname, size_t n, float *a)
 
double * gk_dreadfilebin (char *fname, ssize_t *r_nelmnts)
 

Detailed Description

Various file I/O functions.

This file contains various functions that perform I/O.

Date
Started 4/10/95
Author
George
Version
$Id: io.c 12591 2012-09-01 19:03:15Z karypis $ 

Function Documentation

§ gk_dreadfilebin()

double* gk_dreadfilebin ( char *  fname,
ssize_t *  r_nelmnts 
)

This function reads the contents of a binary file and returns it in the form of an array of double.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.

§ gk_freadfilebin()

float* gk_freadfilebin ( char *  fname,
ssize_t *  r_nelmnts 
)

This function reads the contents of a binary file and returns it in the form of an array of float.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.

§ gk_fwritefilebin()

size_t gk_fwritefilebin ( char *  fname,
size_t  n,
float *  a 
)

This function writes the contents of an array into a binary file.

Parameters
fnameis the name of the file
nthe number of elements in the array.
athe array to be written out.

§ gk_getline()

gk_idx_t gk_getline ( char **  lineptr,
size_t *  n,
FILE *  stream 
)

This function is the GKlib implementation of glibc's getline() function.

Returns
-1 if the EOF has been reached, otherwise it returns the number of bytes read.

§ gk_i32readfile()

int32_t* gk_i32readfile ( char *  fname,
gk_idx_t *  r_nlines 
)

This function reads the contents of a file and returns it in the form of an array of int32_t.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.

§ gk_i32readfilebin()

int32_t* gk_i32readfilebin ( char *  fname,
ssize_t *  r_nelmnts 
)

This function reads the contents of a binary file and returns it in the form of an array of int32_t.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.

§ gk_i64readfile()

int64_t* gk_i64readfile ( char *  fname,
gk_idx_t *  r_nlines 
)

This function reads the contents of a file and returns it in the form of an array of int64_t.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.

§ gk_i64readfilebin()

int64_t* gk_i64readfilebin ( char *  fname,
ssize_t *  r_nelmnts 
)

This function reads the contents of a binary file and returns it in the form of an array of int64_t.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.

§ gk_readfile()

char** gk_readfile ( char *  fname,
gk_idx_t *  r_nlines 
)

This function reads the contents of a text file and returns it in the form of an array of strings.

Parameters
fnameis the name of the file
r_nlinesis the number of lines in the file. If it is NULL, this information is not returned.