On Aug 26, 3:09 pm, Conrad Lawes <[email protected]> wrote:
> Dos-Man,
>
> I don't understand why you are having so much difficulty.   Simply install
> the *Linux Midnight Commander* - sudo apt-get install mc.  Midnight
> Commander works almost identical to the old DOS Norton Commander.  Given
> your DOS heritage, this should be a breeze for you..
>


Yes, it's installed. Didn't quite the fit the bill in this case, but
perhaps I can find other uses for it.  At any rate, I'm giving up on
this. My C program can launch dialog and create the listing, but it
can't check the return value.  I have to admit defeat in this case.
Oh, well. I have other windows and dos apps that I am going to try to
recreate, so, next!

Here's the final source code for the C program in case anyone ever
wants to attempt this.

#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>

void newstrcat(char * dest, char * source);
void printdir(char * dir);
void inttostr(char * x);

char curdir[266] = "";
char cmdline[32000] = "dialog --menu \"Choose folder\" 20 30 14";
int counter = 0;

int main()
{
  int result;
  getcwd(curdir, 265);
  printdir(curdir);
  system(cmdline);
}

void printdir(char * dir)
{
  DIR * dp;
  char num[20] = "";
  char twobytes[2]="";

  struct dirent * entry;
  struct stat statbuf;

  if((dp=opendir(dir)) == NULL)
  {
    fprintf(stderr, "Failed.\n");
    return;
  }

  while((entry=readdir(dp))!= NULL)
  {
    lstat(entry->d_name, &statbuf);
    if(S_ISDIR(statbuf.st_mode))
    {
      counter++;
      newstrcat(cmdline," ");
      sprintf(num, "%i ", counter);
      newstrcat(cmdline,num);
      strcpy(num,"");
      newstrcat(cmdline, entry->d_name);
    }
   }
   closedir(dp);
} // end of printdir()


void newstrcat(char * dest, char * source)
{
  if ((strlen(dest) + strlen(source)) >= 32000)
  {
    fprintf(stderr, "Failed.\n");
    exit(0);
  }
  else
  {
    strcat(dest,source);
  }
}



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Linux Users Group.
To post a message, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit our group at 
http://groups.google.com/group/linuxusersgroup
-~----------~----~----~----~------~----~------~--~---

Reply via email to