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