Mercurial > hg > xemacs-beta
diff src/nt.c @ 359:8e84bee8ddd0 r21-1-9
Import from CVS: tag r21-1-9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:57:55 +0200 |
parents | c6de09ad3017 |
children | a4f53d9b3154 |
line wrap: on
line diff
--- a/src/nt.c Mon Aug 13 10:57:07 2007 +0200 +++ b/src/nt.c Mon Aug 13 10:57:55 2007 +0200 @@ -1288,7 +1288,7 @@ unsigned hash; /* Get the truly canonical filename, if it exists. (Note: this - doesn't resolve aliasing due to subst commands, or recognise hard + doesn't resolve aliasing due to subst commands, or recognize hard links. */ if (!win32_get_long_filename ((char *)name, fullname, MAX_PATH)) abort (); @@ -1301,6 +1301,40 @@ #endif +/* Since stat is encapsulated on Windows NT, we need to encapsulate + the equally broken fstat as well. */ +int +fstat (int handle, struct stat *buffer) +{ + int ret; + BY_HANDLE_FILE_INFORMATION lpFileInfo; + /* Initialize values */ + buffer->st_mode = 0; + buffer->st_size = 0; + buffer->st_dev = 0; + buffer->st_rdev = 0; + buffer->st_atime = 0; + buffer->st_ctime = 0; + buffer->st_mtime = 0; + buffer->st_nlink = 0; + ret = GetFileInformationByHandle((HANDLE) handle, &lpFileInfo); + if (!ret) + { + return -1; + } + else + { + buffer->st_mtime = convert_time (lpFileInfo.ftLastWriteTime); + buffer->st_atime = convert_time (lpFileInfo.ftLastAccessTime); + if (buffer->st_atime == 0) buffer->st_atime = buffer->st_mtime; + buffer->st_ctime = convert_time (lpFileInfo.ftCreationTime); + if (buffer->st_ctime == 0) buffer->st_ctime = buffer->st_mtime; + buffer->st_size = lpFileInfo.nFileSizeLow; + buffer->st_nlink = (short) lpFileInfo.nNumberOfLinks; + return 0; + } +} + /* MSVC stat function can't cope with UNC names and has other bugs, so replace it with our own. This also allows us to calculate consistent inode values without hacks in the main Emacs code. */ @@ -1390,8 +1424,8 @@ } else if (!NILP (Vmswindows_get_true_file_attributes)) { - /* This is more accurate in terms of gettting the correct number - of links, but is quite slow (it is noticable when Emacs is + /* This is more accurate in terms of getting the correct number + of links, but is quite slow (it is noticeable when Emacs is making a list of file name completions). */ BY_HANDLE_FILE_INFORMATION info; @@ -1863,7 +1897,7 @@ if (tv->tv_sec == 0 && tv->tv_usec == 0) return 0; - /* Conver to ms and divide by denom */ + /* Convert to ms and divide by denom */ res = (tv->tv_sec * 1000 + (tv->tv_usec + 500) / 1000) / denom; /* Converge to minimum timer resolution */