MCPcopy Create free account
hub / github.com/apache/httpd / dav_fs_dir_file_name

Function dav_fs_dir_file_name

modules/dav/fs/repos.c:239–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239dav_error * dav_fs_dir_file_name(
240 const dav_resource *resource,
241 const char **dirpath_p,
242 const char **fname_p)
243{
244 dav_resource_private *ctx = resource->info;
245
246 if (resource->collection) {
247 *dirpath_p = ctx->pathname;
248 if (fname_p != NULL)
249 *fname_p = NULL;
250 }
251 else {
252 const char *testpath, *rootpath;
253 char *dirpath = ap_make_dirstr_parent(ctx->pool, ctx->pathname);
254 apr_size_t dirlen = strlen(dirpath);
255 apr_status_t rv = APR_SUCCESS;
256
257 testpath = dirpath;
258 if (dirlen > 0) {
259 rv = apr_filepath_root(&rootpath, &testpath, 0, ctx->pool);
260 }
261
262 /* remove trailing slash from dirpath, unless it's a root path
263 */
264 if ((rv == APR_SUCCESS && testpath && *testpath)
265 || rv == APR_ERELATIVE) {
266 if (dirpath[dirlen - 1] == '/') {
267 dirpath[dirlen - 1] = '\0';
268 }
269 }
270
271 /* ###: Looks like a response could be appropriate
272 *
273 * APR_SUCCESS here tells us the dir is a root
274 * APR_ERELATIVE told us we had no root (ok)
275 * APR_EINCOMPLETE an incomplete testpath told us
276 * there was no -file- name here!
277 * APR_EBADPATH or other errors tell us this file
278 * path is undecipherable
279 */
280
281 if (rv == APR_SUCCESS || rv == APR_ERELATIVE) {
282 *dirpath_p = dirpath;
283 if (fname_p != NULL)
284 *fname_p = ctx->pathname + dirlen;
285 }
286 else {
287 return dav_new_error(ctx->pool, HTTP_INTERNAL_SERVER_ERROR, 0, rv,
288 "An incomplete/bad path was found in "
289 "dav_fs_dir_file_name.");
290 }
291 }
292
293 return NULL;
294}
295
296/* Note: picked up from ap_gm_timestr_822() */

Callers 5

dav_dbm_openFunction · 0.85
dav_fs_copymovesetFunction · 0.85
dav_fs_deletesetFunction · 0.85

Calls 2

ap_make_dirstr_parentFunction · 0.85
dav_new_errorFunction · 0.85

Tested by

no test coverage detected