aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorRonan Desplanques <desplanques@adacore.com>2023-10-16 17:09:25 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-11-07 10:15:04 +0100
commit63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc (patch)
treee667b44e5e5e3cd3dbb6480a6f9e4562d10ba0e6 /gcc/ada
parenta2e4afc6f6bd0fd3c3894a2192fcc09e0b60f0be (diff)
downloadgcc-63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc.zip
gcc-63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc.tar.gz
gcc-63eaa7eeb68cd967ce9a93a4669dc46f1048b0bc.tar.bz2
ada: Fix Ada.Directories.Modification_Time on Windows
Before this patch, Ada.Directories.Modification_Time called GetFileAttributesExA under the hood on Windows. That would sometimes fail to work with files whose names were non-ASCII. This patch replaces the call to GetFileAttributesExA with a call to GetFileAttributesEx preceded by an encoding scheme conversion, as is done in other functions of the run-time library. This fixes the issues that were observed with the previous implementations. gcc/ada/ * adaint.c (__gnat_file_time): Fix Windows version.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/adaint.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 2a193ef..bb4ed26 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -1507,7 +1507,16 @@ extern long long __gnat_file_time(char* name)
long long ll_time;
} t_write;
- if (!GetFileAttributesExA(name, GetFileExInfoStandard, &fad)) {
+ TCHAR wname [GNAT_MAX_PATH_LEN + 2];
+ int name_len;
+
+ S2WSC (wname, name, GNAT_MAX_PATH_LEN + 2);
+ name_len = _tcslen (wname);
+
+ if (name_len > GNAT_MAX_PATH_LEN)
+ return LLONG_MIN;
+
+ if (!GetFileAttributesEx(wname, GetFileExInfoStandard, &fad)) {
return LLONG_MIN;
}