Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-ID: <36EA826D.7477DBA6@cityweb.de> Date: Sat, 13 Mar 1999 16:21:17 +0100 From: Corinna Vinschen X-Mailer: Mozilla 4.04 [en] (WinNT; I) MIME-Version: 1.0 To: Chris Faylor CC: cygwin-developers AT sourceware DOT cygnus DOT com Subject: Re: patch: telldir() and seekdir() References: <36E9955A DOT 19238FA5 AT cityweb DOT de> <19990312233927 DOT A7402 AT cygnus DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Chris Faylor wrote: > > Could you rewrite this patch and change the name from __find_first_called > to something more descriptive? > > I removed the dependency on this field a while ago so I think it is safe > to change it as long as you replace it with something that is 4 bytes > in size in the same location in the structure. > > cgf Ok, done. I have also changed dirent.h, to shift the prototypes to the #ifndef _POSIX_SOURCE section. telldir/seekdir are not POSIX, are they? ChangeLog: ========== Sat Mar 13 9:11:00 Corinna Vinschen * dir.cc: Changed usage of struct member __d_find_first_called to usage of __d_position. * dir.cc (telldir): Checks for __d_cookie now. * dir.cc (seekdir): Ditto. * newlib/libc/sys/cygwin/sys/dirent.h: Renamed `__d_find_first_called' to `__d_position'. Prototypes of `telldir()' and `seekdir()' are part of `#ifndef _POSIX_SOURCE' section now. Fri Mar 12 23:23:00 Corinna Vinschen * dir.cc: New functions `telldir()' and `seekdir()'. * cygwin.def: Ditto. * newlib/libc/sys/cygwin/sys/dirent.h: Additional prototypes for `telldir()' and `seekdir()'. ======= snip ======= --- dir.cc 1999/03/07 22:05:34 1.3 +++ dir.cc 1999/03/13 07:07:40 @@ -106,2 +106,3 @@ opendir (const char *dirname) dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE; + dir->__d_position = 0; dir->__d_dirhash = statbuf.st_ino; @@ -202,2 +203,3 @@ readdir (DIR * dir) + ++dir->__d_position; res = dir->__d_dirent; @@ -208,2 +210,25 @@ readdir (DIR * dir) +/* telldir */ +extern "C" +off_t +telldir (DIR * dir) +{ + if (dir->__d_cookie != __DIRENT_COOKIE) + return 0; + return dir->__d_position; +} + +/* seekdir */ +extern "C" +void +seekdir (DIR * dir, off_t loc) +{ + if (dir->__d_cookie != __DIRENT_COOKIE) + return; + rewinddir (dir); + while (loc > dir->__d_position) + if (! readdir (dir)) + break; +} + /* rewinddir: POSIX 5.1.2.1 */ @@ -221,2 +246,3 @@ rewinddir (DIR * dir) dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE; + dir->__d_position = 0; } --- cygwin.def.orig Sat Mar 13 00:25:27 1999 +++ cygwin.def Sat Mar 13 00:12:58 1999 @@ -495,2 +495,4 @@ random initstate +seekdir +_seekdir = seekdir setstate @@ -727,2 +729,4 @@ tcsetpgrp _tcsetpgrp = tcsetpgrp +telldir +_telldir = telldir tempnam --- newlib/libc/sys/cygwin/sys/dirent.h.orig Sat Mar 13 00:27:01 1999 +++ newlib/libc/sys/cygwin/sys/dirent.h Sat Mar 13 09:10:34 1999 @@ -24,3 +24,3 @@ typedef struct char *__d_dirname; /* directory name with trailing '*' */ - int __d_find_first_called; /* non-zero if FindFirstFile called */ + off_t __d_position; /* used by telldir/seekdir */ unsigned long __d_dirhash; /* hash of directory name for use by @@ -46,2 +46,5 @@ int closedir (DIR *); #ifndef _POSIX_SOURCE +off_t telldir (DIR *); +void seekdir (DIR *, off_t loc); + int scandir (const char *__dir,