Skip to content

Commit a907bae

Browse files
author
Santiago
committed
indent with tabs
1 parent 5837326 commit a907bae

File tree

2 files changed

+65
-65
lines changed

2 files changed

+65
-65
lines changed

src/PathUtils.cpp

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,88 +5,88 @@
55

66
namespace PathUtils
77
{
8-
std::string programDirectory;
9-
std::string assetsDirectory;
8+
std::string programDirectory;
9+
std::string assetsDirectory;
1010
}
1111

1212
void PathUtils::SetProgramDirectory(const std::string& executableFilePath)
1313
{
14-
programDirectory = GetFolderPath(executableFilePath);
15-
assetsDirectory = programDirectory + "assets/";
16-
if (!std::filesystem::exists(assetsDirectory))
17-
{
18-
// asset directory is different when launching from visual studio
19-
std::string parent = programDirectory;
20-
parent = GetFolderPath(parent.substr(0, parent.length() - 1));
21-
parent = GetFolderPath(parent.substr(0, parent.length() - 1));
22-
parent = GetFolderPath(parent.substr(0, parent.length() - 1));
14+
programDirectory = GetFolderPath(executableFilePath);
15+
assetsDirectory = programDirectory + "assets/";
16+
if (!std::filesystem::exists(assetsDirectory))
17+
{
18+
// asset directory is different when launching from visual studio
19+
std::string parent = programDirectory;
20+
parent = GetFolderPath(parent.substr(0, parent.length() - 1));
21+
parent = GetFolderPath(parent.substr(0, parent.length() - 1));
22+
parent = GetFolderPath(parent.substr(0, parent.length() - 1));
2323

24-
assetsDirectory = parent + "assets/";
25-
}
26-
if (!std::filesystem::exists(assetsDirectory))
27-
std::cout << "[Path utils] Warning, could not locate assets folder\n";
28-
else
29-
std::cout << "[Path utils] Assets directory set to: " << assetsDirectory << std::endl;
24+
assetsDirectory = parent + "assets/";
25+
}
26+
if (!std::filesystem::exists(assetsDirectory))
27+
std::cout << "[Path utils] Warning, could not locate assets folder\n";
28+
else
29+
std::cout << "[Path utils] Assets directory set to: " << assetsDirectory << std::endl;
3030
}
3131

3232
const std::string& PathUtils::GetProgramDirectory()
3333
{
34-
return programDirectory;
34+
return programDirectory;
3535
}
3636

3737
const std::string& PathUtils::GetAssetsDirectory()
3838
{
39-
return assetsDirectory;
39+
return assetsDirectory;
4040
}
4141

4242
std::string PathUtils::GetRelativePath(const std::string& fileRelativeTo, const std::string& targetPath)
4343
{
44-
std::string out = "";
44+
std::string out = "";
4545

46-
std::vector<std::string> pathA, pathB;
46+
std::vector<std::string> pathA, pathB;
4747

48-
int i = fileRelativeTo.length() - 1, iEnd = fileRelativeTo.length();
49-
int j = targetPath.length() - 1, jEnd = targetPath.length();
50-
while (i > -1)
51-
{
52-
if (fileRelativeTo[i] == '/' || fileRelativeTo[i] == '\\')
53-
{
54-
pathA.insert(pathA.begin(), fileRelativeTo.substr(i + 1, iEnd - i - 1));
55-
iEnd = i;
56-
}
57-
i--;
58-
}
59-
while (j > -1)
60-
{
61-
if (targetPath[j] == '/' || targetPath[j] == '\\')
62-
{
63-
pathB.insert(pathB.begin(), targetPath.substr(j + 1, jEnd - j - 1));
64-
jEnd = j;
65-
}
66-
j--;
67-
}
48+
int i = fileRelativeTo.length() - 1, iEnd = fileRelativeTo.length();
49+
int j = targetPath.length() - 1, jEnd = targetPath.length();
50+
while (i > -1)
51+
{
52+
if (fileRelativeTo[i] == '/' || fileRelativeTo[i] == '\\')
53+
{
54+
pathA.insert(pathA.begin(), fileRelativeTo.substr(i + 1, iEnd - i - 1));
55+
iEnd = i;
56+
}
57+
i--;
58+
}
59+
while (j > -1)
60+
{
61+
if (targetPath[j] == '/' || targetPath[j] == '\\')
62+
{
63+
pathB.insert(pathB.begin(), targetPath.substr(j + 1, jEnd - j - 1));
64+
jEnd = j;
65+
}
66+
j--;
67+
}
6868

69-
i = 0; j = 0;
70-
while (pathA[i].compare(pathB[j]) == 0) { i++; j++; }
69+
i = 0; j = 0;
70+
while (pathA[i].compare(pathB[j]) == 0) { i++; j++; }
7171

72-
while (i < pathA.size() - 1)
73-
{
74-
out += "../";
75-
i++;
76-
}
77-
while (j < pathB.size())
78-
{
79-
out += pathB[j];
80-
if (j != pathB.size() - 1)
81-
out += '/';
82-
j++;
83-
}
84-
return out;
72+
while (i < pathA.size() - 1)
73+
{
74+
out += "../";
75+
i++;
76+
}
77+
while (j < pathB.size())
78+
{
79+
out += pathB[j];
80+
if (j != pathB.size() - 1)
81+
out += '/';
82+
j++;
83+
}
84+
return out;
8585
}
8686

8787
std::string PathUtils::GetFolderPath(const std::string& filePath)
8888
{
89-
int i = filePath.length() - 1;
90-
for (; i > -1 && filePath[i] != '/' && filePath[i] != '\\'; i--) {};
91-
return filePath.substr(0, i + 1);
89+
int i = filePath.length() - 1;
90+
for (; i > -1 && filePath[i] != '/' && filePath[i] != '\\'; i--) {};
91+
return filePath.substr(0, i + 1);
9292
}

src/Utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
std::wstring Utils::Utf8ToWstring(const std::string& str)
88
{
9-
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
10-
return myconv.from_bytes(str);
9+
std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
10+
return myconv.from_bytes(str);
1111
}
1212

1313
void Utils::SetWindowIcon(const std::string& path, GLFWwindow* window)
1414
{
15-
GLFWimage images[1];
16-
images[0].pixels = stbi_load(path.c_str(), &images[0].width, &images[0].height, 0, 4); //rgba channels
17-
glfwSetWindowIcon(window, 1, images);
18-
stbi_image_free(images[0].pixels);
15+
GLFWimage images[1];
16+
images[0].pixels = stbi_load(path.c_str(), &images[0].width, &images[0].height, 0, 4); //rgba channels
17+
glfwSetWindowIcon(window, 1, images);
18+
stbi_image_free(images[0].pixels);
1919
}

0 commit comments

Comments
 (0)