www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/01/12/21:30:15

From: pete <pete AT p-smith DOT co DOT uk>
Subject: portability problems
Newsgroups: comp.os.msdos.djgpp
Lines: 89
User-Agent: KNode/0.7.1
MIME-Version: 1.0
Message-ID: <PrpU9.626$iX6.5058@newsfep4-win.server.ntli.net>
Date: Tue, 14 Jan 2003 02:24:46 +0000
NNTP-Posting-Host: 80.6.240.12
X-Complaints-To: abuse AT ntlworld DOT com
X-Trace: newsfep4-win.server.ntli.net 1042424687 80.6.240.12 (Mon, 13 Jan 2003 02:24:47 GMT)
NNTP-Posting-Date: Mon, 13 Jan 2003 02:24:47 GMT
Organization: ntl Cablemodem News Service
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

I have a small program which i'm attempting to port from unix to dos. I 
installed Windows on a spare machine along with djgpp (2.03), and luckily 
it didn't take much editing to get it running.

I sent it to a couple of friends (running Win 2000 also), but it just hangs 
for them, apparently doing nothing. If anyone can shed any light it would 
be much appreciated.

At the moment all the program does is list all files in C:\, decending 
through each directory in turn. I've included it below :

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/dir.h>

struct direct *DirEntryPtr;
DIR *DirPtr;
struct stat Stat;
char Path[500];

char *a[200000];
int top = -1;
int isempty() { return top == -1; }
int Tmp;

void push(char *c) { a[++top] = c; }
char *pop() { return a[top--];}
void get_dir(char *dir_name);


int main(void)
{
  puts("Started ....");
  get_dir("\\");

  while(top > -1) {
    char *top = pop();
    get_dir(top);
    free(top);
 }

}

 void get_dir(char *dir_name)
 {

 DirPtr = opendir(dir_name);
   while (1)  {

      DirEntryPtr = readdir(DirPtr);
      if (DirEntryPtr == 0) break;

      if (strcmp(DirEntryPtr->d_name,".") != 0 &&
          strcmp(DirEntryPtr->d_name,"..") != 0)  {
             Path[0] = 0;
             strcat(Path,dir_name);
             strcat(Path,"\\");
             strcat(Path,DirEntryPtr->d_name);
              Tmp = stat(Path,&Stat);

             if (S_ISDIR(Stat.st_mode)) {

              char *str = malloc(strlen(Path) + 1);
               strcpy(str, Path);
               push(str);

            }
        printf("  %s\n",DirEntryPtr->d_name);

      }
   }
}


I'm compiling it with :

        gcc -o whatever whatever.c

Then sending the whatever.exe off to friends for testing- I assume it will 
be standalone ?

Thanks

pete

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019