Roxen.git
/
server
/
base_server
/
module.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/base_server/module.pike:1428:
//! write access to @[path]. It should at least call //! @[check_if_header] to check DAV locks. It takes the same arguments //! and has the same return value as that function. //! //! WARNING: This function has some design issues and will very likely //! get a different interface. Compatibility is NOT guaranteed. //! //! A filesystem module should typically put all needed write access //! checks here and then use this from @[find_file()], //! @[delete_file()] etc.
+
//!
+
//! @returns
+
//! Returns @expr{0@} (zero) on success, a status mapping on
+
//! failure, or @expr{1@} if @[recursive] is set and write access is
+
//! allowed on this level but maybe not somewhere below. The caller
+
//! should in the last case do the operation on this level if
+
//! possible and then handle each member in the directory
+
//! recursively with @[write_access] etc.
protected mapping(string:mixed)|int(0..1) write_access(string relative_path, int(0..1) recursive, RequestID id) { return check_if_header (relative_path, recursive, id); }
-
+
//!
+
protected variant mapping(string:mixed)|int(0..1) write_access(array(string) paths,
+
int(0..1) recursive,
+
RequestID id)
+
{
+
mapping(string:mixed)|int(0..1) ret;
+
int got_ok;
+
foreach(paths, string path) {
+
ret = write_access(path, recursive, id);
+
if (!ret) {
+
got_ok = 1;
+
continue;
+
}
+
if (ret == 1) {
+
continue;
+
}
+
if (ret->error == Protocols.HTTP.HTTP_PRECOND_FAILED) {
+
continue;
+
}
+
return ret;
+
}
+
+
if (got_ok) {
+
// The if headers are valid for at least one of the paths,
+
// and none of the other paths are locked.
+
return 0;
+
}
+
+
// HTTP_PRECOND_FAILED for all of the paths.
+
return ret;
+
}
+
mapping(string:mixed)|int(-1..0)|Stdio.File find_file(string path, RequestID id); //! Used by the default @[recurse_delete_files] implementation to //! delete a file or an empty directory. //! //! @returns //! Returns a 2xx series status mapping on success (typically 204 No //! Content). Returns 0 if the file doesn't exist. Returns an //! appropriate status mapping for any other error.