~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-07-06 00:44:32 UTC
  • mfrom: (1643.1.13 build)
  • Revision ID: mordred@inaugust.com-20100706004432-843uftc92rc2497l
Merged in PBMS, translation updates, a few build fixes and a few bug fixes.

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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
 
 
41
using namespace std;
 
42
 
 
43
class CSFile;
 
44
class CSDirectory;
 
45
 
 
46
class CSPath : public CSRefObject {
 
47
public:
 
48
        virtual CSFile *createFile(int mode);
 
49
 
 
50
        virtual void copyFile(CSPath *to_file, bool overwrite);
 
51
 
 
52
        /*
 
53
         * Recursively creates as many directories as required.
 
54
         */
 
55
        virtual void makePath();
 
56
 
 
57
        virtual void copyDir(CSPath *to_dir, bool overwrite);
 
58
 
 
59
        /* Return true of the directory is a symbolic link. */
 
60
        virtual bool isLink();
 
61
 
 
62
        /* Return true of the directory is empty. */
 
63
        virtual bool isEmpty();
 
64
 
 
65
        /* Delete the contents of a directory */
 
66
        virtual void emptyDir();
 
67
        
 
68
        /* Copy a file or directory to the specified location. */
 
69
        virtual void copyTo(CSPath *to_path, bool overwrite);
 
70
 
 
71
        virtual void moveTo(CSPath *to_path);
 
72
 
 
73
        /*
 
74
         * Remove a file or directory (even if not empty).
 
75
         */
 
76
        virtual void remove();
 
77
 
 
78
        /* Create an empty file. */
 
79
        virtual void touch(bool create_path);
 
80
 
 
81
        virtual CSString *getString();
 
82
 
 
83
        virtual const char *getCString();
 
84
 
 
85
        virtual const char *getNameCString();
 
86
 
 
87
        //virtual CSPath *clone() const;
 
88
 
 
89
        friend class TDPath;
 
90
        
 
91
        virtual bool exists(bool *is_dir);
 
92
 
 
93
        virtual bool exists() { return exists(NULL); }
 
94
 
 
95
        virtual void info(bool *is_dir, off64_t *size, CSTime *mod_time);
 
96
 
 
97
        virtual off64_t getSize();
 
98
 
 
99
        virtual bool isDir();
 
100
 
 
101
        virtual CSFile *openFile(int mode);
 
102
 
 
103
        /*
 
104
         * Remove a file.
 
105
         */
 
106
        virtual void removeFile();
 
107
 
 
108
        /*
 
109
         * Creates a directory assuming the directory path exists.
 
110
         */
 
111
        virtual void makeDir();
 
112
 
 
113
        virtual CSDirectory *openDirectory();
 
114
 
 
115
        virtual void removeDir();
 
116
 
 
117
        virtual void rename(const char *name);
 
118
 
 
119
        /*
 
120
         * Renames one path to another.
 
121
         * The destination path may not exist.
 
122
         */
 
123
        virtual void move(CSPath *to_path);
 
124
        
 
125
        CSPath *getCWD();
 
126
 
 
127
        static CSPath *getSystemCWD();
 
128
 
 
129
        /* Create a new path given an absolute and a relative path: */
 
130
        static CSPath *newPath(const char *path);
 
131
        static CSPath *newPath(CSString *path);
 
132
 
 
133
        /* Create a path relative to the given 'cwd' */
 
134
        static CSPath *newPath(CSPath *cwd, const char *path);
 
135
        static CSPath *newPath(CSString *cwd, const char *path);
 
136
        static CSPath *newPath(const char *cwd, CSString *path);
 
137
        static CSPath *newPath(const char *cwd, const char *path);
 
138
 
 
139
private:
 
140
        CSPath():iPath(NULL) { }
 
141
 
 
142
        virtual ~CSPath();
 
143
 
 
144
        CSString *iPath;
 
145
 
 
146
        static CSPath *iCWD;
 
147
};
 
148
 
 
149
#endif