const word bodyPartAttachment::getName() const { word name; // Try the 'filename' parameter of 'Content-Disposition' field shared_ptr <const contentDispositionField> cdf = getContentDisposition(); if (cdf && cdf->hasFilename()) { name = cdf->getFilename(); } // Try the 'name' parameter of 'Content-Type' field else { shared_ptr <const contentTypeField> ctf = getContentType(); if (ctf) { shared_ptr <const parameter> prm = ctf->findParameter("name"); if (prm != NULL) name = prm->getValue(); } } return name; }
const word bodyPartAttachment::getName() const { word name; // Try the 'filename' parameter of 'Content-Disposition' field try { name = getContentDisposition()->getFilename(); } catch (exceptions::no_such_field&) { // No 'Content-Disposition' field } catch (exceptions::no_such_parameter&) { // No 'filename' parameter } // Try the 'name' parameter of 'Content-Type' field if (name.getBuffer().empty()) { try { ref <parameter> prm = getContentType()->findParameter("name"); if (prm != NULL) name = prm->getValue(); } catch (exceptions::no_such_field&) { // No 'Content-Type' field } catch (exceptions::no_such_parameter&) { // No attachment name available } } return name; }