/* -*-C-*-
-$Id: ntfs.c,v 1.17 1997/10/26 09:15:04 cph Exp $
+$Id: ntfs.c,v 1.18 1997/10/26 09:32:53 cph Exp $
Copyright (c) 1992-97 Massachusetts Institute of Technology
#include <string.h>
#include "outf.h"
\f
-/* Incredible kludge. Some files (e.g. \pagefile.sys) cannot be
- accessed by the usual technique, but much of the same information
- is available by reading the directory. Additionally,
- GetFileInformationByHandle returns incorrect time-stamp information
- for some files (specifically, Samba files), but FindFirstFile
- returns correct information. Go figure. More M$ bullshit. */
+static HANDLE create_file_for_info (const char *);
+
+static enum get_file_info_result get_file_info_from_dir
+ (const char *, BY_HANDLE_FILE_INFORMATION *);
+
enum get_file_info_result
NT_get_file_info (const char * namestring, BY_HANDLE_FILE_INFORMATION * info)
+{
+ HANDLE hfile = (create_file_for_info (namestring));
+ if (hfile == INVALID_HANDLE_VALUE)
+ {
+ DWORD code = (GetLastError ());
+ if (STAT_NOT_FOUND_P (code))
+ return (gfi_not_found);
+ if (STAT_NOT_ACCESSIBLE_P (code))
+ return (get_file_info_from_dir (namestring, info));
+ NT_error_api_call (code, apicall_CreateFile);
+ }
+ if (!GetFileInformationByHandle (hfile, info))
+ {
+ DWORD code = (GetLastError ());
+ (void) CloseHandle (hfile);
+ if (STAT_NOT_FOUND_P (code))
+ return (gfi_not_found);
+ if (STAT_NOT_ACCESSIBLE_P (code))
+ return (gfi_not_accessible);
+ NT_error_api_call (code, apicall_GetFileInformationByHandle);
+ }
+ STD_BOOL_API_CALL (CloseHandle, (hfile));
+ return (gfi_ok);
+}
+
+/* Incredible kludge. Some files (e.g. \pagefile.sys) cannot be
+ accessed by the usual technique, but much of the same information
+ is available by reading the directory. More M$ bullshit. */
+static enum get_file_info_result
+get_file_info_from_dir (const char * namestring,
+ BY_HANDLE_FILE_INFORMATION * info)
{
char nscopy [MAX_PATH];
WIN32_FIND_DATA fi;
return (gfi_ok);
}
+static HANDLE
+create_file_for_info (const char * namestring)
+{
+ return
+ (CreateFile (namestring,
+ 0,
+ (FILE_SHARE_READ | FILE_SHARE_WRITE),
+ 0,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS,
+ NULL));
+}
+\f
enum file_existence
DEFUN (OS_file_existence_test, (name), CONST char * name)
{