readdir.inc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. { Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {
  17. * Structures and types used to implement opendir/readdir/closedir
  18. * on Windows 95/NT.
  19. }
  20. {$ifdef WINDOWS}
  21. {#include <io.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <sys/types.h>
  25. #ifndef API_EXPORT
  26. # define API_EXPORT(type) __declspec(dllexport) type __stdcall
  27. #endif}
  28. { struct dirent - same as Unix }
  29. const
  30. _MAX_FNAME = 256;
  31. type
  32. dirent = record
  33. d_ino: clong; { inode (always 1 in WIN32) }
  34. d_off: off_t; { offset to this dirent }
  35. d_reclen: cushort; { length of d_name }
  36. d_name: array[0.._MAX_FNAME] of Char; { filename (null terminated) }
  37. end;
  38. { typedef DIR - not the same as Unix }
  39. DIR = record
  40. handle: clong; { _findfirst/_findnext handle }
  41. offset: cshort; { offset into directory }
  42. finished: cshort; { 1 if there are not more files }
  43. // struct _finddata_t fileinfo; { from _findfirst/_findnext }
  44. fileinfo: Pointer; { from _findfirst/_findnext }
  45. dir: PChar; { the dir we are reading }
  46. dent: dirent; { the dirent to return }
  47. end;
  48. PDIR = ^DIR;
  49. { Function prototypes }
  50. {API_EXPORT(DIR *) opendir(const char *);
  51. API_EXPORT(struct dirent *) readdir(DIR *);
  52. API_EXPORT(int) closedir(DIR *);}
  53. va_list = Pointer;
  54. {
  55. * Simplified declarations for other platforms
  56. }
  57. {$else}
  58. PDIR = Pointer;
  59. va_list = Pointer;
  60. {$endif} { WINDOWS }