my_dir.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  18. #ifndef MY_DIR_H
  19. #define MY_DIR_H
  20. #include "my_global.h"
  21. #include <sys/stat.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Defines for my_dir and my_stat */
  26. #ifdef _WIN32
  27. #define S_IROTH _S_IREAD
  28. #define S_IFIFO _S_IFIFO
  29. #endif
  30. #define MY_S_IFMT S_IFMT /* type of file */
  31. #define MY_S_IFDIR S_IFDIR /* directory */
  32. #define MY_S_IFCHR S_IFCHR /* character special */
  33. #define MY_S_IFBLK S_IFBLK /* block special */
  34. #define MY_S_IFREG S_IFREG /* regular */
  35. #define MY_S_IFIFO S_IFIFO /* fifo */
  36. #define MY_S_ISUID S_ISUID /* set user id on execution */
  37. #define MY_S_ISGID S_ISGID /* set group id on execution */
  38. #define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
  39. #define MY_S_IREAD S_IREAD /* read permission, owner */
  40. #define MY_S_IWRITE S_IWRITE /* write permission, owner */
  41. #define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
  42. #define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
  43. #define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
  44. #define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
  45. #define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
  46. #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
  47. #define MY_DONT_SORT 512 /* my_lib; Don't sort files */
  48. #define MY_WANT_STAT 1024 /* my_lib; stat files */
  49. /* typedefs for my_dir & my_stat */
  50. #if(_MSC_VER)
  51. #define MY_STAT struct _stati64 /* 64 bit file size */
  52. #else
  53. #define MY_STAT struct stat /* Orginal struct have what we need */
  54. #endif
  55. /* Struct describing one file returned from my_dir */
  56. typedef struct fileinfo
  57. {
  58. char *name;
  59. MY_STAT *mystat;
  60. } FILEINFO;
  61. typedef struct st_my_dir /* Struct returned from my_dir */
  62. {
  63. /*
  64. These members are just copies of parts of DYNAMIC_ARRAY structure,
  65. which is allocated right after the end of MY_DIR structure (MEM_ROOT
  66. for storing names is also resides there). We've left them here because
  67. we don't want to change code that uses my_dir.
  68. */
  69. struct fileinfo *dir_entry;
  70. uint number_off_files;
  71. } MY_DIR;
  72. extern MY_DIR *my_dir(const char *path,myf MyFlags);
  73. extern void my_dirend(MY_DIR *buffer);
  74. extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
  75. extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif /* MY_DIR_H */