12.06.2015 Views

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

The Annoyance Filter.pdf - Fourmilab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

120 MAIL FOLDER ANNOYANCE-FILTER §137<br />

137. Open the next file in a directory of files which constitute a logical mail folder. findNextFileInDirectory<br />

has already vetted and expanded the path name, certifying that (at least when it checked) the target<br />

was an extant regular file.<br />

〈 Class implementations 11 〉 +≡<br />

#ifdef HAVE_DIRECTORY_TRAVERSAL<br />

bool mailFolder ::openNextFileInDirectory (void)<br />

{<br />

assert(dirFolder );<br />

if (dh ≡ Λ) {<br />

return false ;<br />

}<br />

#ifdef COMPRESSED_FILES<br />

string fname = cfName ;<br />

〈 Check for symbolic link to compressed file 133 〉;<br />

if (jname .rfind (Compressed file type ) ≡ (jname .length ( )−string(Compressed file type ).length ( )))<br />

{<br />

string cmd (Uncompress command );<br />

cmd += ’␣’ + fname ;<br />

ip = popen (cmd .c str ( ), "r");<br />

#ifdef HAVE_FDSTREAM_COMPATIBILITY<br />

ifcdir .attach (fileno(ip));<br />

ifcdir .clear ( ); /∗ Stupid attach doesn’t reset ios ::eofbit ! ∗/<br />

is = &ifcdir ;<br />

#else<br />

ifdir .attach (fileno(ip));<br />

ifdir .clear ( ); /∗ Stupid attach doesn’t reset ios ::eofbit ! ∗/<br />

is = &ifdir ;<br />

#endif<br />

}<br />

else {<br />

#endif<br />

ifdir .open (cfName .c str ( ));<br />

if (¬ifdir .is open ( )) {<br />

if (verbose ) {<br />

cerr ≪ "Unable␣to␣open␣mail␣folder␣directory␣file␣\"" ≪ cfName ≪ "\"" ≪ endl ;<br />

}<br />

return false ;<br />

}<br />

ifdir .clear ( ); /∗ Clean ios ::eofbit if open didn’t do so ∗/<br />

is = &ifdir ;<br />

#ifdef COMPRESSED_FILES<br />

}<br />

#endif<br />

expectingNewMessage = true ; /∗ Expect file to contain a new message ∗/<br />

setNewMessageEligiblity ( );<br />

return true ;<br />

}<br />

#endif

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!