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