From: Kevin Day Date: Mon, 11 May 2020 01:58:19 +0000 (-0500) Subject: Update: finish the @todo in errno handling of recent directory additions X-Git-Tag: 0.5.0~262 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=5f94fb485f6e760313b060ea49b50f6999e3042d;p=fll Update: finish the @todo in errno handling of recent directory additions --- diff --git a/level_0/f_directory/c/directory.c b/level_0/f_directory/c/directory.c index 2dbc324..6c245ba 100644 --- a/level_0/f_directory/c/directory.c +++ b/level_0/f_directory/c/directory.c @@ -82,8 +82,6 @@ extern "C" { result = remove(path); } - // @todo properly handle the correct error codes, this was simply copied over from f_file_remove(). - if (result < 0) { if (errno == EACCES) { return f_status_set_error(f_access_denied); @@ -118,6 +116,18 @@ extern "C" { else if (errno == EROFS) { return f_status_set_error(f_read_only); } + else if (errno == EOVERFLOW) { + return f_status_set_error(f_number_overflow); + } + else if (errno == EMFILE) { + return f_status_set_error(f_file_max_descriptors); + } + else if (errno == ENFILE) { + return f_status_set_error(f_file_max_open); + } + else if (errno == EINVAL) { + return f_status_set_error(f_invalid_parameter); + } return f_status_set_error(f_failure); } @@ -148,8 +158,6 @@ extern "C" { result = remove(path); } - // @todo properly handle the correct error codes, this was simply copied over from f_file_remove(). - if (result < 0) { if (errno == EACCES) { return f_status_set_error(f_access_denied); @@ -184,6 +192,18 @@ extern "C" { else if (errno == EROFS) { return f_status_set_error(f_read_only); } + else if (errno == EOVERFLOW) { + return f_status_set_error(f_number_overflow); + } + else if (errno == EMFILE) { + return f_status_set_error(f_file_max_descriptors); + } + else if (errno == ENFILE) { + return f_status_set_error(f_file_max_open); + } + else if (errno == EINVAL) { + return f_status_set_error(f_invalid_parameter); + } return f_status_set_error(f_failure); } diff --git a/level_0/f_directory/c/directory.h b/level_0/f_directory/c/directory.h index 82a1612..8f55a9a 100644 --- a/level_0/f_directory/c/directory.h +++ b/level_0/f_directory/c/directory.h @@ -195,6 +195,9 @@ extern "C" { * f_prohibited (with error bit) if filesystem does not allow for removing. * f_read_only (with error bit) if file is read-only. * f_failure (with error bit) for any other (unlink()) error. + * f_number_overflow (with error bit) on integer overflow. + * f_file_max_descriptors (with error bit) if max file descriptors was reached. + * f_file_max_open (with error bit) too many open files. * * @see nftw() * @see remove() diff --git a/level_2/fll_directory/c/directory.h b/level_2/fll_directory/c/directory.h index 8007d09..e1b4af1 100644 --- a/level_2/fll_directory/c/directory.h +++ b/level_2/fll_directory/c/directory.h @@ -60,6 +60,8 @@ extern "C" { * f_directory_error_descriptor (with error bit) on directory file descriptor error. * f_directory_error_stream (with error bit) on directory stream error. * f_directory_error_unsupported (with error bit) on directory file descriptor not supported. + * f_file_max_descriptors (with error bit) if max file descriptors was reached. + * f_file_max_open (with error bit) too many open files. * * @see alphasort() * @see scandir()