Failing to open a text file on Linux but on Windows it works

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
¿are you using slashes `/' ?
hello n555. Yes sir I am, specifically "/"
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
$ ls resources/
Last edited on
Excellent! Thanks ne555, that did the trick!
Topic archived. No new replies allowed.