forked from microsoft/winget-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile.cpp
More file actions
68 lines (55 loc) · 1.59 KB
/
Copy pathFile.cpp
File metadata and controls
68 lines (55 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "File.h"
#include "details/ErrorHandling.h"
using namespace SFS;
File::File(std::string&& fileId,
std::string&& url,
uint64_t sizeInBytes,
std::unordered_map<HashType, std::string>&& hashes)
: m_fileId(std::move(fileId))
, m_url(std::move(url))
, m_sizeInBytes(sizeInBytes)
, m_hashes(std::move(hashes))
{
}
Result File::Make(std::string fileId,
std::string url,
uint64_t sizeInBytes,
std::unordered_map<HashType, std::string> hashes,
std::unique_ptr<File>& out) noexcept
try
{
out.reset();
std::unique_ptr<File> tmp(new File(std::move(fileId), std::move(url), sizeInBytes, std::move(hashes)));
out = std::move(tmp);
return Result::Success;
}
SFS_CATCH_RETURN()
Result File::Clone(std::unique_ptr<File>& out) const noexcept
{
return Make(m_fileId, m_url, m_sizeInBytes, m_hashes, out);
}
File::File(File&& other) noexcept
{
m_fileId = std::move(other.m_fileId);
m_url = std::move(other.m_url);
m_sizeInBytes = other.m_sizeInBytes;
m_hashes = std::move(other.m_hashes);
}
const std::string& File::GetFileId() const noexcept
{
return m_fileId;
}
const std::string& File::GetUrl() const noexcept
{
return m_url;
}
uint64_t File::GetSizeInBytes() const noexcept
{
return m_sizeInBytes;
}
const std::unordered_map<HashType, std::string>& File::GetHashes() const noexcept
{
return m_hashes;
}