From 5cac9a3498b4739a8859bbce58f10c2d10ae554a Mon Sep 17 00:00:00 2001 From: Prabhanjan Kambadur Date: Tue, 2 Nov 2004 21:48:31 +0000 Subject: [PATCH] making some changes to ompi_config_bottom and also changing the logic for windows portion of ompi_empty_dir This commit was SVN r3480. --- include/ompi_config_bottom.h | 2 +- src/util/session_dir.c | 79 ++++++++++++++++++++--------------- vcproj/openmpi/openmpi.vcproj | 4 +- 3 files changed, 48 insertions(+), 37 deletions(-) diff --git a/include/ompi_config_bottom.h b/include/ompi_config_bottom.h index 67ec20312e..47a715310f 100644 --- a/include/ompi_config_bottom.h +++ b/include/ompi_config_bottom.h @@ -13,7 +13,7 @@ #ifndef OMPI_CONFIG_BOTTOM_H #define OMPI_CONFIG_BOTTOM_H -#ifdef WIN32 +#if defined(WIN32) && defined(OMPI_BUILDING) #include "win32/win_compat.h" #define OMPI_COMP_EXPORT __declspec(dllexport) #endif diff --git a/src/util/session_dir.c b/src/util/session_dir.c index 4ca8c2c2de..ce0f99749e 100644 --- a/src/util/session_dir.c +++ b/src/util/session_dir.c @@ -425,29 +425,36 @@ ompi_dir_empty(char *pathname) } #else bool empty = false; + char search_path[MAX_PATH]; HANDLE file; WIN32_FIND_DATA file_data; TCHAR *file_name; if (NULL != pathname) { - if (INVALID_HANDLE_VALUE == (file = FindFirstFile(pathname, &file_data))) { + strncpy(search_path, pathname, strlen(pathname)+1); + strncat (search_path, "\\*", 3); + file = FindFirstFile(search_path, &file_data); + + if (INVALID_HANDLE_VALUE == file) { + FindClose(&file_data); return; - } else while (!empty) { + } + + do { if ((0 != strcmp(file_data.cFileName, ".")) && - (0 != strcmp(file_data.cFileName, "..")) && - (!(file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) && - (0 != strncmp(file_data.cFileName,"output-", strlen("output-"))) && - (0 != strcmp(file_data.cFileName,"universe-setup.txt-"))) { - /*remove the file */ - file_name = ompi_os_path(false, pathname, file_data.cFileName, NULL); - DeleteFile(file_name); + (0 != strcmp(file_data.cFileName, "..")) && + (!(file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) && + (0 != strncmp(file_data.cFileName,"output-", strlen("output-"))) && + (0 != strcmp(file_data.cFileName,"universe-setup.txt-"))) { + + file_name = ompi_os_path(false, pathname, file_data.cFileName, NULL); + DeleteFile(file_name); + } - if (!FindNextFile(pathname, &file_data)) { - if (ERROR_NO_MORE_FILES == GetLastError()) { + if (!FindNextFile(search_path, &file_data)) { empty = true; - } } - } + } while(!empty); FindClose(&file_data); } #endif @@ -476,30 +483,34 @@ static bool ompi_is_empty(char *pathname) } return false; #else - /* ANJU: check this logic again PLEASE */ - bool empty = true; + char search_path[MAX_PATH]; HANDLE file; WIN32_FIND_DATA file_data; if (NULL != pathname) { - if (!(INVALID_HANDLE_VALUE == (file = FindFirstFile(pathname, &file_data)))) { - while(empty) { - if ((0 != strcmp(file_data.cFileName, ".")) && - (0 != strcmp(file_data.cFileName, ".."))) { - if (!FindNextFile(pathname, &file_data)) { - if (ERROR_NO_MORE_FILES == GetLastError()) { - empty = true; - } else { - empty = false; - } - } else { - empty = false; - } - } - } /* end while */ - } /* endif */ - } /* end outer if */ - return empty; + strncpy(search_path, pathname, strlen(pathname)+1); + strncat (search_path, "\\*", 3); + + file = FindFirstFile(search_path, &file_data); + if (INVALID_HANDLE_VALUE == file) { + FindClose(&file_data); + return true; + } + + if (0 != strcmp(file_data.cFileName, ".") || 0 != strcmp(file_data.cFileName, "..")) { + FindClose(&file_data); + return false; + } + + while (0 != FindNextFile(search_path, &file_data)) { + if (0 != strcmp(file_data.cFileName, ".") || 0 != strcmp(file_data.cFileName, "..")) { + FindClose(&file_data); + return false; + } + } + } + + FindClose(&file_data); + return true; #endif /* ifndef WIN32 */ } - diff --git a/vcproj/openmpi/openmpi.vcproj b/vcproj/openmpi/openmpi.vcproj index fe8d4ba1eb..f8145fbae9 100755 --- a/vcproj/openmpi/openmpi.vcproj +++ b/vcproj/openmpi/openmpi.vcproj @@ -18,7 +18,7 @@ CharacterSet="2"> + RelativePath="hello.c">