27 #include <sys/types.h> 33 return fopen_s(&f, file_name, mode) == 0 ? f : NULL;
38 return strncat_s(dest, dest_size, src, count) == 0 ? dest : NULL;
43 int rc = _mkdir(dirname);
44 return rc != -1 || errno == EEXIST;
55 size_t filename_length
58 size_t dirlen = strlen(dirname);
59 size_t dest_size = dirlen + filename_length + 1;
60 if (dirname[dirlen] !=
'\\' || dirname[dirlen] !=
'/') {
63 char*
name = malloc(dest_size);
70 if (dirname[dirlen] !=
'\\' || dirname[dirlen] !=
'/') {
81 if ((fd = _fileno(f)) == -1 || _fstat(fd, &st) != 0) {
84 *ret_size = st.st_size;
90 static const char dir_suffix[] =
"Ethash\\";
92 if (!
SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, (CHAR*)strbuf))) {
99 return ethash_strncat(strbuf, buffsize, dir_suffix,
sizeof(dir_suffix));
bool ethash_file_size(FILE *f, size_t *ret_size)
Get a file's size.
int ethash_fileno(FILE *f)
Get a file descriptor number from a FILE stream.
char * ethash_io_create_filename(char const *dirname, char const *filename, size_t filename_length)
Create the filename for the DAG.
FILE * ethash_fopen(char const *file_name, char const *mode)
An fopen wrapper for no-warnings crossplatform fopen.
bool ethash_mkdir(char const *dirname)
A cross-platform mkdir wrapper to create a directory or assert it's there.
char * ethash_strncat(char *dest, size_t dest_size, char const *src, size_t count)
An strncat wrapper for no-warnings crossplatform strncat.
bool ethash_get_default_dirname(char *strbuf, size_t buffsize)
Gets the default directory name for the DAG depending on the system.