INGOR
|
File stream related routines. More...
#include <ytFile.h>
Public Member Functions | |
int | ytFile_readLine (FILE *fp, char **buff, size_t *size) |
Reads one line from the given file stream. | |
void | ytFile_printComma_size_t (FILE *fp, size_t value) |
Prints a size_t value with delimiters for each 3-digit. | |
void | ytFile_printBit64 (FILE *fp, uint64_t b) |
Prints a 64 unsigned integer value in binary. | |
ytIntArray * | ytFile_readNodes (FILE *fp, int col, ytIntArray *array, ytData *data) |
Reads a node list file. | |
FILE * | ytFile_ropen (const char *filename) |
Opens the file for reading. | |
FILE * | ytFile_wopen (const char *filename) |
Opens the file for writing. | |
void | ytFile_flush () |
Alias of ytStdioBuff_flush(). | |
File stream related routines.
void ytFile_flush | ( | ) |
Alias of ytStdioBuff_flush().
This outputs the buffered data for the standard output if available.
void ytFile_printBit64 | ( | FILE * | fp, |
uint64_t | b | ||
) |
Prints a 64 unsigned integer value in binary.
fp | file stream. |
b | value to be printed. |
void ytFile_printComma_size_t | ( | FILE * | fp, |
size_t | value | ||
) |
Prints a size_t
value with delimiters for each 3-digit.
fp | file stream. |
value | value to be printed. |
int ytFile_readLine | ( | FILE * | fp, |
char ** | buff, | ||
size_t * | size | ||
) |
Reads one line from the given file stream.
The read string is stored in buff. This automatically allocates memory for buff and extends the size required to read the entire line. To do so, user needs to pass the buffer and the size of it by pointers. The buffer can be empty (NULL). If so, set 0 to the variable pointed by size.
This regards all CR, CR+LF, and LF as a new line marker. The newline character at the end of line is removed.
fp | input stream to be read. |
buff | pointer to the pointer to the buffer. The buffer needs to be the pointer returned by malloc and so on. |
size | pointer to the buffer size. |
ytIntArray * ytFile_readNodes | ( | FILE * | fp, |
int | col, | ||
ytIntArray * | array, | ||
ytData * | data | ||
) |
Reads a node list file.
This reads a column of a tab-seperated text file consisting of node names, and returns their corresponding internal node IDs according to the given data.
The column position to read is given by the col parameter.
fp | |
col | |
array | NULL acceptable. If so, new ytIntArray instance is generated and returned. Othewise, this adds read node IDs to the given instance. This does not clear the given array instance before adding read IDs. |
data |
FILE * ytFile_ropen | ( | const char * | filename | ) |
Opens the file for reading.
If ytStdioBuff_read() has been already called, and the file name is STDIN_
n, the file stream pointer of the n-th data set read from the standard input is returned.
filename | file name of the file to open, or "STDIN_ n" to specify the data set from the standard input. n (≥1) represents the index of the order to read. |
FILE * ytFile_wopen | ( | const char * | filename | ) |
Opens the file for writing.
If ytStdioBuff_prepare() has been already called, and file name is STDOUT_
n, the file stream pointer of n-th data to write is return. The written data to the stream is buffered. To actually write them into the standard output, call ytFile_flush().
filename | file name of the file to open, or "STDOUT_ n" to specify the file that is output to the standard output. n (≥1) represents the index of the order to write. |