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 (H&G2JCtL)
20
* Continued development: Barry Leslie
33
#include "CSStrUtil.h"
35
#include "CSDirectory.h"
39
* ---------------------------------------------------------------
40
* CORE SYSTEM DIRECTORY
43
void CSDirectory::print(CSOutputStream *out)
53
info(&is_dir, &size, &mod_time);
55
cs_strcpy(500, buffer, "D");
57
cs_strcpy(500, buffer, "f");
58
snprintf(number, 50, "%8llu ", (unsigned long long) size);
59
cs_strcat(500, buffer, number);
60
str_time = mod_time.getCString();
61
cs_strcat(500, buffer, str_time);
62
cs_strcat(500, buffer, " ");
63
cs_strcat(500, buffer, name());
64
out->printLine(buffer);
68
void CSDirectory::deleteEntry()
74
getEntryPath(path, PATH_MAX);
76
CSPath *cs_path = CSPath::newPath(path);
78
cs_path->removeFile();
84
const char *CSDirectory::name()
89
bool CSDirectory::isFile()
94
off64_t CSDirectory::getSize()
98
getEntryPath(path, PATH_MAX);
100
return CSPath::getSize(path);
103
void CSDirectory::info(bool *is_dir, off64_t *size, CSTime *mod_time)
107
getEntryPath(path, PATH_MAX);
109
CSPath::info(path, is_dir, size, mod_time);
112
bool CSDirectory::exists()
118
path = CSPath::newPath(RETAIN(sd_path));
120
yup = path->exists();
125
CSDirectory *CSDirectory::newDirectory(CSString *path)
129
if (!(dir = new CSDirectory())) {
131
CSException::throwOSError(CS_CONTEXT, ENOMEM);
137
CSDirectory *CSDirectory::newDirectory(CSPath *path)
143
dir = newDirectory(RETAIN(path->getString()));
148
CSDirectory *CSDirectory::newDirectory(const char *path)
150
return newDirectory(CSString::newString(path));