From f554237f7dd771127a04b8046eeb30a5276a3d4a Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 4 Nov 2017 18:39:25 +0100 Subject: [PATCH 1/1] kill borken code for _WIN32 - This code was supposed to retrieve the current directory on Windows to pre-seed the path in which we search for trace files (and used to search for include files too) - But it is borken: instead of returning the current dir, it only returned the current drive. So the path was not seeded with a useful value. - Plus, now that wubuntu is working correctly, we will soon kill all _WIN32 specific stuff. --- src/include/surf/surf.h | 6 ------ src/simgrid/sg_config.cpp | 9 ++------ src/surf/surf_interface.cpp | 41 ------------------------------------- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 7b0f721b4d..54c15326d6 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -419,12 +419,6 @@ XBT_PUBLIC(void) surf_exit(); /* surf parse file related (public because called from a test suite) */ XBT_PUBLIC(void) parse_platform_file(const char *file); -/* - * Returns the initial path. On Windows the initial path is the current directory for the current process in the other - * case the function returns "./" that represents the current directory on Unix/Linux platforms. - */ -const char *__surf_get_initial_path(); - /********** Tracing **********/ /* from surf_instr.c */ void TRACE_surf_action(surf_action_t surf_action, const char *category); diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 17bb94fc35..c8a657913d 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -552,13 +552,8 @@ void sg_config_init(int *argc, char **argv) "Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end."); xbt_cfg_register_alias("clean-atexit","clean_atexit"); - if (surf_path.empty()) { - /* retrieves the current directory of the current process */ - const char *initial_path = __surf_get_initial_path(); - xbt_assert((initial_path), "__surf_get_initial_path() failed! Can't resolve current Windows directory"); - - xbt_cfg_setdefault_string("path", initial_path); - } + if (surf_path.empty()) + xbt_cfg_setdefault_string("path", "./"); _sg_cfg_init_status = 1; diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index bd45679669..8a8d2ee9b3 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -170,47 +170,6 @@ FILE *surf_fopen(const char *name, const char *mode) return nullptr; } -#ifdef _WIN32 -#include -#define MAX_DRIVE 26 -static const char *disk_drives_letter_table[MAX_DRIVE] = { - "A:\\","B:\\","C:\\","D:\\","E:\\","F:\\","G:\\","H:\\","I:\\","J:\\","K:\\","L:\\","M:\\", - "N:\\","O:\\","P:\\","Q:\\","R:\\","S:\\","T:\\","U:\\","V:\\","W:\\","X:\\","Y:\\","Z:\\" -}; -#endif - -/* - * Returns the initial path. On Windows the initial path is - * the current directory for the current process in the other - * case the function returns "./" that represents the current - * directory on Unix/Linux platforms. - */ - -const char *__surf_get_initial_path() -{ - -#ifdef _WIN32 - unsigned i; - char current_directory[MAX_PATH + 1] = { 0 }; - unsigned int len = GetCurrentDirectory(MAX_PATH + 1, current_directory); - char root[4] = { 0 }; - - if (not len) - return nullptr; - - strncpy(root, current_directory, 3); - - for (i = 0; i < MAX_DRIVE; i++) { - if (toupper(root[0]) == disk_drives_letter_table[i][0]) - return disk_drives_letter_table[i]; - } - - return nullptr; -#else - return "./"; -#endif -} - /* The __surf_is_absolute_file_path() returns 1 if * file_path is a absolute file path, in the other * case the function returns 0. -- 2.20.1