~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/cslib/CSPath.h

Merge Stewart's dead code removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
2
 
 *
3
 
 * PrimeBase Media Stream for MySQL
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 *
19
 
 * Original author: Paul McCullagh
20
 
 * Continued development: Barry Leslie
21
 
 *
22
 
 * 2007-06-07
23
 
 *
24
 
 * CORE SYSTEM:
25
 
 * Basic file system path.
26
 
 *
27
 
 */
28
 
 
29
 
#ifndef __CSPATH_H__
30
 
#define __CSPATH_H__
31
 
 
32
 
#ifdef OS_UNIX
33
 
#include <limits.h>
34
 
#endif
35
 
 
36
 
#include "CSDefs.h"
37
 
#include "CSTime.h"
38
 
#include "CSDefs.h"
39
 
#include "CSString.h"
40
 
#include "CSSys.h"
41
 
 
42
 
class CSFile;
43
 
class CSDirectory;
44
 
 
45
 
class CSPath : public CSRefObject, public CSSys {
46
 
public:
47
 
        virtual CSFile *createFile(int mode);
48
 
 
49
 
        virtual void copyFile(CSPath *to_file, bool overwrite);
50
 
 
51
 
        /*
52
 
         * Recursively creates as many directories as required.
53
 
         */
54
 
        virtual void makePath();
55
 
 
56
 
        virtual void copyDir(CSPath *to_dir, bool overwrite);
57
 
 
58
 
        /* Return true of the directory is a symbolic link. */
59
 
        virtual bool isLink();
60
 
 
61
 
        /* Return true of the directory is empty. */
62
 
        virtual bool isEmpty();
63
 
 
64
 
        /* Delete the contents of a directory */
65
 
        virtual void emptyDir();
66
 
        
67
 
        /* Recursively delete the contents of a directory */
68
 
        virtual void emptyPath();
69
 
        
70
 
        /* Copy a file or directory to the specified location. */
71
 
        virtual void copyTo(CSPath *to_path, bool overwrite);
72
 
 
73
 
        virtual void moveTo(CSPath *to_path);
74
 
 
75
 
        /*
76
 
         * Remove a file or directory (even if not empty).
77
 
         */
78
 
        virtual void remove();
79
 
 
80
 
        /* Create an empty file. */
81
 
        virtual void touch(bool create_path = false);
82
 
 
83
 
        virtual CSString *getString();
84
 
 
85
 
        virtual const char *getCString();
86
 
 
87
 
        virtual const char *getNameCString();
88
 
 
89
 
        //virtual CSPath *clone() const;
90
 
 
91
 
        friend class TDPath;
92
 
        
93
 
        virtual bool exists(bool *is_dir);
94
 
 
95
 
        virtual bool exists() { return exists(NULL); }
96
 
 
97
 
        static void info(const char *path, bool *is_dir, off64_t *size, CSTime *mod_time);
98
 
 
99
 
        virtual void info(bool *is_dir, off64_t *size, CSTime *mod_time);
100
 
 
101
 
        static off64_t getSize(const char *path);
102
 
        
103
 
        virtual off64_t getSize();
104
 
 
105
 
        virtual bool isDir();
106
 
 
107
 
        virtual CSFile *openFile(int mode);
108
 
 
109
 
        /*
110
 
         * Remove a file.
111
 
         */
112
 
        virtual void removeFile();
113
 
 
114
 
        /*
115
 
         * Creates a directory assuming the directory path exists.
116
 
         */
117
 
        virtual void makeDir();
118
 
 
119
 
        virtual CSDirectory *openDirectory();
120
 
 
121
 
        virtual void removeDir();
122
 
 
123
 
        virtual void rename(const char *name);
124
 
 
125
 
        /*
126
 
         * Renames one path to another.
127
 
         * The destination path may not exist.
128
 
         */
129
 
        virtual void move(CSPath *to_path);
130
 
        
131
 
        CSPath *getCWD();
132
 
 
133
 
        static CSPath *getSystemCWD();
134
 
 
135
 
        /* Create a new path given an absolute and a relative path: */
136
 
        static CSPath *newPath(const char *path);
137
 
        static CSPath *newPath(CSString *path);
138
 
 
139
 
        /* Create a path relative to the given 'cwd' */
140
 
        static CSPath *newPath(CSPath *cwd, const char *path);
141
 
        static CSPath *newPath(CSString *cwd, const char *path);
142
 
        static CSPath *newPath(const char *cwd, CSString *path);
143
 
        static CSPath *newPath(const char *cwd, const char *path);
144
 
 
145
 
private:
146
 
        CSFile *try_CreateAndOpen(CSThread *self, int mode, bool retry);
147
 
        static CSLock iRename_lock;
148
 
        CSPath():iPath(NULL) { }
149
 
 
150
 
        virtual ~CSPath();
151
 
 
152
 
        CSString *iPath;
153
 
 
154
 
        static CSPath *iCWD;
155
 
};
156
 
 
157
 
#endif