libsdfio 1.0.0
Reader and writer for ISO 25178-71 SDF surface data files in C
Loading...
Searching...
No Matches
file.h File Reference

Files by path, and the stream over a C file. More...

#include <sdfio/reader.h>
#include <sdfio/sdfio_export.h>
#include <sdfio/types.h>
#include <sdfio/writer.h>
#include <stdio.h>
#include <wchar.h>

Go to the source code of this file.

Functions

void sdfio_stdio_stream (sdfio_stream *stream, FILE *file)
 Creates a stream over a C file.
sdfio_status sdfio_open_file (sdfio_reader *reader, const char *path)
 Opens the file at a path as the source and reads its header, as sdfio_open_stream() does for a stream.
sdfio_status sdfio_create_file (sdfio_writer *writer, const char *path, const sdfio_header *header)
 Creates the file at a path and starts it as sdfio_create_stream() does.
sdfio_status sdfio_open_wfile (sdfio_reader *reader, const wchar_t *path)
 Variant of sdfio_open_file() with a path of wide characters.
sdfio_status sdfio_create_wfile (sdfio_writer *writer, const wchar_t *path, const sdfio_header *header)
 Variant of sdfio_create_file() with a path of wide characters.

Detailed Description

Files by path, and the stream over a C file.

<sdfio/sdfio.h> does not include this header.

Function Documentation

◆ sdfio_create_file()

sdfio_status sdfio_create_file ( sdfio_writer * writer,
const char * path,
const sdfio_header * header )

Creates the file at a path and starts it as sdfio_create_stream() does.

An existing file is truncated. The data is written in place, and sdfio_end_file() closes the file. If the writing fails, the data written so far remains. A header that cannot be written creates no file.

Parameters
[in,out]writerThe writer.
[in]pathThe path of the file.
[in]headerThe description of the file.
Return values
SDFIO_ERR_ARGUMENTA pointer is null or the header cannot be written.
SDFIO_ERR_STATEThe writer has created a file already.
SDFIO_ERR_IOThe file cannot be created.
Returns
Otherwise the result of sdfio_create_stream().
Examples
custom_timezone.c, eigen.cpp, opencv.cpp, write_coded.c, and write_heights.c.

◆ sdfio_create_wfile()

sdfio_status sdfio_create_wfile ( sdfio_writer * writer,
const wchar_t * path,
const sdfio_header * header )

Variant of sdfio_create_file() with a path of wide characters.

Parameters
[in,out]writerThe writer.
[in]pathThe path of the file.
[in]headerThe description of the file.

◆ sdfio_open_file()

sdfio_status sdfio_open_file ( sdfio_reader * reader,
const char * path )

Opens the file at a path as the source and reads its header, as sdfio_open_stream() does for a stream.

The reader closes the file when it is freed or when the open fails.

Parameters
[in,out]readerThe reader.
[in]pathThe path of the file.
Return values
SDFIO_ERR_ARGUMENTA pointer is null.
SDFIO_ERR_IOThe file cannot be opened.
Returns
Otherwise the result of sdfio_open_stream().
Examples
custom_allocator.c, custom_timezone.c, eigen.cpp, opencv.cpp, read_coded.c, read_heights.c, and vtk.cpp.

◆ sdfio_open_wfile()

sdfio_status sdfio_open_wfile ( sdfio_reader * reader,
const wchar_t * path )

Variant of sdfio_open_file() with a path of wide characters.

Parameters
[in,out]readerThe reader.
[in]pathThe path of the file.

◆ sdfio_stdio_stream()

void sdfio_stdio_stream ( sdfio_stream * stream,
FILE * file )

Creates a stream over a C file.

The file remains owned by the caller and is not closed.

The file must be open in binary mode. On Windows stdin and stdout are in text mode, which translates line ends and treats the byte 0x1A as the end of the input. Switch them before the first use with _setmode(_fileno(stdin), _O_BINARY). The files of sdfio_open_file() and sdfio_create_file() are always binary.

Parameters
[out]streamThe stream, whose user is the file.
[in]fileThe C file.
Examples
read_stream.c.