Sep 27, 2020 at 9:04pm Sep 27, 2020 at 9:04pm UTC
I'm trying to open a text file and it's opening perfectly on Windows, but on Linux I'm getting a "No such file or directory".
My project structure is as the following:
- project
----> builds/debug/executable
----> engine/src
----> game
----> ----> src
----> ----> resources (found on windows, but not linux)
On Windows, as long as the resources folder is in the same folder where the game's source folder, it opens.
But on Linux, no mater where I move the resources folder, it never finds. Not sure how Linux manages that and what's my best option.
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
void Assets::LoadShader(const char * name, const char * vertexSrc, const char * fragSrc) {
std::ifstream vShaderFile;
std::ifstream fShaderFile;
vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
try {
vShaderFile.open(vertexSrc);
fShaderFile.open(fragSrc);
std::stringstream vShaderStream, fShaderStream;
std::string vertexCodeStr, fragCodeStr;
vShaderStream << vShaderFile.rdbuf();
fShaderStream << fShaderFile.rdbuf();
vShaderFile.close();
fShaderFile.close();
}
catch (std::ifstream::failure& _e) {
std::cout << "Assets: Error Loading File: " << strerror(errno) << std::endl;
}
}
I've tried moving the folder to where the executable is, also where all the projects are...but nothing :(
Last edited on Sep 27, 2020 at 9:06pm Sep 27, 2020 at 9:06pm UTC
Sep 27, 2020 at 9:29pm Sep 27, 2020 at 9:29pm UTC
¿are you using slashes `/' ?
Sep 27, 2020 at 9:32pm Sep 27, 2020 at 9:32pm UTC
hello n555. Yes sir I am, specifically "/"
Sep 27, 2020 at 9:44pm Sep 27, 2020 at 9:44pm UTC
paths are relative to the current working directory
1 2 3 4 5 6 7 8 9
#include <unistd.h>
#include <iostream>
int main(){
char current_working_directory[1000];
getcwd(current_working_directory, sizeof (current_working_directory));
std::cout << "CWD: " << current_working_directory << '\n' ;
//...
}
also show the content of `vertexSrc', `fragSrc' and the output of the command
Last edited on Sep 27, 2020 at 9:48pm Sep 27, 2020 at 9:48pm UTC
Sep 27, 2020 at 10:11pm Sep 27, 2020 at 10:11pm UTC
Excellent! Thanks ne555, that did the trick!