Subversion Repositories SvarDOS

Rev

Rev 2029 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2029 Rev 2030
Line 221... Line 221...
221
   any newlines (but this should not occur in tree).
221
   any newlines (but this should not occur in tree).
222
*/
222
*/
223
#include <stdarg.h>  /* va_list, va_start, va_end */
223
#include <stdarg.h>  /* va_list, va_start, va_end */
224
int pprintf(const char *msg, ...)
224
int pprintf(const char *msg, ...)
225
{
225
{
226
  static int lineCnt = rows;
226
  static int lineCnt = -1;
227
  static int lineCol = 0;
227
  static int lineCol = 0;
228
 
-
 
229
  va_list argptr;
228
  va_list argptr;
230
  int cnt;
229
  int cnt;
231
  char buffer[MAXBUF];
230
  char buffer[MAXBUF];
232
 
231
 
-
 
232
  if (lineCnt == -1) lineCnt = rows;
-
 
233
 
233
  va_start(argptr, msg);
234
  va_start(argptr, msg);
234
  cnt = vsprintf(buffer, msg, argptr);
235
  cnt = vsprintf(buffer, msg, argptr);
235
  va_end(argptr);
236
  va_end(argptr);
236
 
237
 
237
  if (pause == PAUSE)
238
  if (pause == PAUSE)
238
  {
239
  {
239
    char * l = buffer;
240
    char *l = buffer;
-
 
241
    char *t;
240
    /* cycle through counting newlines and lines > cols */
242
    /* cycle through counting newlines and lines > cols */
241
    for (char *t = strchr(l, '\n'); t != NULL; t = strchr(l, '\n'))
243
    for (t = strchr(l, '\n'); t != NULL; t = strchr(l, '\n'))
242
    {
244
    {
-
 
245
      char c;
243
      t++;             /* point to character after newline */
246
      t++;             /* point to character after newline */
244
      char c = *t;     /* store current value */
247
      c = *t;          /* store current value */
245
      *t = '\0';       /* mark as end of string */
248
      *t = '\0';       /* mark as end of string */
246
 
249
 
247
      /* print all but last line of a string that wraps across rows */
250
      /* print all but last line of a string that wraps across rows */
248
      /* adjusting for partial lines printed without the newlines   */
251
      /* adjusting for partial lines printed without the newlines   */
249
      while (strlen(l)+lineCol > cols)
252
      while (strlen(l)+lineCol > cols)
Line 538... Line 541...
538
          showInvalidUsage(argv[i]);
541
          showInvalidUsage(argv[i]);
539
      }
542
      }
540
    }
543
    }
541
    else /* should be a drive/path */
544
    else /* should be a drive/path */
542
    {
545
    {
543
      if (strlen(argv[i]) > MAXBUF)
546
      char *dptr = path;
-
 
547
      char *cptr;
-
 
548
 
544
        showBufferOverrun(MAXBUF);
549
      if (strlen(argv[i]) > MAXBUF) showBufferOverrun(MAXBUF);
545
 
550
 
546
      /* copy path over, making all caps to look prettier, can be strcpy */
551
      /* copy path over, making all caps to look prettier, can be strcpy */
547
      char *dptr = path;
-
 
548
      for (char *cptr = argv[i]; *cptr != '\0'; cptr++, dptr++)
552
      for (cptr = argv[i]; *cptr != '\0'; cptr++, dptr++) {
549
        *dptr = toupper(*cptr);
553
        *dptr = toupper(*cptr);
-
 
554
      }
550
      *dptr = '\0';
555
      *dptr = '\0';
551
 
556
 
552
      /* Converts given path to full path */
557
      /* Converts given path to full path */
553
      getProperPath(path);
558
      getProperPath(path);
554
    }
559
    }
Line 604... Line 609...
604
#define STDCALL __stdcall
609
#define STDCALL __stdcall
605
#endif
610
#endif
606
 
611
 
607
typedef HANDLE ( STDCALL * fFindFirstFileExA)(const char *, FINDEX_INFO_LEVELS, void *, FINDEX_SEARCH_OPS, void *, DWORD);
612
typedef HANDLE ( STDCALL * fFindFirstFileExA)(const char *, FINDEX_INFO_LEVELS, void *, FINDEX_SEARCH_OPS, void *, DWORD);
608
 
613
 
609
/* FindFirstFileExA is only available on NT systems, so on Win9x & DOS use plain FindFirstFile */
-
 
610
HANDLE STDCALL myFindFirstFileExA(const char *fname, FINDEX_INFO_LEVELS, void * ffd, FINDEX_SEARCH_OPS, void *, DWORD)
-
 
611
{
-
 
612
  return FindFirstFileA(fname, (WIN32_FIND_DATAA *)ffd);
-
 
613
}
-
 
614
 
-
 
615
fFindFirstFileExA pFindFirstFileExA = &myFindFirstFileExA;
-
 
616
 
614
 
617
/**
615
/**
618
 * Stores directory information obtained from FindFirst/Next that
616
 * Stores directory information obtained from FindFirst/Next that
619
 * we may wish to make use of when displaying directory entry.
617
 * we may wish to make use of when displaying directory entry.
620
 * e.g. attribute, dates, etc.
618
 * e.g. attribute, dates, etc.
Line 647... Line 645...
647
 * Path must end in slash \ or /
645
 * Path must end in slash \ or /
648
 * On error (invalid path) displays message and returns -1L.
646
 * On error (invalid path) displays message and returns -1L.
649
 * Stores additional directory data in ddata if non-NULL
647
 * Stores additional directory data in ddata if non-NULL
650
 * and path is valid.
648
 * and path is valid.
651
 */
649
 */
652
long hasSubdirectories(char *path, DIRDATA *ddata = NULL)
650
long hasSubdirectories(char *path, DIRDATA *ddata)
653
{
651
{
654
  static WIN32_FIND_DATA findData;
652
  static WIN32_FIND_DATA findData;
655
  HANDLE hnd;
653
  HANDLE hnd;
656
  static char buffer[MAXBUF];
654
  static char buffer[MAXBUF];
657
  int hasSubdirs = 0;
655
  int hasSubdirs = 0;
Line 662... Line 660...
662
 
660
 
663
  /* Use FindFirstFileEx when available (falls back to FindFirstFile).
661
  /* Use FindFirstFileEx when available (falls back to FindFirstFile).
664
   * Allows us to limit returned results to just directories
662
   * Allows us to limit returned results to just directories
665
   * if supported by underlying filesystem.
663
   * if supported by underlying filesystem.
666
   */
664
   */
667
  hnd = pFindFirstFileExA(buffer, FindExInfoStandard, &findData, FindExSearchLimitToDirectories, NULL, 0);
665
  hnd = FindFirstFileA(buffer, &findData);
668
  if (hnd == INVALID_HANDLE_VALUE)
666
  if (hnd == INVALID_HANDLE_VALUE)
669
  {
667
  {
670
    showInvalidPath(path); /* Display error message */
668
    showInvalidPath(path); /* Display error message */
671
    return -1L;
669
    return -1L;
672
  }
670
  }
Line 1064... Line 1062...
1064
 
1062
 
1065
  /* get handle for files in current directory (using wildcard spec) */
1063
  /* get handle for files in current directory (using wildcard spec) */
1066
  strcpy(buffer, currentpath);
1064
  strcpy(buffer, currentpath);
1067
  strcat(buffer, "*");
1065
  strcat(buffer, "*");
1068
 
1066
 
1069
  dir = pFindFirstFileExA(buffer, FindExInfoStandard, &findSubdir_entry.ad, FindExSearchLimitToDirectories, NULL, 0);
1067
  dir = FindFirstFileA(buffer, &findSubdir_entry.ad);
1070
 
-
 
1071
  if (dir == INVALID_HANDLE_VALUE)
1068
  if (dir == INVALID_HANDLE_VALUE)
1072
  {
1069
  {
1073
    showInvalidPath(currentpath);
1070
    showInvalidPath(currentpath);
1074
    return INVALID_HANDLE_VALUE;
1071
    return INVALID_HANDLE_VALUE;
1075
  }
1072
  }