summaryrefslogtreecommitdiff
path: root/support/dktools/dk4appdeldir.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/dk4appdeldir.c
Initial commit
Diffstat (limited to 'support/dktools/dk4appdeldir.c')
-rw-r--r--support/dktools/dk4appdeldir.c259
1 files changed, 259 insertions, 0 deletions
diff --git a/support/dktools/dk4appdeldir.c b/support/dktools/dk4appdeldir.c
new file mode 100644
index 0000000000..108a977496
--- /dev/null
+++ b/support/dktools/dk4appdeldir.c
@@ -0,0 +1,259 @@
+/*
+ WARNING: This file was generated by dkct.
+ Changes you make here will be lost if dkct is run again!
+ You should modify the original source and run dkct on it.
+ Original source: dk4appdeldir.ctr
+*/
+
+/*
+Copyright (C) 2015-2017, Dirk Krause
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above opyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+* Neither the name of the author nor the names of contributors may be used
+ to endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/** @file dk4appdeldir.c The dk4appdeldir module.
+*/
+
+
+#line 10 "dk4appdeldir.ctr"
+
+
+#include "dk4conf.h"
+#include "dk4types.h"
+
+#if DK4_ON_WINDOWS
+#ifndef WINDOWS_H_INCLUDED
+#include <windows.h>
+#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 <errno.h>
+#define ERRNO_H_INCLUDED 1
+#endif
+#endif
+
+
+
+
+
+#line 64 "dk4appdeldir.ctr"
+
+
+
+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;
+
+
+#line 192 "dk4appdeldir.ctr"
+ if (NULL != fn) {
+
+#line 193 "dk4appdeldir.ctr"
+ 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) {
+
+#line 206 "dk4appdeldir.ctr"
+ if (0 != dk4file_exists(fn, NULL)) {
+ dk4app_del_dir_report(fn, &er, app);
+ } else {
+
+#line 209 "dk4appdeldir.ctr"
+ back = 1; /* File does not exist */
+ }
+ }
+ }
+
+
+#line 214 "dk4appdeldir.ctr"
+ return back;
+}
+