1
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
* Original author: Paul McCullagh
20
* Continued development: Barry Leslie
25
* Basic file system path.
45
class CSPath : public CSRefObject, public CSSys {
47
virtual CSFile *createFile(int mode);
49
virtual void copyFile(CSPath *to_file, bool overwrite);
52
* Recursively creates as many directories as required.
54
virtual void makePath();
56
virtual void copyDir(CSPath *to_dir, bool overwrite);
58
/* Return true of the directory is a symbolic link. */
59
virtual bool isLink();
61
/* Return true of the directory is empty. */
62
virtual bool isEmpty();
64
/* Delete the contents of a directory */
65
virtual void emptyDir();
67
/* Recursively delete the contents of a directory */
68
virtual void emptyPath();
70
/* Copy a file or directory to the specified location. */
71
virtual void copyTo(CSPath *to_path, bool overwrite);
73
virtual void moveTo(CSPath *to_path);
76
* Remove a file or directory (even if not empty).
78
virtual void remove();
80
/* Create an empty file. */
81
virtual void touch(bool create_path = false);
83
virtual CSString *getString();
85
virtual const char *getCString();
87
virtual const char *getNameCString();
89
//virtual CSPath *clone() const;
93
virtual bool exists(bool *is_dir);
95
virtual bool exists() { return exists(NULL); }
97
static void info(const char *path, bool *is_dir, off64_t *size, CSTime *mod_time);
99
virtual void info(bool *is_dir, off64_t *size, CSTime *mod_time);
101
static off64_t getSize(const char *path);
103
virtual off64_t getSize();
105
virtual bool isDir();
107
virtual CSFile *openFile(int mode);
112
virtual void removeFile();
115
* Creates a directory assuming the directory path exists.
117
virtual void makeDir();
119
virtual CSDirectory *openDirectory();
121
virtual void removeDir();
123
virtual void rename(const char *name);
126
* Renames one path to another.
127
* The destination path may not exist.
129
virtual void move(CSPath *to_path);
133
static CSPath *getSystemCWD();
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);
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);
146
CSFile *try_CreateAndOpen(CSThread *self, int mode, bool retry);
147
static CSLock iRename_lock;
148
CSPath():iPath(NULL) { }