PageRenderTime 52ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/strigi-0.7.7/libstreamanalyzer/lib/stgdirent.h

#
C Header | 111 lines | 47 code | 20 blank | 44 comment | 6 complexity | 4a69c96588b6595a3827d4724d4bae1a MD5 | raw file
Possible License(s): LGPL-2.0
  1. /*------------------------------------------------------------------------------
  2. * Copyright (C) 2003-2006 Matt J. Weinstein <weinstein@macalester.edu>
  3. *
  4. * Distributable under the terms of either the Apache License (Version 2.0) or
  5. * the GNU Lesser General Public License, as specified in the COPYING file.
  6. ------------------------------------------------------------------------------*/
  7. #ifndef STGDIRENT_H
  8. #define STGDIRENT_H
  9. #ifdef HAVE_CONFIG_H
  10. # include "config.h"
  11. #endif
  12. #if !defined(HAVE_DIRENT_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H)
  13. #include <strigi/strigiconfig.h>
  14. #include <windows.h>
  15. #include <io.h>
  16. /**
  17. * dirent.c
  18. *
  19. * Derived from DIRLIB.C by Matt J. Weinstein
  20. * This note appears in the DIRLIB.H
  21. * DIRLIB.H by M. J. Weinstein Released to public domain 1-Jan-89
  22. *
  23. * Updated by Jeremy Bettis <jeremy@hksys.com>
  24. * Significantly revised and rewinddir, seekdir and telldir added by Colin
  25. * Cut down again & changed by Ben van Klinken
  26. * Peters <colin@fu.is.saga-u.ac.jp>
  27. *
  28. */
  29. /** dirent structure - used by the dirent.h directory iteration functions */
  30. struct dirent
  31. {
  32. unsigned short d_namlen; /* Length of name in d_name. */
  33. char *d_name; /* File name. */
  34. };
  35. /** DIR structure - used by the dirent.h directory iteration functions*/
  36. struct DIR
  37. {
  38. /** disk transfer area for this dir */
  39. struct _finddata_t dd_dta;
  40. /* dirent struct to return from dir (NOTE: this makes this thread
  41. * safe as long as only one thread uses a particular DIR struct at
  42. * a time) */
  43. struct dirent dd_dir;
  44. /** _findnext handle */
  45. intptr_t dd_handle;
  46. /**
  47. * Status of search:
  48. * 0 = not started yet (next entry to read is first entry)
  49. * -1 = off the end
  50. * positive = 0 based index of next entry
  51. */
  52. int32_t dd_stat;
  53. /** given path for dir with search pattern (struct is extended) */
  54. char dd_name[MAX_PATH];
  55. };
  56. #define DIRENT_SEARCH_SUFFIX "*"
  57. #define DIRENT_SLASH PATH_DELIMITERA
  58. /**
  59. * Returns a pointer to a DIR structure appropriately filled in to begin
  60. * searching a directory.
  61. */
  62. DIR* strigi_opendir (const char* filespec);
  63. #define opendir strigi_opendir
  64. /**
  65. * Return a pointer to a dirent structure filled with the information on the
  66. * next entry in the directory.
  67. */
  68. struct dirent* strigi_readdir (DIR* dir);
  69. #define readdir strigi_readdir
  70. /**
  71. * Frees up resources allocated by opendir.
  72. */
  73. int32_t strigi_closedir (DIR* dir);
  74. #define closedir strigi_closedir
  75. #elif defined (HAVE_DIRENT_H)
  76. # include <dirent.h>
  77. # define NAMLEN(dirent) strlen((dirent)->d_name)
  78. #else
  79. # define dirent direct
  80. # define NAMLEN(dirent) (dirent)->d_namlen
  81. # if defined(HAVE_SYS_NDIR_H)
  82. # include <sys/ndir.h>
  83. # endif
  84. # if defined(HHAVE_SYS_DIR_H)
  85. # include <sys/dir.h>
  86. # endif
  87. # if defined(HHAVE_NDIR_H)
  88. # include <ndir.h>
  89. # endif
  90. #endif //HAVE_DIRENT_H
  91. #endif