1
/* Copyright (c) 2007 SNAP Innovation GmbH
3
* BLOB Streaming for MySQL
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.
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.
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
19
* Author: Paul McCullagh
24
* Basic file system path.
46
class CSPath : public CSRefObject {
48
virtual CSFile *createFile(int mode);
50
virtual void copyFile(CSPath *to_file, bool overwrite);
53
* Recursively creates as many directories as required.
55
virtual void makePath();
57
virtual void copyDir(CSPath *to_dir, bool overwrite);
59
/* Return true of the directory is empty. */
60
virtual bool isEmpty();
62
/* Delete the contents of a directory */
63
virtual void emptyDir();
65
/* Copy a file or directory to the specified location. */
66
virtual void copyTo(CSPath *to_path, bool overwrite);
68
virtual void moveTo(CSPath *to_path);
70
virtual void remove();
72
/* Create an empty file. */
73
virtual void touch(bool create_path);
75
virtual CSString *getString();
77
virtual const char *getCString();
79
virtual const char *getNameCString();
81
//virtual CSPath *clone() const = 0;
87
virtual bool exists(bool *is_dir) = 0;
89
virtual bool exists() { return exists(NULL); }
91
virtual void info(bool *is_dir, off_t *size, CSTime *mod_time) = 0;
93
virtual off_t getSize();
97
virtual CSFile *openFile(int mode) = 0;
100
* Remove a file or directory (even if not empty).
102
virtual void removeFile() = 0;
105
* Creates a directory assuming the directory path exists.
107
virtual void makeDir() = 0;
109
virtual CSDirectory *openDirectory() = 0;
111
virtual void removeDir() = 0;
113
virtual void rename(const char *name) = 0;
116
* Renames one path to another.
117
* The destination path may not exist.
119
virtual void move(CSPath *to_path) = 0;
121
static CSPath *getSystemCWD();
123
/* Create a new path given an absolute and a relative path: */
124
static CSPath *newPath(const char *path);
125
static CSPath *newPath(CSString *path);
127
/* Create a path relative to the given 'cwd' */
128
static CSPath *newPath(CSPath *cwd, const char *path);
129
static CSPath *newPath(CSString *cwd, const char *path);
132
CSPath():iPath(NULL) { }
141
class UXPath : public CSPath {
143
UXPath(): CSPath() { }
145
virtual ~UXPath() { }
147
virtual bool exists(bool *is_dir);
149
virtual void info(bool *is_dir, off_t *size, CSTime *mod_time);
151
virtual CSFile *openFile(int mode);
153
virtual void removeFile();
155
virtual void makeDir();
157
virtual CSDirectory *openDirectory();
159
virtual void removeDir();
161
virtual void rename(const char *path);
163
virtual void move(CSPath *to_path);
165
static CSPath *getCWD();
167
static CSPath *newPath(const char *path);
169
static CSPath *newPath(CSString *path);
171
static CSPath *newPath(CSPath *cwd, const char *path);
173
static CSPath *newPath(CSString *cwd, const char *path);