Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill borken code for _WIN32
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 4 Nov 2017 17:39:25 +0000 (18:39 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 4 Nov 2017 17:51:46 +0000 (18:51 +0100)
- 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
src/simgrid/sg_config.cpp
src/surf/surf_interface.cpp

index 7b0f721..54c1532 100644 (file)
@@ -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);
index 17bb94f..c8a6579 100644 (file)
@@ -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;
 
index bd45679..8a8d2ee 100644 (file)
@@ -170,47 +170,6 @@ FILE *surf_fopen(const char *name, const char *mode)
   return nullptr;
 }
 
-#ifdef _WIN32
-#include <windows.h>
-#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.