Subversion Repositories SvarDOS

Rev

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

Rev 2057 Rev 2058
Line 611... Line 611...
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 */
615
  do {
615
  do {
616
    if (((findData.ff_attr & FILE_A_DIR) != 0) &&
616
    if (((findData.attrib & FILE_A_SUBDIR) != 0) &&
617
        ((findData.ff_attr &
617
        ((findData.attrib &
618
         (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0 || dspAll) ) {
618
         (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0 || dspAll) ) {
619
      if (findData.ff_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
 
Line 802... Line 802...
802
  }
802
  }
803
 
803
 
804
  /* optional display data */
804
  /* optional display data */
805
  if (dspAttr)  /* attributes */
805
  if (dspAttr)  /* attributes */
806
    pprintf("[%c%c%c%c%c] ",
806
    pprintf("[%c%c%c%c%c] ",
807
      (ddata->attrib & FILE_A_DIR)?'D':' ',  /* keep this one? its always true */
807
      (ddata->attrib & FILE_A_SUBDIR)?'D':' ',  /* keep this one? its always true */
808
      (ddata->attrib & FILE_A_ARCH)?'A':' ',
808
      (ddata->attrib & FILE_A_ARCH)?'A':' ',
809
      (ddata->attrib & FILE_A_SYSTEM)?'S':' ',
809
      (ddata->attrib & FILE_A_SYSTEM)?'S':' ',
810
      (ddata->attrib & FILE_A_HIDDEN)?'H':' ',
810
      (ddata->attrib & FILE_A_HIDDEN)?'H':' ',
811
      (ddata->attrib & FILE_A_READONLY)?'R':' '
811
      (ddata->attrib & FILE_A_RDONLY)?'R':' '
812
    );
812
    );
813
 
813
 
814
  /* display directory name */
814
  /* display directory name */
815
  pprintf("%s\n", currentpath);
815
  pprintf("%s\n", currentpath);
816
}
816
}
Line 860... Line 860...
860
 
860
 
861
  /* cycle through directory printing out files. */
861
  /* cycle through directory printing out files. */
862
  do
862
  do
863
  {
863
  {
864
    /* print padding followed by filename */
864
    /* print padding followed by filename */
865
    if ( ((entry.ff_attr & FILE_A_DIR) == 0) &&
865
    if ( ((entry.attrib & FILE_A_SUBDIR) == 0) &&
866
         ( ((entry.ff_attr & (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0)  || dspAll) )
866
         ( ((entry.attrib & (FILE_A_HIDDEN | FILE_A_SYSTEM)) == 0)  || dspAll) )
867
    {
867
    {
868
      /* print lead padding */
868
      /* print lead padding */
869
      pprintf("%s", padding);
869
      pprintf("%s", padding);
870
 
870
 
871
      /* optional display data */
871
      /* optional display data */
872
      if (dspAttr)  /* file attributes */
872
      if (dspAttr)  /* file attributes */
873
        pprintf("[%c%c%c%c] ",
873
        pprintf("[%c%c%c%c] ",
874
          (entry.ff_attr & FILE_A_ARCH)?'A':' ',
874
          (entry.attrib & FILE_A_ARCH)?'A':' ',
875
          (entry.ff_attr & FILE_A_SYSTEM)?'S':' ',
875
          (entry.attrib & FILE_A_SYSTEM)?'S':' ',
876
          (entry.ff_attr & FILE_A_HIDDEN)?'H':' ',
876
          (entry.attrib & FILE_A_HIDDEN)?'H':' ',
877
          (entry.ff_attr & FILE_A_READONLY)?'R':' '
877
          (entry.attrib & FILE_A_RDONLY)?'R':' '
878
        );
878
        );
879
 
879
 
880
      if (dspSize) { /* file size */
880
      if (dspSize) { /* file size */
881
        if (entry.ff_fsize < 1048576ul)  /* if less than a MB, display in bytes */
881
        if (entry.size < 1048576ul)  /* if less than a MB, display in bytes */
882
          pprintf("%10lu ", entry.ff_fsize);
882
          pprintf("%10lu ", entry.size);
883
        else                               /* otherwise display in KB */
883
        else                               /* otherwise display in KB */
884
          pprintf("%8luKB ", entry.ff_fsize / 1024ul);
884
          pprintf("%8luKB ", entry.size / 1024ul);
885
      }
885
      }
886
 
886
 
887
      /* print filename */
887
      /* print filename */
888
      pprintf("%s\n", entry.ff_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
 
Line 915... Line 915...
915
 */
915
 */
916
static struct FFDTA *cycleFindResults(struct FFDTA *entry, char *subdir, char *dsubdir) {
916
static struct FFDTA *cycleFindResults(struct FFDTA *entry, char *subdir, char *dsubdir) {
917
  /* cycle through directory until 1st non . or .. directory is found. */
917
  /* cycle through directory until 1st non . or .. directory is found. */
918
  for (;;) {
918
  for (;;) {
919
    /* skip files & hidden or system directories */
919
    /* skip files & hidden or system directories */
920
    if ((((entry->ff_attr & FILE_A_DIR) == 0) ||
920
    if ((((entry->attrib & FILE_A_SUBDIR) == 0) ||
921
         ((entry->ff_attr &
921
         ((entry->attrib &
922
          (FILE_A_HIDDEN | FILE_A_SYSTEM)) != 0  && !dspAll) ) ||
922
          (FILE_A_HIDDEN | FILE_A_SYSTEM)) != 0  && !dspAll) ) ||
923
        (entry->ff_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 */
930
      strcpy(dsubdir, entry->ff_name);
930
      strcpy(dsubdir, entry->name);
931
 
931
 
932
      strcpy(subdir, entry->ff_name);
932
      strcpy(subdir, entry->name);
933
      strcat(subdir, "\\");
933
      strcat(subdir, "\\");
934
      return(entry);
934
      return(entry);
935
    }
935
    }
936
  }
936
  }
937
 
937