Merge branch 'bugfix/default_vfs_paths' into 'master'
Make relative paths match the default VFS, if provided See merge request !913
This commit is contained in:
commit
ff6a3b1a11
|
@ -197,6 +197,8 @@ TEST_CASE("vfs parses paths correctly", "[vfs]")
|
||||||
test_dir_opened(&inst_foobar, "/foo/bar/file");
|
test_dir_opened(&inst_foobar, "/foo/bar/file");
|
||||||
inst_toplevel.match_path = "/tmp/foo";
|
inst_toplevel.match_path = "/tmp/foo";
|
||||||
test_opened(&inst_toplevel, "/tmp/foo");
|
test_opened(&inst_toplevel, "/tmp/foo");
|
||||||
|
inst_toplevel.match_path = "foo";
|
||||||
|
test_opened(&inst_toplevel, "foo");
|
||||||
|
|
||||||
TEST_ESP_OK( esp_vfs_unregister("/foo") );
|
TEST_ESP_OK( esp_vfs_unregister("/foo") );
|
||||||
TEST_ESP_OK( esp_vfs_unregister("/foo1") );
|
TEST_ESP_OK( esp_vfs_unregister("/foo1") );
|
||||||
|
|
|
@ -142,6 +142,11 @@ static const vfs_entry_t* get_vfs_for_path(const char* path)
|
||||||
memcmp(path, vfs->path_prefix, vfs->path_prefix_len) != 0) {
|
memcmp(path, vfs->path_prefix, vfs->path_prefix_len) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// this is the default VFS and we don't have a better match yet.
|
||||||
|
if (vfs->path_prefix_len == 0 && !best_match) {
|
||||||
|
best_match = vfs;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// if path is not equal to the prefix, expect to see a path separator
|
// if path is not equal to the prefix, expect to see a path separator
|
||||||
// i.e. don't match "/data" prefix for "/data1/foo.txt" path
|
// i.e. don't match "/data" prefix for "/data1/foo.txt" path
|
||||||
if (len > vfs->path_prefix_len &&
|
if (len > vfs->path_prefix_len &&
|
||||||
|
|
Loading…
Reference in a new issue