ArchiveWriter.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Declares the writeArchive function for writing an archive file.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_OBJECT_ARCHIVEWRITER_H
  18. #define LLVM_OBJECT_ARCHIVEWRITER_H
  19. #include "llvm/Object/Archive.h"
  20. namespace llvm {
  21. struct NewArchiveMember {
  22. std::unique_ptr<MemoryBuffer> Buf;
  23. StringRef MemberName;
  24. sys::TimePoint<std::chrono::seconds> ModTime;
  25. unsigned UID = 0, GID = 0, Perms = 0644;
  26. NewArchiveMember() = default;
  27. NewArchiveMember(MemoryBufferRef BufRef);
  28. static Expected<NewArchiveMember>
  29. getOldMember(const object::Archive::Child &OldMember, bool Deterministic);
  30. static Expected<NewArchiveMember> getFile(StringRef FileName,
  31. bool Deterministic);
  32. };
  33. Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);
  34. Error writeArchive(StringRef ArcName, ArrayRef<NewArchiveMember> NewMembers,
  35. bool WriteSymtab, object::Archive::Kind Kind,
  36. bool Deterministic, bool Thin,
  37. std::unique_ptr<MemoryBuffer> OldArchiveBuf = nullptr);
  38. // writeArchiveToBuffer is similar to writeArchive but returns the Archive in a
  39. // buffer instead of writing it out to a file.
  40. Expected<std::unique_ptr<MemoryBuffer>>
  41. writeArchiveToBuffer(ArrayRef<NewArchiveMember> NewMembers, bool WriteSymtab,
  42. object::Archive::Kind Kind, bool Deterministic, bool Thin);
  43. }
  44. #endif
  45. #ifdef __GNUC__
  46. #pragma GCC diagnostic pop
  47. #endif