-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigInfo.cpp
More file actions
90 lines (86 loc) · 1.88 KB
/
ConfigInfo.cpp
File metadata and controls
90 lines (86 loc) · 1.88 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// Created by Alex on 10/26/2016.
//
#include "ConfigInfo.h"
#include "all_inlcudes.h"
ConfigInfo::ConfigInfo()
{
setRawPath(CONFIG_FILE_NAME);
setDriveLetter();
buildFullPath();
}
//SET==================================================
void ConfigInfo::setRawPath(string pConfigPath)
{
rawPath = findRawPath(pConfigPath);
}
void ConfigInfo::setDriveLetter()
{
driveLetter = findDriveLetter();
}
//GET==================================================
string ConfigInfo::getRawPath()
{
return rawPath;
}
char ConfigInfo::getDriveLetter()
{
return driveLetter;
}
//MISC OF CLASS========================================
string ConfigInfo::buildFullPath()
{
string drive = "";
drive += getDriveLetter();
return drive + ":\\" + getRawPath();
}
//MISC=================================================
bool doesPathExist(string pPath)
{
bool output = false;
DWORD path = GetFileAttributesA(pPath.c_str());
if (path != INVALID_FILE_ATTRIBUTES)
{
if (path & FILE_ATTRIBUTE_DIRECTORY)
{
//path exist
output = true;
}
}
return output;
}
bool doesFileExist(string pPath)
{
ifstream output(pPath.c_str());
return output.good();
}
string findRawPath(string pPath)
{
string output = " ";
ifstream input(pPath.c_str());
if (input.is_open())
{
cout << "its opened" << endl;
input >> output;
size_t pos = CONFIG_WORKSPACE_PARAM.length();
output.erase(0, pos);
}
return output;
}
char findDriveLetter()
{
char output[255];
_getcwd(output,255);
return output[0];
}
bool createConfig(string pPath)
{
bool out = false;
ofstream output("config.conf");
if (output.is_open()) {
output << CONFIG_WORKSPACE_PARAM << pPath;
output.close();
out = true;
}
return out;
}