@17140@
@13830@
@13245@
@13635@
@13440@
@13245@

Modified by Robert H”hne to be used for RHIDE.

@13245@
@13245@
@14024@

@14141@
@14345@
@14585@
@14634@
@14293@
@14366@
@14706@
@16849@

#include <errno.h>
@16679@
#ifdef __DJGPP__
@16695@
@15582@
@16751@
@16745@
#include <sys/stat.h>
#include <dirent.h>
#include <fnmatch.h>
#include <glob.h>

@19351@
          TScrollBar *aScrollBar) :
@07055@
@23372@
  numCols = 1;
@24151@

@19352@
@23372@
 if ( list() )
   destroy ( list() );
@24151@

void TFileList::focusItem( ccIndex item )
@23372@
  TSortedListBox::focusItem( item );
  message( owner, evBroadcast, cmFileFocused, list()->at(item) );
@24151@

@21613@
@23372@
@24151@

@21618@
@23372@
@24151@

uint32 TFileList::dataSize()
@23372@
@12873@
@24151@

@21982@
@23372@
  static TSearchRec sR;

  if ( (shiftState & 0x03) != 0 || *s == '.' )
    sR.attr = FA_DIREC;
@12774@
    sR.attr = 0;
  strcpy( sR.name, s );
  return &sR;
@24151@

void TFileList::getText( char *dest, ccIndex item, short maxChars )
@23372@
  TSearchRec *f = (TSearchRec *)(list()->at(item));

  strncpy( dest, f->name, maxChars );
  dest[maxChars] = '\0';
@08824@
  strcat( dest, DIRSEPARATOR_ );
@24151@

void TFileList::handleEvent( TEvent & event )
@23372@
  if ( event.what == evMouseDown && event.mouse.doubleClick )
@12966@
    event.what = evCommand;
    event.message.command = cmOK;
@09832@
@07622@
@12978@
@12774@
    TSortedListBox::handleEvent( event );
@24151@

@21616@
@23372@
  char path[PATH_MAX];
  strcpy( path, dir );
  strcat( path, wildCard );
  readDirectory( path );
@24151@

#ifdef __DJGPP__
typedef struct TSearchRec DirSearchRec;

struct __dj_DIR {
  int num_read;
  char *name;
  int flags;
  struct ffblk ff;
  struct dirent de;
@24833@

extern "C" size_t _file_time_stamp(unsigned);

@15193@

@21283@
@23372@
  /* SS: changed */

  void readFf_blk(char *filename, struct stat &s)
@12966@
    attr = FA_ARCH;
    if (S_ISDIR(s.st_mode)) attr |= FA_DIREC;
    strcpy(name, filename);
    size = s.st_size;
    time = s.st_mtime;
@12978@

@24833@

@15582@

#ifdef __DJGPP__ // this is really faster then the glob methode
@21615@
@23372@
  DIR *dir;
  struct dirent *de;
  DirSearchRec *p;
  TFileCollection *fileList = new TFileCollection( 5, 5 );
  char *wildcard = (char *)alloca(strlen(aWildCard)+1);
  strcpy(wildcard,aWildCard);
  char *slash = strrchr(wildcard,'/');
  char *path;
  if (slash)
@12966@
    *slash = 0;
    path = wildcard;
    if (strlen(path) == 2 && path[1] == ':')
@12247@
      path = (char *)alloca(4);
      strcpy(path,wildcard);
      strcat(path,"/");
@12539@
    slash++;
@12978@
@12774@
@12966@
    slash = wildcard;
    path = ".";
@12978@
  dir = opendir(path);
  if (dir) while ((de = readdir(dir)))
@12966@
    struct ffblk &ff = dir->ff;
    if (!(ff.ff_attrib & FA_DIREC) && fnmatch(slash,de->d_name,0)) continue;
    if (strcmp(de->d_name,".") == 0) continue;
    p = new DirSearchRec;
    strcpy(p->name,de->d_name);
    p->attr = ff.ff_attrib;
    p->size = ff.ff_fsize;
    p->time = ((unsigned long)(ff.ff_fdate)) << 16 | (unsigned short)ff.ff_ftime;
    p->time = _file_time_stamp(p->time);
    fileList->insert(p);
@12978@
  if (dir) closedir(dir);
  newList(fileList);
  if (list()->getCount() > 0)
    message( owner, evBroadcast, cmFileFocused, list()->at(0) );
@12774@
@12966@
    static DirSearchRec noFile;
    message( owner, evBroadcast, cmFileFocused, &noFile );
@12978@
@24151@

@15193@

@21615@
@23372@
  /* SS: changed */

