-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.h
More file actions
59 lines (44 loc) · 1.19 KB
/
Copy pathhelpers.h
File metadata and controls
59 lines (44 loc) · 1.19 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
#ifndef HELPERS_H
#define HELPERS_H
#include <string>
#include <vector>
#include "socket.h"
#ifdef _WIN32
#include <Windows.h>
#endif
#ifdef __unix__
#include <sys/types.h>
#include <sys/wait.h>
using PROCESS_INFORMATION = pid_t;
using HANDLE = int;
#endif
namespace helpers
{
struct ProcessDescripor
{
PROCESS_INFORMATION process;
#ifdef _WIN32
STARTUPINFO si;
#endif
};
struct SharedMemoryDescriptor
{
HANDLE handle;
std::string name;
void* memory;
size_t size;
};
template<typename T>
constexpr typename std::underlying_type<T>::type integral(T value)
{
return static_cast<typename std::underlying_type<T>::type>(value);
}
void preallocateFile(const std::string& file, size_t size);
int getMaxSocketDescriptor(const std::vector<Socket*>& sockets);
ProcessDescripor createProcess(const std::string& executable, std::vector<std::string> args);
void waitProcess(ProcessDescripor& descriptor);
SharedMemoryDescriptor createSharedMemory(size_t size, const std::string& name);
SharedMemoryDescriptor openSharedMemory(size_t size, const std::string& name);
void removeSharedMemory(SharedMemoryDescriptor& desc);
}
#endif