void mail::maildir::genericMessageSize(string uid, size_t messageNumber, mail::callback::message &callback) { if (!fixMessageNumber(this, uid, messageNumber)) { callback.messageSizeCallback(messageNumber, 0); callback.success("OK"); return; } string messageFn=getfilename(messageNumber); if (messageFn.size() == 0) { callback.messageSizeCallback(messageNumber,0); callback.success("OK"); return; } unsigned long ul; if (maildir_parsequota(messageFn.c_str(), &ul) == 0) { callback.messageSizeCallback(messageNumber, ul); callback.success("OK"); return; } struct stat stat_buf; int rc=stat(messageFn.c_str(), &stat_buf); callback.messageSizeCallback(messageNumber, rc == 0 ? stat_buf.st_size:0); callback.success("OK"); }
void mail::mbox::genericMessageSize(string uid, size_t messageNumber, mail::callback::message &callback) { if (!verifyUid(uid, messageNumber, callback)) return; size_t n=uidmap.find(uid)->second; off_t s=folderMessageIndex[n].startingPos; off_t e=n + 1 >= folderMessageIndex.size() ? folderSavedSize:folderMessageIndex[n+1].startingPos; callback.messageSizeCallback( messageNumber, e > s ? e-s:0); callback.success("OK"); }