~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/blocks/ndbfs/Filename.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 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 Filename_H
 
17
#define Filename_H
 
18
 
 
19
//===========================================================================
 
20
//
 
21
// .DESCRIPTION
 
22
//      Takes a 128 bits value (done as a array of four longs) and 
 
23
//      makes a filename out of it acording the following schema
 
24
//      Bits 0-31 T 
 
25
//      Bits 32-63 F
 
26
//      Bits 64-95 S
 
27
//      Bits 96-103 P
 
28
//      Bits 104-111 D
 
29
//      Bits 112-119 File Type
 
30
//      Bits 120-127 Version number of Filename
 
31
//      
 
32
//      T, is used to find/create a directory. If T = 0xFFFF then the
 
33
//      file is on top level. In that case the F is of no relevance.
 
34
//      F, same as T.
 
35
//      S, is used to find/create a filename. If S= 0xFFFF then it is ignored.
 
36
//      P, same as S
 
37
//      D, is used to find/create the root directory, this is the
 
38
//      directory before the blockname. If D= 0xFF then it is ignored.
 
39
//      File Type
 
40
//              0 => .Data
 
41
//              1 => .FragLog
 
42
//              2 => .LocLog
 
43
//              3 => .FragList
 
44
//              4 => .TableList
 
45
//              5 => .SchemaLog
 
46
//              6 => .sysfile
 
47
//              15=> ignored
 
48
//      Version number of Filename, current version is 0x1, must be
 
49
//      used for the this style of options.
 
50
//
 
51
//
 
52
//===========================================================================
 
53
 
 
54
#include <ndb_global.h>
 
55
#include <kernel_types.h>
 
56
#include <SimulatedBlock.hpp>
 
57
 
 
58
class Filename
 
59
{
 
60
public:
 
61
   // filenumber is 64 bits but is split in to 4 32bits words 
 
62
  Filename();
 
63
  ~Filename();
 
64
 
 
65
  struct NameSpec {
 
66
    NameSpec(BaseString& f, BaseString&b) :
 
67
      fs_path(f), backup_path(b) {}
 
68
    BaseString& fs_path;
 
69
    BaseString& backup_path;
 
70
  };
 
71
  
 
72
  void set(NameSpec& spec, 
 
73
           BlockReference, const Uint32 fileno[4], bool = false);
 
74
  void set(NameSpec& spec, 
 
75
           SegmentedSectionPtr ptr, class SectionSegmentPool&);
 
76
  
 
77
  const char* c_str() const;     // Complete name including dirname
 
78
  const char* get_base_name() const; // Exclude fs (or backup) path
 
79
private:
 
80
  char theName[PATH_MAX];
 
81
  char * m_base_name;
 
82
};
 
83
 
 
84
// inline methods
 
85
inline const char* Filename::c_str() const {
 
86
  return theName;
 
87
}
 
88
 
 
89
inline const char* Filename::get_base_name() const {
 
90
  return m_base_name;
 
91
}
 
92
 
 
93
#endif
 
94
 
 
95
 
 
96
 
 
97