PageRenderTime 39ms CodeModel.GetById 30ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/mysql/include/mysql/my_dir.h

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