-
Notifications
You must be signed in to change notification settings - Fork 1
/
JunctionPoint.h
51 lines (43 loc) · 1.71 KB
/
JunctionPoint.h
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
#pragma once
#include <functional>
#include <string>
#include <memory>
#include <cstdint>
class JunctionPoint {
private:
struct ReparseDataBuffer {
uint32_t ReparseTag;
uint16_t ReparseDataLength;
uint16_t Reserved;
struct {
uint16_t SubstituteNameOffset;
uint16_t SubstituteNameLength;
uint16_t PrintNameOffset;
uint16_t PrintNameLength;
wchar_t PathBuffer[1];
} MountPointReparseBuffer;
static std::pair<std::unique_ptr<ReparseDataBuffer, std::function<void(void*)>>, size_t> CreateMountPoint(std::wstring_view substituteName, std::wstring_view printName);
};
public:
static void Mount(std::wstring_view junctionPoint, std::wstring_view targetDir);
static void Create(std::wstring_view junctionPoint, std::wstring_view targetDir);
static void Unmount(std::wstring_view junctionPoint);
static void Delete(std::wstring_view junctionPoint);
static bool IsJunctionPoint(std::wstring_view path);
private:
std::wstring junctionPoint;
public:
JunctionPoint() noexcept = default;
JunctionPoint(const JunctionPoint& other) noexcept = default;
JunctionPoint(std::wstring_view junctionPoint) noexcept;
JunctionPoint(std::wstring&& junctionPoint) noexcept;
JunctionPoint(JunctionPoint&& other) noexcept;
JunctionPoint& operator=(const JunctionPoint& other) noexcept;
JunctionPoint& operator=(JunctionPoint&& other) noexcept;
std::wstring& operator*() noexcept;
void MountFor(std::wstring_view targetDir) const;
void CreateFor(std::wstring_view targetDir) const;
void Unmount() const;
void Delete() const;
void RemountFor(std::wstring_view targetDir) const;
};