Reputation: 1892
I'm trying to open a file using open()
but I'm having a problem with the path. It seems like if the path starts with a forward-slash /
, it wont find the file, for example if path was /index.html
then it wont open, if it was index.html
then it works fine.
Is there any way to fix this? I don't want to parse the path because there might be several forward-slashes like in ///index.html
int fd = open(path, O_RDONLY);
Upvotes: 0
Views: 164
Reputation: 153840
If the path starts with a slash /
(a backslash looks like \
) the path is absolute and starts at the root of the file system. If it doesn't start with a slash, it is a relative path. It is unclear what you want to do but it seems you might need to remove leading slashes if you want the path to be relative.
Upvotes: 2