Subversion Repositories SvarDOS

Rev

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

Rev 2039 Rev 2040
Line 690... Line 690...
690
 * On error (invalid path) displays message and returns -1L.
690
 * On error (invalid path) displays message and returns -1L.
691
 * Stores additional directory data in ddata if non-NULL
691
 * Stores additional directory data in ddata if non-NULL
692
 * and path is valid.
692
 * and path is valid.
693
 */
693
 */
694
static long hasSubdirectories(char *path, DIRDATA *ddata) {
694
static long hasSubdirectories(char *path, DIRDATA *ddata) {
695
  static WIN32_FIND_DATA findData;
695
  static struct WIN32_FIND_DATA findData;
696
  HANDLE hnd;
696
  HANDLE hnd;
697
  static char buffer[MAXBUF];
697
  static char buffer[MAXBUF];
698
  int hasSubdirs = 0;
698
  int hasSubdirs = 0;
699
 
699
 
700
  /* get the handle to start with (using wildcard spec) */
700
  /* get the handle to start with (using wildcard spec) */
Line 703... Line 703...
703
 
703
 
704
  /* Use FindFirstFileEx when available (falls back to FindFirstFile).
704
  /* Use FindFirstFileEx when available (falls back to FindFirstFile).
705
   * Allows us to limit returned results to just directories
705
   * Allows us to limit returned results to just directories
706
   * if supported by underlying filesystem.
706
   * if supported by underlying filesystem.
707
   */
707
   */
708
  hnd = FindFirstFileA(buffer, &findData);
708
  hnd = FindFirstFile(buffer, &findData);
709
  if (hnd == INVALID_HANDLE_VALUE)
709
  if (hnd == INVALID_HANDLE_VALUE)
710
  {
710
  {
711
    showInvalidPath(path); /* Display error message */
711
    showInvalidPath(path); /* Display error message */
712
    return -1L;
712
    return -1L;
713
  }
713
  }
Line 949... Line 949...
949
 *          0 if no files, but no errors either,
949
 *          0 if no files, but no errors either,
950
 *      or  1 if files displayed, no errors.
950
 *      or  1 if files displayed, no errors.
951
 */
951
 */
952
static int displayFiles(char *path, char *padding, int hasMoreSubdirs, DIRDATA *ddata) {
952
static int displayFiles(char *path, char *padding, int hasMoreSubdirs, DIRDATA *ddata) {
953
  static char buffer[MAXBUF];
953
  static char buffer[MAXBUF];
954
  WIN32_FIND_DATA entry; /* current directory entry info    */
954
  struct WIN32_FIND_DATA entry; /* current directory entry info    */
955
  HANDLE dir;         /* Current directory entry working with      */
955
  HANDLE dir;         /* Current directory entry working with      */
956
  unsigned long filesShown = 0;
956
  unsigned long filesShown = 0;
957
 
957
 
958
  /* get handle for files in current directory (using wildcard spec) */
958
  /* get handle for files in current directory (using wildcard spec) */
959
  strcpy(buffer, path);
959
  strcpy(buffer, path);
Line 1030... Line 1030...
1030
 * was found, and if so copies appropriate data into subdir and dsubdir.
1030
 * was found, and if so copies appropriate data into subdir and dsubdir.
1031
 * It will repeat until a valid subdirectory is found or no more
1031
 * It will repeat until a valid subdirectory is found or no more
1032
 * are found, at which point it closes the FindFile search handle and
1032
 * are found, at which point it closes the FindFile search handle and
1033
 * return INVALID_HANDLE_VALUE.  If successful, returns FindFile handle.
1033
 * return INVALID_HANDLE_VALUE.  If successful, returns FindFile handle.
1034
 */
1034
 */
1035
static HANDLE cycleFindResults(HANDLE findnexthnd, WIN32_FIND_DATAA *entry, char *subdir, char *dsubdir) {
1035
static HANDLE cycleFindResults(HANDLE findnexthnd, struct WIN32_FIND_DATA *entry, char *subdir, char *dsubdir) {
1036
  /* cycle through directory until 1st non . or .. directory is found. */
1036
  /* cycle through directory until 1st non . or .. directory is found. */
1037
  do
1037
  do
1038
  {
1038
  {
1039
    /* skip files & hidden or system directories */
1039
    /* skip files & hidden or system directories */
1040
    if ((((entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) ||
1040
    if ((((entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) ||
Line 1066... Line 1066...
1066
  return findnexthnd;
1066
  return findnexthnd;
1067
}
1067
}
1068
 
1068
 
1069
 
1069
 
1070
/* FindFile buffer used by findFirstSubdir and findNextSubdir only */
1070
/* FindFile buffer used by findFirstSubdir and findNextSubdir only */
1071
static WIN32_FIND_DATAA findSubdir_entry; /* current directory entry info    */
1071
static struct WIN32_FIND_DATA findSubdir_entry; /* current directory entry info    */
1072
 
1072
 
1073
/**
1073
/**
1074
 * Given the current path, find the 1st subdirectory.
1074
 * Given the current path, find the 1st subdirectory.
1075
 * The subdirectory found is stored in subdir.
1075
 * The subdirectory found is stored in subdir.
1076
 * subdir is cleared on error or no subdirectories.
1076
 * subdir is cleared on error or no subdirectories.
Line 1086... Line 1086...
1086
 
1086
 
1087
  /* get handle for files in current directory (using wildcard spec) */
1087
  /* get handle for files in current directory (using wildcard spec) */
1088
  strcpy(buffer, currentpath);
1088
  strcpy(buffer, currentpath);
1089
  strcat(buffer, "*");
1089
  strcat(buffer, "*");
1090
 
1090
 
1091
  dir = FindFirstFileA(buffer, &findSubdir_entry);
1091
  dir = FindFirstFile(buffer, &findSubdir_entry);
1092
  if (dir == INVALID_HANDLE_VALUE)
1092
  if (dir == INVALID_HANDLE_VALUE)
1093
  {
1093
  {
1094
    showInvalidPath(currentpath);
1094
    showInvalidPath(currentpath);
1095
    return INVALID_HANDLE_VALUE;
1095
    return INVALID_HANDLE_VALUE;
1096
  }
1096
  }