diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-10-27 12:56:12 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2015-10-27 12:56:12 +0100 |
commit | 2f97d24cad349a09ee1beb3e20b636925aa9baa9 (patch) | |
tree | 35eda234e18f129cc90e7b4653320126aa073196 /gcc/ada/adaint.c | |
parent | 4e48e02be82c63ebe6687bca93f07b76b5765261 (diff) | |
download | gcc-2f97d24cad349a09ee1beb3e20b636925aa9baa9.zip gcc-2f97d24cad349a09ee1beb3e20b636925aa9baa9.tar.gz gcc-2f97d24cad349a09ee1beb3e20b636925aa9baa9.tar.bz2 |
[multiple changes]
2015-10-27 Tristan Gingold <gingold@adacore.com>
* bindgen.adb (System_BB_CPU_Primitives_Multiprocessors_Used):
New variable.
(Gen_Adainit): Call Start_All_CPUs if the above
variable is set to true.
2015-10-27 Emmanuel Briot <briot@adacore.com>
* adaint.c, s-os_lib.adb, s-os_lib.ads (Copy_File_Attributes): New
subprogram.
From-SVN: r229429
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r-- | gcc/ada/adaint.c | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index df6dbff..5fef49c 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -2902,6 +2902,8 @@ char __gnat_environment_char = '$'; mode = 1 : In this mode, time stamps and read/write/execute attributes are copied. + mode = 2 : In this mode, only read/write/execute attributes are copied + Returns 0 if operation was successful and -1 in case of error. */ int @@ -2921,39 +2923,46 @@ __gnat_copy_attribs (char *from ATTRIBUTE_UNUSED, char *to ATTRIBUTE_UNUSED, S2WSC (wfrom, from, GNAT_MAX_PATH_LEN + 2); S2WSC (wto, to, GNAT_MAX_PATH_LEN + 2); - /* retrieve from times */ + /* Do we need to copy the timestamp ? */ - hfrom = CreateFile - (wfrom, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (mode != 2) { + /* retrieve from times */ - if (hfrom == INVALID_HANDLE_VALUE) - return -1; + hfrom = CreateFile + (wfrom, GENERIC_READ, 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); - res = GetFileTime (hfrom, &fct, &flat, &flwt); + if (hfrom == INVALID_HANDLE_VALUE) + return -1; - CloseHandle (hfrom); + res = GetFileTime (hfrom, &fct, &flat, &flwt); - if (res == 0) - return -1; + CloseHandle (hfrom); - /* retrieve from times */ + if (res == 0) + return -1; - hto = CreateFile - (wto, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + /* retrieve from times */ - if (hto == INVALID_HANDLE_VALUE) - return -1; + hto = CreateFile + (wto, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); - res = SetFileTime (hto, NULL, &flat, &flwt); + if (hto == INVALID_HANDLE_VALUE) + return -1; - CloseHandle (hto); + res = SetFileTime (hto, NULL, &flat, &flwt); - if (res == 0) - return -1; + CloseHandle (hto); + if (res == 0) + return -1; + } + + /* Do we need to copy the permissions ? */ /* Set file attributes in full mode. */ - if (mode == 1) + if (mode != 0) { DWORD attribs = GetFileAttributes (wfrom); @@ -2971,26 +2980,24 @@ __gnat_copy_attribs (char *from ATTRIBUTE_UNUSED, char *to ATTRIBUTE_UNUSED, GNAT_STRUCT_STAT fbuf; struct utimbuf tbuf; - if (GNAT_STAT (from, &fbuf) == -1) - { - return -1; - } + if (GNAT_STAT (from, &fbuf) == -1) { + return -1; + } - tbuf.actime = fbuf.st_atime; - tbuf.modtime = fbuf.st_mtime; + /* Do we need to copy timestamp ? */ + if (mode != 2) { + tbuf.actime = fbuf.st_atime; + tbuf.modtime = fbuf.st_mtime; - if (utime (to, &tbuf) == -1) - { - return -1; - } + if (utime (to, &tbuf) == -1) { + return -1; + } + } - if (mode == 1) - { - if (chmod (to, fbuf.st_mode) == -1) - { + /* Do we need to copy file permissions ? */ + if (mode != 0 && (chmod (to, fbuf.st_mode) == -1)) { return -1; - } - } + } return 0; #endif |