static void sHandle_PROPFIND_All(const ZTrail& iPrefix, const ZNode& iRoot, const ZNode& iNode, int iDepth, ZTuple& ioTuple) { vector<string> thePropNames; thePropNames.push_back("D:resourcetype"); thePropNames.push_back("D:getcontenttype"); thePropNames.push_back("D:creationdate"); thePropNames.push_back("D:getlastmodified"); thePropNames.push_back("D:getcontentlength"); for (DAVIter i = DAVIter(iNode, iDepth); i; i.Advance()) { ZNode theNode = i.Current(); if (theNode.Exists()) { ZTuple goodT, badT; sGetProperties(theNode, thePropNames, goodT, badT); ZTuple responseT; responseT.SetString("D:href", sMakeHREF(iPrefix, iRoot, theNode)); if (goodT) { goodT.SetString("D:status", "HTTP/1.1 200 OK"); responseT.AppendTuple("D:propstat", goodT); } ioTuple.AppendTuple("D:response", responseT); } } }
static void sHandle_PROPFIND_Some(const ZTrail& iPrefix, const ZNode& iRoot, const ZNode& iNode, int iDepth, const vector<string>& iPropNames, ZTuple& ioTuple) { for (DAVIter i = DAVIter(iNode, iDepth); i; i.Advance()) { ZNode theNode = i.Current(); if (theNode.Exists()) { ZTuple goodT, badT; sGetProperties(theNode, iPropNames, goodT, badT); ZTuple responseT; responseT.SetString("D:href", sMakeHREF(iPrefix, iRoot, theNode)); if (goodT) { goodT.SetString("D:status", "HTTP/1.1 200 OK"); responseT.AppendTuple("D:propstat", goodT); } if (badT) { badT.SetString("D:status", "HTTP/1.1 404 Not Found"); responseT.AppendTuple("D:propstat", badT); } ioTuple.AppendTuple("D:response", responseT); } } }
static void sGetProperties(const ZNode& iNode, const vector<string>& iPropNames, ZTuple& oGoodT, ZTuple& oBadT) { for (vector<string>::const_iterator i = iPropNames.begin(); i != iPropNames.end(); ++i) { if (ZTuple propT = sGetProp(iNode, *i)) oGoodT.AppendTuple("D:prop", propT); else oBadT.AppendTuple("D:prop", ZTuple().SetNull(*i)); } }
static bool sDelete(const ZTrail& iPrefix, const ZNode& iRoot, const ZNode& iNode, ZTuple& ioT) { bool allOkay = true; // Delete any descendants of iNode. for (ZNodeIter i = iNode; i; i.Advance()) { if (!sDelete(iPrefix, iRoot, i.Current(), ioT)) allOkay = false; } if (allOkay) { if (iNode.Delete()) return true; ZTuple responseT; responseT.SetString("D:href", sMakeHREF(iPrefix, iRoot, iNode)); responseT.SetString("D:status", "HTTP/1.1 404"); ioT.AppendTuple("D:response", responseT); } return false; }