Subversion Repositories SvarDOS

Rev

Rev 2058 | Rev 2060 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2058 Rev 2059
Line 604... Line 604...
604
 
604
 
605
  /* Use FindFirstFileEx when available (falls back to FindFirstFile).
605
  /* Use FindFirstFileEx when available (falls back to FindFirstFile).
606
   * Allows us to limit returned results to just directories
606
   * Allows us to limit returned results to just directories
607
   * if supported by underlying filesystem.
607
   * if supported by underlying filesystem.
608
   */
608
   */
609
  if (FindFirstFile(buffer, &findData) == NULL) {
609
  if (FindFirstFile(buffer, &findData) != 0) {
610
    showInvalidPath(path); /* Display error message */
610
    showInvalidPath(path); /* Display error message */
611
    return(-1);
611
    return(-1);
612
  }
612
  }
613
 
613
 
614
  /*  cycle through entries counting directories found until no more entries */
614
  /*  cycle through entries counting directories found until no more entries */
Line 618... Line 618...
618
         (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0 || dspAll) ) {
618
         (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0 || dspAll) ) {
619
      if (findData.name[0] != '.') { /* ignore '.' and '..' */
619
      if (findData.name[0] != '.') { /* ignore '.' and '..' */
620
        hasSubdirs++;      /* subdir of initial path found, so increment counter */
620
        hasSubdirs++;      /* subdir of initial path found, so increment counter */
621
      }
621
      }
622
    }
622
    }
623
  } while(FindNextFile(&findData) != 0);
623
  } while(FindNextFile(&findData) == 0);
624
 
624
 
625
  /* prevent resource leaks, close the handle. */
625
  /* prevent resource leaks, close the handle. */
626
  FindClose(&findData);
626
  FindClose(&findData);
627
 
627
 
628
  if (ddata != NULL)  // don't bother if user doesn't want them
628
  if (ddata != NULL)  // don't bother if user doesn't want them
Line 852... Line 852...
852
  unsigned long filesShown = 0;
852
  unsigned long filesShown = 0;
853
 
853
 
854
  /* get handle for files in current directory (using wildcard spec) */
854
  /* get handle for files in current directory (using wildcard spec) */
855
  strcpy(buffer, path);
855
  strcpy(buffer, path);
856
  strcat(buffer, "*");
856
  strcat(buffer, "*");
857
  if (FindFirstFile(buffer, &entry) == NULL) return(-1);
857
  if (FindFirstFile(buffer, &entry) != 0) return(-1);
858
 
858
 
859
  addPadding(padding, hasMoreSubdirs);
859
  addPadding(padding, hasMoreSubdirs);
860
 
860
 
861
  /* cycle through directory printing out files. */
861
  /* cycle through directory printing out files. */
862
  do
862
  do
Line 887... Line 887...
887
      /* print filename */
887
      /* print filename */
888
      pprintf("%s\n", entry.name);
888
      pprintf("%s\n", entry.name);
889
 
889
 
890
      filesShown++;
890
      filesShown++;
891
    }
891
    }
892
  } while(FindNextFile(&entry) != 0);
892
  } while(FindNextFile(&entry) == 0);
893
 
893
 
894
  if (filesShown)
894
  if (filesShown)
895
  {
895
  {
896
    pprintf("%s\n", padding);
896
    pprintf("%s\n", padding);
897
  }
897
  }
Line 919... Line 919...
919
    /* skip files & hidden or system directories */
919
    /* skip files & hidden or system directories */
920
    if ((((entry->attrib & FILE_A_SUBDIR) == 0) ||
920
    if ((((entry->attrib & FILE_A_SUBDIR) == 0) ||
921
         ((entry->attrib &
921
         ((entry->attrib &
922
          (FILE_A_HIDDEN | FILE_A_SYSTEM)) != 0  && !dspAll) ) ||
922
          (FILE_A_HIDDEN | FILE_A_SYSTEM)) != 0  && !dspAll) ) ||
923
        (entry->name[0] == '.')) {
923
        (entry->name[0] == '.')) {
924
      if (FindNextFile(entry) == 0) {
924
      if (FindNextFile(entry) != 0) {
925
        FindClose(entry);      // prevent resource leaks
925
        FindClose(entry);      // prevent resource leaks
926
        return(NULL); // no subdirs found
926
        return(NULL); // no subdirs found
927
      }
927
      }
928
    } else {
928
    } else {
929
      /* set display name */
929
      /* set display name */
Line 958... Line 958...
958
 
958
 
959
  /* get handle for files in current directory (using wildcard spec) */
959
  /* get handle for files in current directory (using wildcard spec) */
960
  strcpy(buffer, currentpath);
960
  strcpy(buffer, currentpath);
961
  strcat(buffer, "*");
961
  strcat(buffer, "*");
962
 
962
 
963
  if (FindFirstFile(buffer, dir) == NULL) {
963
  if (FindFirstFile(buffer, dir) != 0) {
964
    showInvalidPath(currentpath);
964
    showInvalidPath(currentpath);
965
    return(NULL);
965
    return(NULL);
966
  }
966
  }
967
 
967
 
968
  /* clear result path */
968
  /* clear result path */
Line 981... Line 981...
981
 */
981
 */
982
static int findNextSubdir(struct FFDTA *findnexthnd, char *subdir, char *dsubdir) {
982
static int findNextSubdir(struct FFDTA *findnexthnd, char *subdir, char *dsubdir) {
983
  /* clear result path */
983
  /* clear result path */
984
  subdir[0] = 0;
984
  subdir[0] = 0;
985
 
985
 
986
  if (FindNextFile(findnexthnd) == 0) return 1; // no subdirs found
986
  if (FindNextFile(findnexthnd) != 0) return(1); // no subdirs found
987
 
987
 
988
  if (cycleFindResults(findnexthnd, subdir, dsubdir) == NULL) {
988
  if (cycleFindResults(findnexthnd, subdir, dsubdir) == NULL) {
989
    return 1;
989
    return 1;
990
  }
990
  }
991
  return 0;
991
  return 0;