Search in sources :

Example 1 with UnixArchiveEntry

use of com.facebook.buck.bsd.UnixArchiveEntry in project buck by facebook.

the class ObjectPathsAbsolutifier method fixCompDirInStaticLibrary.

private void fixCompDirInStaticLibrary(Path destination) throws IOException {
    FileChannel channel = FileChannel.open(destination, StandardOpenOption.READ, StandardOpenOption.WRITE);
    ByteBuffer buffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, channel.size());
    if (!UnixArchive.checkHeader(buffer)) {
        LOG.warn("Static library at %s has wrong header, skipping", destination);
        return;
    }
    UnixArchive archive = new UnixArchive(channel, nulTerminatedCharsetDecoder);
    for (UnixArchiveEntry archiveEntry : archive.getEntries()) {
        if (archiveEntry.getFileName().endsWith(".o")) {
            MappedByteBuffer map = archive.getMapForEntry(archiveEntry);
            CompDirReplacer replacer = new CompDirReplacer(map, nulTerminatedCharsetDecoder);
            replacer.replaceCompDir(oldCompDir, newCompDir);
        }
    }
    archive.close();
}
Also used : MappedByteBuffer(java.nio.MappedByteBuffer) FileChannel(java.nio.channels.FileChannel) UnixArchive(com.facebook.buck.bsd.UnixArchive) UnixArchiveEntry(com.facebook.buck.bsd.UnixArchiveEntry) ByteBuffer(java.nio.ByteBuffer) MappedByteBuffer(java.nio.MappedByteBuffer)

Aggregations

UnixArchive (com.facebook.buck.bsd.UnixArchive)1 UnixArchiveEntry (com.facebook.buck.bsd.UnixArchiveEntry)1 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1