  DIR *dp;
  DirSearchRec *p;
  char dir[PATH_MAX];
  char file[PATH_MAX];
  char path[PATH_MAX];
  char *np;
  dirent *de;
  glob_t gl;
  struct stat s;

  strcpy( path, aWildCard );
  if (!isWild(path)) strcat(path, "*");
  fexpand( path );
  expandPath(path, dir, file);
  TFileCollection *fileList = new TFileCollection( 5, 5 );

  /* find all filenames that match our wildcards */

  /*
   * The use of 'glob' function was proposed by:
   * Rainer Keuchel <r_keuchel@smaug.netwave.de>
   * Date: 18 Jan 1997 22:52:12 +0000
   */
#ifdef __linux__
#define __gl_options GLOB_PERIOD
@15193@
#define __gl_options 0
@15582@
  if (glob(path, __gl_options, NULL, &gl) == 0)
@12966@
    for (int i = 0; i < (int)gl.gl_pathc; i++)
@12247@
      /* is this a regular file ? */
  
      if (stat(gl.gl_pathv[i], &s) == 0 && S_ISREG(s.st_mode))
@06184@
        if ((p = new DirSearchRec) == NULL) break;
  
        /* strip directory part */
  
        if ((np = strrchr(gl.gl_pathv[i], '/')) != NULL) np++;
        else np = gl.gl_pathv[i];
        p->readFf_blk(np, s);
        fileList->insert( p );
@06196@
@12539@
    globfree(&gl);
@12978@
  /* now read all directory names */

  sprintf(path, "%s.", dir);
  if ((dp = opendir(path)) != NULL)
@12966@
    while ((de = readdir(dp)) != NULL)
@12247@
      /* we don't want these directories */

      if (strcmp(de->d_name, ".") == 0 ||
        strcmp(de->d_name, "..") == 0) continue;

      /* is it a directory ? */

      sprintf(path, "%s%s", dir, de->d_name);
      if (stat(path, &s) == 0 && S_ISDIR(s.st_mode))
@06184@
        if ((p = new DirSearchRec) == NULL) break;
        p->readFf_blk(de->d_name, s);
        fileList->insert( p );
@06196@
@12539@
    closedir(dp);
@12978@

  if ( strlen( dir ) > 1 )
@12966@
    p = new DirSearchRec;
    if ( p != 0 )
@12247@
      sprintf(path, "%s..", dir);
      if (stat(path, &s) == 0)
@06184@
        p->readFf_blk("..", s);
@06196@
@06123@
@06184@
        strcpy( p->name, ".." );
        p->size = 0;
        p->time = 0x210000uL;
        p->attr = FA_DIREC;
@06196@
      fileList->insert( p );
@12539@
@12978@
#if 0 // I think this will never hapen
  if ( p == 0 )
    messageBox( tooManyFiles, mfOKButton | mfWarning );
@15582@
  newList(fileList);
  if ( list()->getCount() > 0 )
    message( owner, evBroadcast, cmFileFocused, list()->at(0) );
@12774@
@12966@
    static DirSearchRec noFile;
    message( owner, evBroadcast, cmFileFocused, &noFile );
@12978@
@24151@

@15582@

#if !defined( NO_STREAM )
@19564@
@23372@
@10128@
@24151@
#endif // NO_STREAM

