30
30
*/
31
31
32
32
/* Changelog:
33
+ Oct. 20, 2024: by Thomas Beutlich
34
+ Removed legacy behaviour in ModelicaInternal_stat for
35
+ MSVC Visual Studio >= 2015 (ticket #4473)
36
+
33
37
Jan. 15, 2024: by Thomas Beutlich
34
38
Utilized ModelicaDuplicateString and
35
39
ModelicaDuplicateStringWithErrorReturn (ticket #3686)
@@ -402,10 +406,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
402
406
struct _stat fileInfo ;
403
407
int statReturn = _stat (name , & fileInfo );
404
408
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:" */
409
410
const char * firstSlash = strpbrk (name , "/\\" );
410
411
const char * firstColon = strchr (name , ':' );
411
412
const char c = (NULL != firstColon ) ? firstColon [1 ] : '\0' ;
@@ -419,6 +420,10 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
419
420
free (nameTmp );
420
421
}
421
422
}
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\" */
422
427
else if (NULL != firstSlash && len > 1 &&
423
428
('/' == name [len - 1 ] || '\\' == name [len - 1 ])) {
424
429
char * nameTmp = (char * )malloc (len * (sizeof (char )));
@@ -429,6 +434,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
429
434
free (nameTmp );
430
435
}
431
436
}
437
+ #endif
432
438
}
433
439
if ( statReturn != 0 ) {
434
440
type = FileType_NoFile ;
0 commit comments