diff options
author | Martin Storsjo <martin@martin.st> | 2018-05-07 20:27:37 +0000 |
---|---|---|
committer | Martin Storsjo <martin@martin.st> | 2018-05-07 20:27:37 +0000 |
commit | 577b98174834401222f8353c2ad8d1a7d9306965 (patch) | |
tree | 9d729230fa6a6bd9aeb30c4c0b9263e958f0f8f3 /llvm/tools/llvm-rc/ResourceFileWriter.cpp | |
parent | 9410276cf7c46ceade1cc812a7d30e6ae0b3d2d1 (diff) | |
download | bcm5719-llvm-577b98174834401222f8353c2ad8d1a7d9306965.tar.gz bcm5719-llvm-577b98174834401222f8353c2ad8d1a7d9306965.zip |
[llvm-rc] Implement the BITMAP resource type
Differential Revision: https://reviews.llvm.org/D46509
llvm-svn: 331670
Diffstat (limited to 'llvm/tools/llvm-rc/ResourceFileWriter.cpp')
-rw-r--r-- | llvm/tools/llvm-rc/ResourceFileWriter.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp b/llvm/tools/llvm-rc/ResourceFileWriter.cpp index 93471db200e..54f6c0ede73 100644 --- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp +++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp @@ -437,6 +437,10 @@ Error ResourceFileWriter::visitAcceleratorsResource(const RCResource *Res) { return writeResource(Res, &ResourceFileWriter::writeAcceleratorsBody); } +Error ResourceFileWriter::visitBitmapResource(const RCResource *Res) { + return writeResource(Res, &ResourceFileWriter::writeBitmapBody); +} + Error ResourceFileWriter::visitCursorResource(const RCResource *Res) { return handleError(visitIconOrCursorResource(Res), Res); } @@ -684,6 +688,29 @@ Error ResourceFileWriter::writeAcceleratorsBody(const RCResource *Base) { return Error::success(); } +// --- BitmapResource helpers. --- // + +Error ResourceFileWriter::writeBitmapBody(const RCResource *Base) { + StringRef Filename = cast<BitmapResource>(Base)->BitmapLoc; + bool IsLong; + stripQuotes(Filename, IsLong); + + auto File = loadFile(Filename); + if (!File) + return File.takeError(); + + StringRef Buffer = (*File)->getBuffer(); + + // Skip the 14 byte BITMAPFILEHEADER. + constexpr size_t BITMAPFILEHEADER_size = 14; + if (Buffer.size() < BITMAPFILEHEADER_size || Buffer[0] != 'B' || + Buffer[1] != 'M') + return createError("Incorrect bitmap file."); + + *FS << Buffer.substr(BITMAPFILEHEADER_size); + return Error::success(); +} + // --- CursorResource and IconResource helpers. --- // // ICONRESDIR structure. Describes a single icon in resouce group. |