blob: 9e6daf2da36e9b344228d961d473ea602bbad4e0 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- ArchiveWriter.h - ar archive file format writer ----------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
21namespace llvm {
22
23struct 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010029 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
Andrew Walbran3d2c1972020-04-07 12:24:26 +010039Expected<std::string> computeArchiveRelativePath(StringRef From, StringRef To);
40
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010041Error 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