glocalvfs: Create a dummy file for g_file_new_for_path("")

`""` is not a valid path (`stat()` on it returns `ENOENT`). Previously,
a full `GLocalFile` was being created, which ended up resolving to
`$CWD`, through path canonicalisation. That isn’t right.

Fix it by creating a `GDummyFile` instead, and adding a unit test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Fixes: #2328
This commit is contained in:
Philip Withnall
2021-03-10 19:10:38 +00:00
parent 628e1c5893
commit d52728f994
2 changed files with 25 additions and 1 deletions

View File

@@ -80,7 +80,10 @@ static GFile *
g_local_vfs_get_file_for_path (GVfs *vfs,
const char *path)
{
return _g_local_file_new (path);
if (*path == '\0')
return _g_dummy_file_new (path);
else
return _g_local_file_new (path);
}
static GFile *