3030*/
3131
3232/* Changelog:
33+ Oct. 20, 2024: by Thomas Beutlich
34+ Removed legacy behaviour in ModelicaInternal_stat for
35+ MSVC Visual Studio >= 2015 (ticket #4473)
36+
3337 Jan. 15, 2024: by Thomas Beutlich
3438 Utilized ModelicaDuplicateString and
3539 ModelicaDuplicateStringWithErrorReturn (ticket #3686)
@@ -402,10 +406,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
402406 struct _stat fileInfo ;
403407 int statReturn = _stat (name , & fileInfo );
404408 if (0 != statReturn ) {
405- /* For some reason _stat requires "a:\" and "a:\test1" but fails
406- * on "a:" and "a:\test1\", respectively. It could be handled in the
407- * Modelica code, but seems better to have it here.
408- */
409+ /* _stat requires "a:\" instead of "a:" */
409410 const char * firstSlash = strpbrk (name , "/\\" );
410411 const char * firstColon = strchr (name , ':' );
411412 const char c = (NULL != firstColon ) ? firstColon [1 ] : '\0' ;
@@ -419,6 +420,11 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
419420 free (nameTmp );
420421 }
421422 }
423+ #if defined(_MSC_VER ) && _MSC_VER >= 1900
424+ /* _stat accepts both "a:\dir" and "a:\dir\" */
425+ #else
426+ /* _stat requires "a:\dir" instead of "a:\dir\" */
427+ /* required for VS 2013 and earlier */
422428 else if (NULL != firstSlash && len > 1 &&
423429 ('/' == name [len - 1 ] || '\\' == name [len - 1 ])) {
424430 char * nameTmp = (char * )malloc (len * (sizeof (char )));
@@ -429,6 +435,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
429435 free (nameTmp );
430436 }
431437 }
438+ #endif
432439 }
433440 if ( statReturn != 0 ) {
434441 type = FileType_NoFile ;
0 commit comments