1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
1 |
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
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
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
18 |
*
|
19 |
* Original author: Paul McCullagh (H&G2JCtL)
|
|
20 |
* Continued development: Barry Leslie
|
|
21 |
*
|
|
22 |
* 2007-06-07
|
|
23 |
*
|
|
24 |
* CORE SYSTEM:
|
|
25 |
* A basic directory.
|
|
26 |
*
|
|
27 |
*/
|
|
28 |
||
29 |
#include "CSConfig.h" |
|
30 |
||
31 |
#include <string.h> |
|
32 |
||
33 |
#include "CSStrUtil.h" |
|
34 |
#include "CSPath.h" |
|
35 |
#include "CSDirectory.h" |
|
36 |
#include "CSGlobal.h" |
|
37 |
||
38 |
/*
|
|
39 |
* ---------------------------------------------------------------
|
|
40 |
* CORE SYSTEM DIRECTORY
|
|
41 |
*/
|
|
42 |
||
43 |
void CSDirectory::print(CSOutputStream *out) |
|
44 |
{
|
|
45 |
char buffer[500]; |
|
46 |
char number[50]; |
|
47 |
bool is_dir; |
|
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
48 |
off64_t size; |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
49 |
CSTime mod_time; |
50 |
char *str_time; |
|
51 |
||
52 |
while (next()) { |
|
53 |
info(&is_dir, &size, &mod_time); |
|
54 |
if (is_dir) |
|
55 |
cs_strcpy(500, buffer, "D"); |
|
56 |
else
|
|
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); |
|
65 |
}
|
|
66 |
}
|
|
67 |
||
68 |
void CSDirectory::deleteEntry() |
|
69 |
{
|
|
70 |
char path[PATH_MAX]; |
|
71 |
||
72 |
enter_(); |
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
73 |
|
74 |
getEntryPath(path, PATH_MAX); |
|
75 |
||
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
76 |
CSPath *cs_path = CSPath::newPath(path); |
77 |
push_(cs_path); |
|
78 |
cs_path->removeFile(); |
|
79 |
release_(cs_path); |
|
80 |
||
81 |
exit_(); |
|
82 |
}
|
|
83 |
||
84 |
const char *CSDirectory::name() |
|
85 |
{
|
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
86 |
return entryName(); |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
87 |
}
|
88 |
||
89 |
bool CSDirectory::isFile() |
|
90 |
{
|
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
91 |
return entryIsFile(); |
92 |
}
|
|
93 |
||
94 |
off64_t CSDirectory::getSize() |
|
95 |
{
|
|
1548.2.33
by Barry.Leslie at PrimeBase
Added some special case code for directory handling on solaris. |
96 |
char path[PATH_MAX]; |
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
97 |
|
98 |
getEntryPath(path, PATH_MAX); |
|
99 |
||
100 |
return CSPath::getSize(path); |
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
101 |
}
|
102 |
||
1548.2.2
by Barry.Leslie at PrimeBase
A lot of minor changes to clean up the code and to get it to build with Drizzle. |
103 |
void CSDirectory::info(bool *is_dir, off64_t *size, CSTime *mod_time) |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
104 |
{
|
105 |
char path[PATH_MAX]; |
|
106 |
||
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
107 |
getEntryPath(path, PATH_MAX); |
108 |
||
109 |
CSPath::info(path, is_dir, size, mod_time); |
|
110 |
}
|
|
111 |
||
112 |
bool CSDirectory::exists() |
|
113 |
{
|
|
114 |
CSPath *path; |
|
115 |
bool yup; |
|
116 |
||
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
117 |
enter_(); |
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
118 |
path = CSPath::newPath(RETAIN(sd_path)); |
119 |
push_(path); |
|
120 |
yup = path->exists(); |
|
121 |
release_(path); |
|
122 |
return_(yup); |
|
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
123 |
}
|
124 |
||
1548.2.33
by Barry.Leslie at PrimeBase
Added some special case code for directory handling on solaris. |
125 |
CSDirectory *CSDirectory::newDirectory(CSString *path) |
126 |
{
|
|
127 |
CSDirectory *dir; |
|
128 |
||
129 |
if (!(dir = new CSDirectory())) { |
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
130 |
path->release(); |
1548.2.33
by Barry.Leslie at PrimeBase
Added some special case code for directory handling on solaris. |
131 |
CSException::throwOSError(CS_CONTEXT, ENOMEM); |
132 |
}
|
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
133 |
dir->sd_path = path; |
134 |
return dir; |
|
135 |
}
|
|
136 |
||
137 |
CSDirectory *CSDirectory::newDirectory(CSPath *path) |
|
138 |
{
|
|
139 |
CSDirectory *dir; |
|
140 |
enter_(); |
|
141 |
||
142 |
push_(path); |
|
143 |
dir = newDirectory(RETAIN(path->getString())); |
|
144 |
release_(path); |
|
1548.2.33
by Barry.Leslie at PrimeBase
Added some special case code for directory handling on solaris. |
145 |
return_(dir); |
146 |
}
|
|
147 |
||
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
148 |
CSDirectory *CSDirectory::newDirectory(const char *path) |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
149 |
{
|
1841.1.3
by Barry.Leslie at PrimeBase
Merged changes from lp:pbms. These changes should remove any danger |
150 |
return newDirectory(CSString::newString(path)); |
1548.2.1
by Barry.Leslie at PrimeBase
Added the PBMS daemon plugin. |
151 |
}
|
152 |
||
153 |