From e716a56d2f16d77dd30ad9e9fa9f20f1ed18d009 Mon Sep 17 00:00:00 2001 From: Erik Sohns Date: Mon, 5 Sep 2022 22:58:59 +0200 Subject: [PATCH 1/3] fixed fstat on win32 (support 64 bit file sizes) --- ACE/ace/OS_NS_sys_stat.inl | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ACE/ace/OS_NS_sys_stat.inl b/ACE/ace/OS_NS_sys_stat.inl index b8f7c9fc829db..255dcf9287fec 100644 --- a/ACE/ace/OS_NS_sys_stat.inl +++ b/ACE/ace/OS_NS_sys_stat.inl @@ -41,23 +41,28 @@ namespace ACE_OS ACE_OS::set_errno_to_last_error (); return -1; } - else if (fdata.nFileSizeHigh != 0) + if (fdata.nFileSizeHigh != 0) { +#if defined (_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) + ULARGE_INTEGER ul; + ul.HighPart = fdata.nFileSizeHigh; + ul.LowPart = fdata.nFileSizeLow; + stp->st_size = ul.QuadPart; +#else errno = EINVAL; return -1; +#endif // _FILE_OFFSET_BITS == 64 } else - { - stp->st_size = fdata.nFileSizeLow; - stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); - stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); - stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); - stp->st_nlink = static_cast (fdata.nNumberOfLinks); - stp->st_dev = stp->st_rdev = 0; // No equivalent conversion. - stp->st_mode = S_IXOTH | S_IROTH | - (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) | - (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG); - } + stp->st_size = fdata.nFileSizeLow; + stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); + stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); + stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); + stp->st_nlink = static_cast (fdata.nNumberOfLinks); + stp->st_dev = stp->st_rdev = 0; // No equivalent conversion. + stp->st_mode = S_IXOTH | S_IROTH | + (fdata.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? 0 : S_IWOTH) | + (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG); return 0; #elif defined (ACE_LACKS_FSTAT) ACE_NOTSUP_RETURN (-1); From 32775801713d0d4ccaacdb3b4a3a76f82ba45429 Mon Sep 17 00:00:00 2001 From: Erik Sohns Date: Tue, 6 Sep 2022 17:11:50 +0200 Subject: [PATCH 2/3] integrated review comments --- ACE/ace/OS_NS_sys_stat.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ACE/ace/OS_NS_sys_stat.inl b/ACE/ace/OS_NS_sys_stat.inl index 255dcf9287fec..5e45bffa7abca 100644 --- a/ACE/ace/OS_NS_sys_stat.inl +++ b/ACE/ace/OS_NS_sys_stat.inl @@ -53,8 +53,10 @@ namespace ACE_OS return -1; #endif // _FILE_OFFSET_BITS == 64 } - else - stp->st_size = fdata.nFileSizeLow; + else + { + stp->st_size = fdata.nFileSizeLow; + } stp->st_atime = ACE_Time_Value (fdata.ftLastAccessTime).sec (); stp->st_mtime = ACE_Time_Value (fdata.ftLastWriteTime).sec (); stp->st_ctime = ACE_Time_Value (fdata.ftCreationTime).sec (); From ee77bf7b19fa6c3aee51e631cf1395dee3f74736 Mon Sep 17 00:00:00 2001 From: Erik Sohns Date: Tue, 6 Sep 2022 17:23:14 +0200 Subject: [PATCH 3/3] removed whitespace --- ACE/ace/OS_NS_sys_stat.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/ace/OS_NS_sys_stat.inl b/ACE/ace/OS_NS_sys_stat.inl index 5e45bffa7abca..080108478e21a 100644 --- a/ACE/ace/OS_NS_sys_stat.inl +++ b/ACE/ace/OS_NS_sys_stat.inl @@ -53,7 +53,7 @@ namespace ACE_OS return -1; #endif // _FILE_OFFSET_BITS == 64 } - else + else { stp->st_size = fdata.nFileSizeLow; }