1 //===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Declares the writeArchive function for writing an archive file.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_OBJECT_ARCHIVEWRITER_H
14 #define LLVM_OBJECT_ARCHIVEWRITER_H
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/Object/Archive.h"
18 #include "llvm/Support/Error.h"
19 #include "llvm/Support/FileSystem.h"
23 struct NewArchiveMember
{
24 std::unique_ptr
<MemoryBuffer
> Buf
;
26 sys::TimePoint
<std::chrono::seconds
> ModTime
;
27 unsigned UID
= 0, GID
= 0, Perms
= 0644;
29 NewArchiveMember() = default;
30 NewArchiveMember(MemoryBufferRef BufRef
);
32 static Expected
<NewArchiveMember
>
33 getOldMember(const object::Archive::Child
&OldMember
, bool Deterministic
);
35 static Expected
<NewArchiveMember
> getFile(StringRef FileName
,
39 Expected
<std::string
> computeArchiveRelativePath(StringRef From
, StringRef To
);
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);