/* 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: dk4dira.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 dk4dira.c The dk4dira module. */ #line 38 "dk4dira.ctr" #include "dk4conf.h" #include "dk4const.h" #if DK4_ON_WINDOWS #ifndef WINDOWS_H_INCLUDED #include #define WINDOWS_H_INCLUDED 1 #endif #endif #if DK4_HAVE_ERRNO_H #ifndef ERRNO_H_INCLUDED #include #define ERRNO_H_INCLUDED 1 #endif #endif #include "dk4mem.h" #include "dk4dira.h" #include "dk4error.h" #if DK4_ON_WINDOWS #include "dk4maodd.h" #include "dk4maodh.h" #endif #line 67 "dk4dira.ctr" dk4_dir_t * dk4dir_open_app(const dkChar *path, int om, dk4_app_t *app) { #if DK4_ON_WINDOWS dkChar eb1[8 * sizeof(dk4_um_t) + 16]; dkChar eb2[8 * sizeof(dk4_um_t) + 16]; #endif dk4_er_t er; dk4_dir_t *back = NULL; #if DK4_ON_WINDOWS DWORD le; int found; int res; #endif if (NULL != path) { dk4error_init(&er); back = dk4dir_open(path, om, &er); if (NULL == back) { switch (er.ec) { case DK4_E_NOT_SUPPORTED : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 145, path); } break; case DK4_E_MEMORY_ALLOCATION_FAILED : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 103, path); } break; case DK4_E_MATH_OVERFLOW : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 146, path); } break; case DK4_E_BUFFER_TOO_SMALL : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 42, path); } break; #if !DK4_ON_WINDOWS case DK4_E_OPENDIR_FAILED : { switch (er.dt.iDetails1) { #ifdef EACCES case EACCES : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 138, path); } break; #endif #ifdef EBADF case EBADF : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 122, path); } break; #endif #ifdef EMFILE case EMFILE : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 114, path); } break; #endif #ifdef ENFILE case ENFILE : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 115, path); } break; #endif #ifdef ENOENT case ENOENT : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 51, path); } break; #endif #ifdef ENOMEM case ENOMEM : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 142, path); } break; #endif #ifdef ENOTDIR case ENOTDIR : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 150, path); } break; #endif #ifdef ELOOP case ELOOP : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 61, path); } break; #endif #ifdef ENAMETOOLONG case ENAMETOOLONG : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 65, path); } break; #endif default : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 10, path); } break; } } break; #endif #if DK4_ON_WINDOWS case DK4_E_FINDFIRSTFILE_FAILED : { le = er.dt.lDetails1; found = 0; if (ERROR_FILE_NOT_FOUND == le) { dk4app_log_base3(app, DK4_LL_ERROR, 144, 147, path); found = 1; } if (ERROR_ACCESS_DENIED == le) { dk4app_log_base3(app, DK4_LL_ERROR, 144, 138, path); found = 1; } if (ERROR_PATH_NOT_FOUND == le) { dk4app_log_base3(app, DK4_LL_ERROR, 144, 51, path); found = 1; } if (ERROR_BAD_NET_NAME == le) { dk4app_log_base3(app, DK4_LL_ERROR, 144, 74, path); found = 1; } if (ERROR_BAD_NETPATH == le) { dk4app_log_base3(app, DK4_LL_ERROR, 144, 75, path); found = 1; } if (0 == found) { res = dk4ma_write_decimal_unsigned( eb1,DK4_SIZEOF(eb1,dkChar),(dk4_um_t)le,0,NULL ); if (0 != res) { res = dk4ma_write_hex_unsigned( eb2, DK4_SIZEOF(eb2,dkChar), (dk4_um_t)le, 0, NULL ); } if (0 != res) { dk4app_log_base7(app,DK4_LL_ERROR,144,69,70,71,path,eb1,eb2); } else { dk4app_log_base3(app, DK4_LL_ERROR, 144, 77, path); } } } break; #endif default : { dk4app_log_base3(app, DK4_LL_ERROR, 144, 10, path); } break; } } } return back; }