OSDN Git Service

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