9
3

my_dir.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copyright (C) 2000 MySQL AB
  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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  12. #ifndef _my_dir_h
  13. #define _my_dir_h
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #ifndef MY_DIR_H
  18. #define MY_DIR_H
  19. #include <sys/stat.h>
  20. /* Defines for my_dir and my_stat */
  21. #define MY_S_IFMT S_IFMT /* type of file */
  22. #define MY_S_IFDIR S_IFDIR /* directory */
  23. #define MY_S_IFCHR S_IFCHR /* character special */
  24. #define MY_S_IFBLK S_IFBLK /* block special */
  25. #define MY_S_IFREG S_IFREG /* regular */
  26. #define MY_S_IFIFO S_IFIFO /* fifo */
  27. #define MY_S_ISUID S_ISUID /* set user id on execution */
  28. #define MY_S_ISGID S_ISGID /* set group id on execution */
  29. #define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
  30. #define MY_S_IREAD S_IREAD /* read permission, owner */
  31. #define MY_S_IWRITE S_IWRITE /* write permission, owner */
  32. #define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
  33. #define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
  34. #define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
  35. #define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
  36. #define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
  37. #define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
  38. #define MY_DONT_SORT 512 /* my_lib; Don't sort files */
  39. #define MY_WANT_STAT 1024 /* my_lib; stat files */
  40. /* typedefs for my_dir & my_stat */
  41. #ifdef USE_MY_STAT_STRUCT
  42. typedef struct my_stat
  43. {
  44. dev_t st_dev; /* major & minor device numbers */
  45. ino_t st_ino; /* inode number */
  46. ushort st_mode; /* file permissons (& suid sgid .. bits) */
  47. short st_nlink; /* number of links to file */
  48. ushort st_uid; /* user id */
  49. ushort st_gid; /* group id */
  50. dev_t st_rdev; /* more major & minor device numbers (???) */
  51. off_t st_size; /* size of file */
  52. time_t st_atime; /* time for last read */
  53. time_t st_mtime; /* time for last contens modify */
  54. time_t st_ctime; /* time for last inode or contents modify */
  55. } MY_STAT;
  56. #else
  57. #define MY_STAT struct stat /* Orginal struct have what we need */
  58. #endif /* USE_MY_STAT_STRUCT */
  59. /* Struct describing one file returned from my_dir */
  60. typedef struct fileinfo
  61. {
  62. char *name;
  63. MY_STAT *mystat;
  64. } FILEINFO;
  65. typedef struct st_my_dir /* Struct returned from my_dir */
  66. {
  67. /*
  68. These members are just copies of parts of DYNAMIC_ARRAY structure,
  69. which is allocated right after the end of MY_DIR structure (MEM_ROOT
  70. for storing names is also resides there). We've left them here because
  71. we don't want to change code that uses my_dir.
  72. */
  73. struct fileinfo *dir_entry;
  74. uint number_off_files;
  75. } MY_DIR;
  76. extern MY_DIR *my_dir(const char *path,myf MyFlags);
  77. extern void my_dirend(MY_DIR *buffer);
  78. extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
  79. extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
  80. #endif /* MY_DIR_H */
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif