-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
system.h
124 lines (104 loc) · 4.8 KB
/
system.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
// system.h - system interface
//
// leccore library, part of the liblec library
// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
//
// Released under the MIT license. For full details see the
// file LICENSE.txt
//
#pragma once
#if defined(LECCORE_EXPORTS)
#include "leccore.h"
#else
#include <liblec/leccore.h>
#endif
#include <string>
#include <vector>
namespace liblec {
namespace leccore {
/// <summary>Class for getting the path to known user folders.</summary>
/// <remarks>If the path doesn't exist, an attempt will be made to create it.
/// An empty string is returned if there is an error.
/// </remarks>
class leccore_api user_folder {
public:
/// <summary>Get the user's home directory.</summary>
/// <returns>The home directory.</returns>
static const std::string home();
/// <summary>Get the user's document directory.</summary>
/// <returns>The documents directory.</returns>
static const std::string documents();
/// <summary>Get the user's downloads directory.</summary>
/// <returns>The downloads directory.</returns>
static const std::string downloads();
/// <summary>Get the user's desktop directory.</summary>
/// <returns>The desktop directory.</returns>
static const std::string desktop();
/// <summary>Get the user's music directory.</summary>
/// <returns>The music directory.</returns>
static const std::string music();
/// <summary>Get the user's videos directory.</summary>
/// <returns>The videos directory.</returns>
static const std::string videos();
/// <summary>Get the user's pictures directory.</summary>
/// <returns>The pictures directory.</returns>
static const std::string pictures();
/// <summary>Get the user's local appdata directory.</summary>
/// <returns>The appdata directory.</returns>
static const std::string local_appdata();
/// <summary>Get the path to the folder designated for temporary files.</summary>
/// <returns>The temporary files directory.</returns>
static const std::string temp();
};
/// <summary>Command line arguments parser.</summary>
class leccore_api commandline_arguments {
public:
/// <summary>Get command line arguments.</summary>
/// <returns>The list of arguments/tokens.</returns>
static const std::vector<std::string>& get();
/// <summary>Check whether a given token is in the list of arguments.</summary>
/// <param name="token">The token to check.</param>
/// <returns>Returns true if the token is in the list, else false.</returns>
static bool contains(const std::string& token);
private:
class impl;
};
/// <summary>Shell helper class.</summary>
class leccore_api shell {
public:
/// <summary>Open a resource using the Operating System default action, equivalent to a double click action.</summary>
/// <param name="path">The path to the resource, e.g. "C:\", "C:\Files\MyFile.pdf" or "https://github.com/alecmus/leccore".</param>
/// <param name="error">Error information.</param>
/// <returns>Returns true if the operation is successful, else false.</returns>
static const bool open(const std::string& path, std::string& error);
/// <summary>View the location a file or folder in File Explorer.</summary>
/// <param name="path">The path to the file or folder, e.g. "C:\", "C:\Files\MyFile.pdf" or "C:\Files".</param>
/// <param name="error">Error information.</param>
/// <returns>Returns true if the operation is successful, else false.</returns>
/// <remarks>Opens the folder containing the file or folder, with the file or folder selected.</remarks>
static const bool view(const std::string& path, std::string& error);
/// <summary>Create a process.</summary>
/// <param name="fullpath">The full path to the executable file.</param>
/// <param name="args">The list of command-line arguments.</param>
/// <param name="error">Error information.</param>
/// <returns>Returns true if the operation is successful, else false.</returns>
static const bool create_process(const std::string& fullpath,
const std::vector<std::string>& args, std::string& error);
};
/// <summary>Clipboard class.</summary>
class leccore_api clipboard {
public:
/// <summary>Set clipboard text.</summary>
/// <param name="text">The text to copy to the clipboard.</param>
/// <param name="error">Error information.</param>
/// <returns>Returns true if the operation is successful, else false.</returns>
static const bool set_text(const std::string& text, std::string& error);
/// <summary>Get text from the clipboard.</summary>
/// <param name="text">The text copied from the clipboard.</param>
/// <param name="error">Error information.</param>
/// <returns>Returns true if the operation is successful, else false.</returns>
static const bool get_text(std::string& text, std::string& error);
};
}
}