diff options
Diffstat (limited to 'win32/mingw.c')
-rw-r--r-- | win32/mingw.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index c7eeea088..0a1af6b72 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -2001,6 +2001,15 @@ int has_exe_suffix_or_dot(const char *name) | |||
2001 | return last_char_is(name, '.') || has_win_suffix(name, 0); | 2001 | return last_char_is(name, '.') || has_win_suffix(name, 0); |
2002 | } | 2002 | } |
2003 | 2003 | ||
2004 | /* Copy path to an allocated string long enough to allow a file extension | ||
2005 | * to be added. */ | ||
2006 | char *alloc_ext_space(const char *path) | ||
2007 | { | ||
2008 | char *s = xmalloc(strlen(path) + 5); | ||
2009 | strcpy(s, path); | ||
2010 | return s; | ||
2011 | } | ||
2012 | |||
2004 | /* Check if path can be made into an executable by adding a suffix. | 2013 | /* Check if path can be made into an executable by adding a suffix. |
2005 | * The suffix is added to the end of the argument which must be | 2014 | * The suffix is added to the end of the argument which must be |
2006 | * long enough to allow this. | 2015 | * long enough to allow this. |
@@ -2024,6 +2033,22 @@ int add_win32_extension(char *p) | |||
2024 | return FALSE; | 2033 | return FALSE; |
2025 | } | 2034 | } |
2026 | 2035 | ||
2036 | /* | ||
2037 | * Determine if a path represents a WIN32 executable, adding a suffix | ||
2038 | * if necessary. Returns an allocated string if it does, NULL if not. | ||
2039 | */ | ||
2040 | char * | ||
2041 | file_is_win32_exe(const char *name) | ||
2042 | { | ||
2043 | char *path = alloc_ext_space(name); | ||
2044 | |||
2045 | if ((add_win32_extension(path) || file_is_executable(path))) | ||
2046 | return path; | ||
2047 | |||
2048 | free(path); | ||
2049 | return NULL; | ||
2050 | } | ||
2051 | |||
2027 | char * FAST_FUNC bs_to_slash(char *str) | 2052 | char * FAST_FUNC bs_to_slash(char *str) |
2028 | { | 2053 | { |
2029 | char *p; | 2054 | char *p; |
@@ -2193,15 +2218,6 @@ const char *need_system_drive(const char *path) | |||
2193 | return NULL; | 2218 | return NULL; |
2194 | } | 2219 | } |
2195 | 2220 | ||
2196 | /* Copy path to an allocated string long enough to allow a file extension | ||
2197 | * to be added. */ | ||
2198 | char *alloc_ext_space(const char *path) | ||
2199 | { | ||
2200 | char *s = xmalloc(strlen(path) + 5); | ||
2201 | strcpy(s, path); | ||
2202 | return s; | ||
2203 | } | ||
2204 | |||
2205 | int chdir_system_drive(void) | 2221 | int chdir_system_drive(void) |
2206 | { | 2222 | { |
2207 | const char *sd = get_system_drive(); | 2223 | const char *sd = get_system_drive(); |