%% 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 DK4DELDIR_H_INCLUDED #include "dk4deldir.h" #endif #ifndef DK4CONST_H_INCLUDED #include "dk4const.h" #endif #ifndef DK4STATD_H_INCLUDED #include "dk4statd.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 $!trace-include void dk4app_del_dir_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: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 54, fn); } break; #if DK4_ON_WINDOWS case DK4_E_REMOVE_DIRECTORY_FAILED : { 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,66,69,70,71,fn,eb1,eb2); } else { dk4app_log_base3(app, DK4_LL_ERROR, 66, 77, fn); } } break; #endif case DK4_E_RMDIR_FAILED: { switch ((erp->dt).iDetails1) { #ifdef EACCES case EACCES: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 55, fn); } break; #endif #ifdef EBUSY case EBUSY: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 49, fn); } break; #endif #ifdef EIO case EIO: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 59, fn); } break; #endif #ifdef EFAULT case EFAULT: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 50, fn); } break; #endif #ifdef EINVAL case EINVAL: { /* ERROR: Invalid path name */ dk4app_log_base3(app, DK4_LL_ERROR, 66, 68, fn); } break; #endif #ifdef ELOOP case ELOOP: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 61, fn); } break; #endif #ifdef ENAMETOOLONG case ENAMETOOLONG: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 65, fn); } break; #endif #ifdef ENOENT case ENOENT: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 51, fn); } break; #endif #ifdef ENOMEM case ENOMEM: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 62, fn); } break; #endif #ifdef ENOTDIR case ENOTDIR: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 150, fn); } break; #endif #ifdef ENOTEMPTY case ENOTEMPTY: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 67, fn); } break; #endif #if defined(EEXIST) && (EEXIST != ENOTEMPTY) case EEXIST: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 67, fn); } break; #endif #ifdef EPERM case EPERM: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 58, fn); } break; #endif #ifdef EROFS case EROFS: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 56, fn); } break; #endif default: { dk4app_log_with_errno( app, DK4_LL_ERROR, 66, 79, 80, 66, 77, fn, (erp->dt).iDetails1 ); } break; } } break; default: { dk4app_log_base3(app, DK4_LL_ERROR, 66, 77, fn); } break; } } int dk4app_del_dir(const dkChar *fn, dk4_app_t *app) { const dkChar *msg[3]; dk4_er_t er; int back = 0; $? "+ dk4app_del_dir %!ds", TR_STR(fn) if (NULL != fn) { $? ". arg ok" if (NULL != app) { if (0 != dk4app_log_do(app, DK4_LL_DEBUG)) { if ((NULL != app->msg_debug) && (25 < app->sz_msg_debug)) { msg[0] = (app->msg_debug)[25]; msg[1] = fn; msg[2] = NULL; dk4app_log_msg(app, DK4_LL_DEBUG, msg, 2); } } } dk4error_init(&er); back = dk4delete_directory(fn, &er); if (0 == back) { $? "! problem" if (0 != dk4file_exists(fn, NULL)) { dk4app_del_dir_report(fn, &er, app); } else { $? ". not found" back = 1; /* File does not exist */ } } } $? "- dk4app_del_dir %d", back return back; }