From d87eb28bf4a74d392333bb7292979a93da9a78ff Mon Sep 17 00:00:00 2001 From: cherierm Date: Fri, 20 Oct 2006 13:38:25 +0000 Subject: [PATCH 1/1] Considers the windows filename conventions (different on unix/linux). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@2898 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/surf/surf.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/src/surf/surf.c b/src/surf/surf.c index cbb8725c26..ae05341fe5 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -11,6 +11,96 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_kernel, surf, "Logging specific to SURF (kernel)"); + +/* Additional declarations for Windows potability. */ + +#ifndef MAX_DRIVE +#define MAX_DRIVE 26 +#endif + +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:\\" +}; + +/* + * 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(!len) + return NULL; + + strncpy(root,current_directory,3); + + for(i = 0; i