%% options copyright owner = Dirk Krause copyright year = 2015-xxxx license = bsd %% module #include "dk4conf.h" #include "dk4types.h" #if DK4_ON_WINDOWS #ifndef WINDOWS_H_INCLUDED #include #define WINDOWS_H_INCLUDED 1 #endif #endif #ifndef DK4MEM_H_INCLUDED #include "dk4mem.h" #endif #ifndef DK4APP_H_INCLUDED #include "dk4app.h" #endif #ifndef DK4DELFILE_H_INCLUDED #include "dk4delfile.h" #endif #ifndef DK4STATD_H_INCLUDED #include "dk4statd.h" #endif #ifndef DK4CONST_H_INCLUDED #include "dk4const.h" #endif #ifndef DK4FILED_H_INCLUDED #include "dk4filed.h" #endif #ifndef DK4MAODD_H_INCLUDED #include "dk4maodd.h" #endif #ifndef DK4MAODH_H_INCLUDED #include "dk4maodh.h" #endif #if DK4_HAVE_ERRNO_H #ifndef ERRNO_H_INCLUDED #include #define ERRNO_H_INCLUDED 1 #endif #endif void dk4app_del_file_report(const dkChar *fn, const dk4_er_t *erp, dk4_app_t *app) { #if DK4_ON_WINDOWS dkChar eb1[8 * sizeof(DWORD)]; dkChar eb2[8 * sizeof(DWORD)]; int res; #endif switch (erp->ec) { case DK4_E_NOT_SUPPORTED: { /* ERROR: Failed to delete file, no function available */ dk4app_log_base3(app, DK4_LL_ERROR, 41, 54, fn); } break; #if DK4_ON_WINDOWS case DK4_E_DELETE_FILE_FAILED : { if (ERROR_FILE_NOT_FOUND == (erp->dt).lDetails1) { dk4app_log_base3(app, DK4_LL_ERROR, 41, 51, fn); goto finished; } if (ERROR_ACCESS_DENIED == (erp->dt).lDetails1) { dk4app_log_base3(app, DK4_LL_ERROR, 41, 55, fn); goto finished; } res = dk4ma_write_decimal_unsigned( eb1, DK4_SIZEOF(eb1,dkChar), (dk4_um_t)((erp->dt).lDetails1), 0, NULL ); if (0 != res) { res = dk4ma_write_hex_unsigned( eb2, DK4_SIZEOF(eb2,dkChar), (dk4_um_t)((erp->dt).lDetails1), 0, NULL ); } if (0 != res) { dk4app_log_base7(app,DK4_LL_ERROR,41,69,70,71,fn,eb1,eb2); } else { dk4app_log_base3(app, DK4_LL_ERROR, 41, 77, fn); } goto finished; } break; #endif case DK4_E_UNLINK_FAILED: { switch ((erp->dt).iDetails1) { #ifdef EACCES case EACCES: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 55, fn); } break; #endif #ifdef EBUSY case EBUSY: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 49, fn); } break; #endif #ifdef EFAULT case EFAULT: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 50, fn); } break; #endif #ifdef EIO case EIO: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 59, fn); } break; #endif #ifdef EISDIR case EISDIR: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 52, fn); } break; #endif #ifdef ELOOP case ELOOP: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 61, fn); } break; #endif #ifdef ENAMETOOLONG case ENAMETOOLONG: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 65, fn); } break; #endif #ifdef ENOENT case ENOENT: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 51, fn); } break; #endif #ifdef ENOMEM case ENOMEM: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 62, fn); } break; #endif #ifdef ENOTDIR case ENOTDIR: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 150, fn); } break; #endif #ifdef EPERM case EPERM: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 58, fn); } break; #endif #ifdef EROFS case EROFS: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 56, fn); } break; #endif default: { dk4app_log_with_errno( app, DK4_LL_ERROR, 41, 79, 80, 41, 77, fn, (erp->dt).iDetails1 ); } break; } } break; default: { dk4app_log_base3(app, DK4_LL_ERROR, 41, 77, fn); } break; } #if DK4_ON_WINDOWS finished: ; #endif } int dk4app_del_file(const dkChar *fn, dk4_app_t *app) { const dkChar *msg[3]; dk4_er_t er; int back = 0; if (NULL != fn) { if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { if ((NULL != app->msg_debug) && (26 < app->sz_msg_debug)) { msg[0] = (app->msg_debug)[26]; msg[1] = fn; msg[2] = NULL; dk4app_log_msg(app, DK4_LL_DEBUG, msg, 2); } } } dk4error_init(&er); back = dk4delete_file(fn, &er); if (0 == back) { if (0 != dk4file_exists(fn, NULL)) { dk4app_del_file_report(fn, &er, app); } else { back = 1; /* File does not exist */ } } } return back; }