delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/03/15/14:32:09

From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: dir problems
Date: Sat, 15 Mar 2003 17:53:24 +0000
Lines: 38
Message-ID: <3E736894.47A6A34@phekda.freeserve.co.uk>
References: <Xns933F32422435Dehowardtcanadacom AT 193 DOT 252 DOT 19 DOT 141>
NNTP-Posting-Host: 62.136.12.118
Mime-Version: 1.0
X-Trace: news8.svr.pol.co.uk 1047753050 12357 62.136.12.118 (15 Mar 2003 18:30:50 GMT)
NNTP-Posting-Date: 15 Mar 2003 18:30:50 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586)
X-Accept-Language: de,fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello.

costa wrote:
> Is there a way to duplicate a value given back by readdir ?
> I want to store them in a struct  wich is :
> 
> typedef struct FileList {
> 
>         char *FileName;
>         char *FileType;
>         int pos;
>         struct FileList *pNext;
> 
> }FileList;
> 
> any pointers would be helpfull.

info libc alpha readdir

What do FileType and pos represent?

Untested code to copy stuff from a DIR to a FileList:

int
dir2filelist (FileList *filelist, const DIR *dir)
{
    /* NB: Assumes filelist needs initialisation. */
    memset(filelist, 0, sizeof(*filelist));
    filelist->FileName = malloc(dir->d_namelen + 1);
    strcpy(filelist->FileName, dir->d_name);
    ...
    return(filelist);
}

Regards,

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


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