~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to storage/ndb/include/portlib/NdbDir.hpp

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008, 2010, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
 
15
 
 
16
#ifndef NdbDir_HPP
 
17
#define NdbDir_HPP
 
18
 
 
19
#ifdef _WIN32
 
20
#ifndef mode_t /* MySQL 5.5+ defines mode_t */
 
21
typedef int mode_t;
 
22
#endif
 
23
#endif
 
24
 
 
25
class NdbDir {
 
26
public:
 
27
  class Iterator {
 
28
    class DirIteratorImpl& m_impl;
 
29
    Iterator(const Iterator&);  // not impl
 
30
    Iterator& operator=(const Iterator&); // not impl
 
31
  public:
 
32
    Iterator();
 
33
    ~Iterator();
 
34
 
 
35
    int open(const char* path);
 
36
    void close(void);
 
37
 
 
38
    /*
 
39
      Return the next regular file or NULL if no more file found
 
40
    */
 
41
    const char* next_file(void);
 
42
 
 
43
    /*
 
44
      Return the next entry(file, dir, symlink etc.) or NULL if no
 
45
      more entries found
 
46
    */
 
47
    const char* next_entry(void);
 
48
  };
 
49
 
 
50
  class Temp {
 
51
    const char* m_path;
 
52
    Temp(const Temp&);  // not impl
 
53
    Temp& operator=(const Temp&); // not impl
 
54
  public:
 
55
    Temp();
 
56
    ~Temp();
 
57
    const char* path(void) const;
 
58
  };
 
59
 
 
60
  static mode_t u_r(void);
 
61
  static mode_t u_w(void);
 
62
  static mode_t u_x(void);
 
63
  static mode_t u_rwx(void) { return (u_r() | u_w() | u_x()); }
 
64
 
 
65
  static mode_t g_r(void);
 
66
  static mode_t g_w(void);
 
67
  static mode_t g_x(void);
 
68
  static mode_t g_rwx(void) { return (g_r() | g_w() | g_x()); }
 
69
 
 
70
  static mode_t o_r(void);
 
71
  static mode_t o_w(void);
 
72
  static mode_t o_x(void);
 
73
  static mode_t o_rwx(void) { return (o_r() | o_w() | o_x()); }
 
74
 
 
75
  /*
 
76
    Create directory
 
77
     path - path to directory to create
 
78
     mode - mode for the directory to create
 
79
     ignore_existing - don't print or return error if directory
 
80
                       already exist
 
81
  */
 
82
  static bool create(const char *path,
 
83
                     mode_t mode = u_rwx(),
 
84
                     bool ignore_existing = false);
 
85
 
 
86
  /*
 
87
    Remove directory recursively
 
88
      path - path to directory that should be removed
 
89
      only_contents - only remove the contents of the directory
 
90
 
 
91
  */
 
92
  static bool remove_recursive(const char* path, bool only_contents = false);
 
93
 
 
94
  /*
 
95
    Remove empty directory
 
96
  */
 
97
  static bool remove(const char* path);
 
98
 
 
99
  /*
 
100
    Change working directory
 
101
  */
 
102
  static int chdir(const char* path);
 
103
 
 
104
};
 
105
 
 
106
#endif