libbase: add Fdopen that takes a unique_fd.

Using fdopen with unique_fd correctly is more annoying than it should
be, because fdopen doesn't close the file descriptor received upon
failure, which means you have to something like the following:

    unique_fd ufd = ...;
    int fd = ufd.release();
    FILE* file = fdopen(fd, "...");
    if (!file) {
        close(fd);
        return;
    }

Add an android::base::Fdopen that does that dance for you.

Bug: http://b/113880863
Test: treehugger
Change-Id: I6325acf1ff06484005c1053fe09672c5eeeecaa1
1 file changed