Remove check to verify that the first entry of a directory is a
authorGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Fri, 30 Jul 1993 06:23:56 +0000 (06:23 +0000)
committerGuillermo J. Rozas <edu/mit/csail/zurich/gjr>
Fri, 30 Jul 1993 06:23:56 +0000 (06:23 +0000)
subdirectory.  Root directories on FAT volumes do not have `.' and
`..' entries, so this is not guaranteed to be the case.

v7/src/microcode/ntfs.c

index c6178a2f350bf029131abb715a8d381aea1688c2..26c0892777198e0e133eabba57f2f7b581783faf 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: ntfs.c,v 1.4 1993/07/21 06:02:28 gjr Exp $
+$Id: ntfs.c,v 1.5 1993/07/30 06:23:56 gjr Exp $
 
 Copyright (c) 1992-1993 Massachusetts Institute of Technology
 
@@ -148,10 +148,15 @@ DEFUN (OS_directory_delete, (name), CONST char * name)
   STD_VOID_SYSTEM_CALL (syscall_rmdir, (RemoveDirectory (name)));
 }
 \f
-/* This is such that directory open does not return the first file */
 #define DIR_UNALLOCATED (-1L)
+
+/* This is used to cache the result of _findfirst because directory open
+   does not return the first file.
+ */
+
 typedef struct DIR_struct
-{ struct _finddata_t entry;
+{
+  struct _finddata_t entry;
   long handle;         /* may be DIR_UNALLOCATED */
   char pathname[256];
 } DIR;
@@ -244,13 +249,17 @@ DEFUN (OS_directory_open, (name), CONST char * name)
   if (dir == 0)
     error_system_call (ENOMEM, syscall_malloc);
 
-  if (dos_pathname_as_filename(name, filename))
-    sprintf(searchname, "%s*.*", filename);
+  if (dos_pathname_as_filename (name, filename))
+    sprintf (searchname, "%s*.*", filename);
   else
-    sprintf(searchname, "%s\\*.*", filename);
-
-  dir->handle = _findfirst(searchname, &(dir->entry));
-  if (dir->handle == DIR_UNALLOCATED  || (dir->entry.attrib & _A_SUBDIR)== 0)
+    sprintf (searchname, "%s\\*.*", filename);
+
+  dir->handle = _findfirst (searchname, &(dir->entry));
+  if ((dir->handle == DIR_UNALLOCATED)
+#if 0
+      || ((dir->entry.attrib & _A_SUBDIR) == 0)
+#endif
+      )
     error_system_call (errno, syscall_opendir);
 
   return (allocate_directory_pointer (dir));
@@ -264,9 +273,8 @@ DEFUN (OS_directory_read, (index), unsigned int index)
     return 0;
 
   Get_Directory_Entry_Name(dir->entry, dir->pathname);
-  if ( _findnext(dir->handle, &(dir->entry))) {
-       dir->handle = DIR_UNALLOCATED;
-  }
+  if (_findnext (dir->handle, &(dir->entry)))
+    dir->handle = DIR_UNALLOCATED;
   return (dir -> pathname);
 }
 
@@ -283,12 +291,11 @@ void
 DEFUN (OS_directory_close, (index), unsigned int index)
 { DIR * dir = REFERENCE_DIRECTORY (index);
 
-  if (dir) {
+  if (dir)
+  {
     if (dir->handle != DIR_UNALLOCATED)
-      _findclose(dir->handle);
+      _findclose (dir->handle);
     free(dir);
   }
   DEALLOCATE_DIRECTORY (index);
 }
-
-