40 lines
800 B
C
40 lines
800 B
C
#include <fx/core/stream.h>
|
|
#include <fx/core/stringstream.h>
|
|
#include <fx/ds/string.h>
|
|
#include <fx/io/file.h>
|
|
#include <fx/io/path.h>
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, const char **argv)
|
|
{
|
|
if (argc < 2) {
|
|
return -1;
|
|
}
|
|
|
|
const char *path_cstr = argv[1];
|
|
fx_path *path = fx_path_create_from_cstr(path_cstr);
|
|
|
|
fx_file *src = NULL;
|
|
fx_result result = fx_file_open(NULL, path, FX_FILE_READ_ONLY, &src);
|
|
if (fx_result_is_error(result)) {
|
|
fx_throw(result);
|
|
return -1;
|
|
}
|
|
|
|
fx_wchar c;
|
|
|
|
size_t nr_read;
|
|
fx_status status = fx_stream_read_char(src, &c);
|
|
if (!FX_OK(status)) {
|
|
printf("read error: %s\n", fx_status_description(status));
|
|
fx_file_unref(src);
|
|
return -1;
|
|
}
|
|
|
|
fx_stream_write_char(fx_stdout, c);
|
|
fx_stream_write_char(fx_stdout, '\n');
|
|
|
|
fx_file_unref(src);
|
|
return 0;
|
|
}
|