Fabcoin Core  0.16.2
P2P Digital Currency
Functions
io_posix.c File Reference
#include "io.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <libgen.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
Include dependency graph for io_posix.c:

Go to the source code of this file.

Functions

FILE * ethash_fopen (char const *file_name, char const *mode)
 An fopen wrapper for no-warnings crossplatform fopen. More...
 
char * ethash_strncat (char *dest, size_t dest_size, char const *src, size_t count)
 An strncat wrapper for no-warnings crossplatform strncat. More...
 
bool ethash_mkdir (char const *dirname)
 A cross-platform mkdir wrapper to create a directory or assert it's there. More...
 
int ethash_fileno (FILE *f)
 Get a file descriptor number from a FILE stream. More...
 
char * ethash_io_create_filename (char const *dirname, char const *filename, size_t filename_length)
 Create the filename for the DAG. More...
 
bool ethash_file_size (FILE *f, size_t *ret_size)
 Get a file's size. More...
 
bool ethash_get_default_dirname (char *strbuf, size_t buffsize)
 Gets the default directory name for the DAG depending on the system. More...
 

Detailed Description

Author
Lefteris Karapetsas lefte.nosp@m.ris@.nosp@m.ethde.nosp@m.v.co.nosp@m.m
Date
2015

Definition in file io_posix.c.

Function Documentation

bool ethash_file_size ( FILE *  f,
size_t *  ret_size 
)

Get a file's size.

Parameters
[in]fThe open file stream whose size to get
[out]sizePass a size_t by reference to contain the file size
Returns
true in success and false if there was a failure

Definition at line 78 of file io_posix.c.

int ethash_fileno ( FILE *  f)

Get a file descriptor number from a FILE stream.

Parameters
fThe file stream whose fd to get
Returns
Platform specific fd handler

Definition at line 48 of file io_posix.c.

FILE* ethash_fopen ( char const *  file_name,
char const *  mode 
)

An fopen wrapper for no-warnings crossplatform fopen.

Msvc compiler considers fopen to be insecure and suggests to use their alternative. This is a wrapper for this alternative. Another way is to #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does not sound like a good idea.

Parameters
file_nameThe path to the file to open
modeOpening mode. Check fopen()
Returns
The FILE* or NULL in failure

Definition at line 32 of file io_posix.c.

Here is the call graph for this function:

bool ethash_get_default_dirname ( char *  strbuf,
size_t  buffsize 
)

Gets the default directory name for the DAG depending on the system.

The spec defining this directory is here: https://github.com/ethereum/wiki/wiki/Ethash-DAG

Parameters
[out]strbufA string buffer of sufficient size to keep the null termninated string of the directory name
[in]buffsizeSize of strbuf in bytes
Returns
true for success and false otherwise

Definition at line 89 of file io_posix.c.

Here is the call graph for this function:

char* ethash_io_create_filename ( char const *  dirname,
char const *  filename,
size_t  filename_length 
)

Create the filename for the DAG.

Parameters
dirnameThe directory name in which the DAG file should reside If it does not end with a directory separator it is appended.
filenameThe actual name of the file
filename_lengthThe length of the filename in bytes
Returns
A char* containing the full name. User must deallocate.

Definition at line 53 of file io_posix.c.

Here is the call graph for this function:

bool ethash_mkdir ( char const *  dirname)

A cross-platform mkdir wrapper to create a directory or assert it's there.

Parameters
dirnameThe full path of the directory to create
Returns
true if the directory was created or if it already existed

Definition at line 42 of file io_posix.c.

char* ethash_strncat ( char *  dest,
size_t  dest_size,
char const *  src,
size_t  count 
)

An strncat wrapper for no-warnings crossplatform strncat.

Msvc compiler considers strncat to be insecure and suggests to use their alternative. This is a wrapper for this alternative. Another way is to #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does not sound like a good idea.

Parameters
desDestination buffer
dest_sizeMaximum size of the destination buffer. This is the extra argument for the MSVC secure strncat
srcSouce buffer
countNumber of bytes to copy from source
Returns
If all is well returns the dest buffer. If there is an error returns NULL

Definition at line 37 of file io_posix.c.

Here is the caller graph for this function: