2008/3/21, Danny Backx <[EMAIL PROTECTED]>:
>  - extend our dirent.c (and submit the extensions), no change to Kaffe
>
>         Danny

I extended dirent.c with the methods telldir() and seekdir(). A patch
is attached. My implementation is very simple, i'm not sure that it is
completely correct but for a simple example i compiled for Cygwin/x86
and Cygwin/ARM it gives the same results.

The Arm version has been tested on a Pocket PC Emulator

The example is :

--- start telldir.c ---
#include <dirent.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>

int main(){

  DIR *dir = opendir(".");
  if (dir == NULL)
    {
      printf("Err: %s\n", strerror(errno)) ;
    }

        
  else
    {

        long int currLoc;
        struct dirent *dirEntry;
        int i = 0;
        for (i = 0; i < 7; i++) {
        
      currLoc= telldir(dir);

          printf("Seekdir to %d \n", currLoc);
      seekdir(dir, currLoc);
        
          dirEntry = readdir(dir);      
          printf("Readdir: %s\n", dirEntry->d_name);
          }

    }
  }

-- end telldir.c --

i created a directory called telldir, and into it i created the dir
"a,b,c,d,e,f"

on both Cygwin/X86 and Cygwin/ARM (windows mobile) the output is:

--- start output ---

[EMAIL PROTECTED] /cygdrive/c/Code/telldir
$ ./telldir-x86.exe
Seekdir to 0
Readdir: .
Seekdir to 1
Readdir: ..
Seekdir to 2
Readdir: a
Seekdir to 3
Readdir: b
Seekdir to 4
Readdir: c
Seekdir to 5
Readdir: d
Seekdir to 6
Readdir: e

--- end output ---

i'm neither an expert in systems programming nor in CeGCC, i tried to
follow the style of the other functions in dirent.c . Feel free to
comment on the code, it can be certainly improved :)

Mario Latronico

Attachment: dirent.diff
Description: Binary data

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to