From ba7084a17ecb13d8f70e80d6f0827afd7cbf5f4f Mon Sep 17 00:00:00 2001 From: shankar Date: Fri, 5 Mar 2010 03:25:36 +0000 Subject: checking error status according to AXIS2C-1362 git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@919278 13f79535-47bb-0310-9956-ffa450edef68 --- util/src/dir_handler.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/util/src/dir_handler.c b/util/src/dir_handler.c index 4a5e51e..50d00b8 100644 --- a/util/src/dir_handler.c +++ b/util/src/dir_handler.c @@ -197,28 +197,52 @@ axutil_dir_handler_list_service_or_module_dirs( */ axis2_status_t status = AXIS2_FAILURE; - AXIS2_ENV_CHECK(env, NULL); - file_list = axutil_array_list_create(env, 0); + if(!AXIS2_GETCWD(cwd, 500)) + { + /* if we can't identify working directory, it will be a critical failure */ + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot identify working directory"); exit(1); + } /* pathname is path of services directory or modules directory. */ chdir_result = AXIS2_CHDIR(pathname); + if(chdir_result == -1) + { + /* we could not be able to find the path given. However, this will not be a problem + * because services and modules are optional. + */ + AXIS2_LOG_INFO(env->log, "Cannot find path %s.", pathname); + return NULL; + } #ifdef AXIS2_ARCHIVE_ENABLED axis2_archive_extract(); #endif count = AXIS2_SCANDIR(pathname, &files, dir_select, AXIS2_ALPHASORT); chdir_result = AXIS2_CHDIR(cwd); + if(chdir_result == -1) + { + /* we are changing back to working directory. If we can't change, this will be critical*/ + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot change directory to working directory"); + exit(1); + } /* If no files found, make a non-selectable menu item */ if(count <= 0) { - axutil_array_list_free(file_list, env); AXIS2_LOG_INFO(env->log, "No files in the path %s.", pathname); return NULL; } + file_list = axutil_array_list_create(env, 0); + if(!file_list) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create file list."); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + for(i = 1; i < (count + 1); ++i) { axis2_char_t *fname = NULL; -- cgit v1.1-32-gdbae