Clone of PhatAC @ https://github.com/floaterxk/PhatAC

my_dir.h 2.9KB

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