You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2022/01/02 19:48:53 UTC
svn commit: r1896625 - /apr/apr/trunk/file_io/win32/filestat.c
Author: ivan
Date: Sun Jan 2 19:48:53 2022
New Revision: 1896625
URL: http://svn.apache.org/viewvc?rev=1896625&view=rev
Log:
Refactor code for further code improvements.
* file_io/win32/filestat.c
(apr_file_info_get): Inline fillin_fileinfo() to apr_file_info_get().
Modified:
apr/apr/trunk/file_io/win32/filestat.c
Modified: apr/apr/trunk/file_io/win32/filestat.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/filestat.c?rev=1896625&r1=1896624&r2=1896625&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/filestat.c (original)
+++ apr/apr/trunk/file_io/win32/filestat.c Sun Jan 2 19:48:53 2022
@@ -489,7 +489,57 @@ APR_DECLARE(apr_status_t) apr_file_info_
return apr_get_os_error();
}
- fillin_fileinfo(finfo, (WIN32_FILE_ATTRIBUTE_DATA *) &FileInfo, 1, 0, thefile->fname, wanted);
+ memset(finfo, '\0', sizeof(*finfo));
+
+ FileTimeToAprTime(&finfo->atime, &FileInfo.ftLastAccessTime);
+ FileTimeToAprTime(&finfo->ctime, &FileInfo.ftCreationTime);
+ FileTimeToAprTime(&finfo->mtime, &FileInfo.ftLastWriteTime);
+
+#if APR_HAS_LARGE_FILES
+ finfo->size = (apr_off_t)FileInfo.nFileSizeLow
+ | ((apr_off_t)FileInfo.nFileSizeHigh << 32);
+#else
+ finfo->size = (apr_off_t)FileInfo.nFileSizeLow;
+ if (finfo->size < 0 || FileInfo.nFileSizeHigh)
+ finfo->size = 0x7fffffff;
+#endif
+
+ if (wanted & APR_FINFO_LINK &&
+ reparse_point_is_link(&FileInfo, 0, thefile->fname)) {
+ finfo->filetype = APR_LNK;
+ }
+ else if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ finfo->filetype = APR_DIR;
+ }
+ else if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) {
+ /* Warning: This test only succeeds on Win9x, on NT these files
+ * (con, aux, nul, lpt#, com# etc) escape early detection!
+ */
+ finfo->filetype = APR_CHR;
+ }
+ else {
+ /* Warning: Short of opening the handle to the file, the 'FileType'
+ * appears to be unknowable (in any trustworthy or consistent sense)
+ * on WinNT/2K as far as PIPE, CHR, etc are concerned.
+ */
+ finfo->filetype = APR_REG;
+ }
+
+ /* The following flags are [for this moment] private to Win32.
+ * That's the only excuse for not toggling valid bits to reflect them.
+ */
+ if (FileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+ finfo->protection = APR_FREADONLY;
+
+ finfo->valid = APR_FINFO_ATIME | APR_FINFO_CTIME | APR_FINFO_MTIME
+ | APR_FINFO_SIZE | APR_FINFO_TYPE; /* == APR_FINFO_MIN */
+
+ /* Only byhandle optionally tests link targets, so tell that caller
+ * what it wants to hear, otherwise the byattributes is never
+ * reporting anything but the link.
+ */
+ if (wanted & APR_FINFO_LINK)
+ finfo->valid |= APR_FINFO_LINK;
if (finfo->filetype == APR_REG)
{