sharkdp / fd

A simple, fast and user-friendly alternative to 'find'
Apache License 2.0
34.06k stars 818 forks source link

Support searching in AVFS #1572

Open CarlOlson opened 5 months ago

CarlOlson commented 5 months ago

A Virtual File System is a common way to access archives as a filesystem. Currently I don't know of any tool that will find files inside archives inside a mounted avfs folder. With many package managers using archives it would be helpful to find files inside archives with fd.

Example:

$ mountavfs
Mounting AVFS on /home/<user>/.avfs...

$ fd <file> ~/.avfs/home/<user>/dir
/home/<user>/.avfs/home/<user>/dir/archive.zip#/dir/<file>

I'd expect fd to check the filesystem of the directory. If it is avfs then it would search inside archives with the #/ suffix.

Currently fd will only search if started inside an archive with a folder:

$ fd <file> ~/.avfs/home/<user>/dir/archive.zip#/

$ fd <file> ~/.avfs/home/<user>/dir/archive.zip#/dir
/home/<user>/.avfs/home/<user>/dir/archive.zip#/dir/<file>
tavianator commented 5 months ago

Hmm, in my experience it's slightly different:

tavianator@graphene $ fd ioq .avfs/home/tavianator/Downloads
tavianator@graphene $ fd ioq .avfs/home/tavianator/Downloads/bfs-3.2.tar.gz\#
.avfs/home/tavianator/Downloads/bfs-3.2.tar.gz#/bfs-3.2/src/ioq.c
.avfs/home/tavianator/Downloads/bfs-3.2.tar.gz#/bfs-3.2/src/ioq.h
.avfs/home/tavianator/Downloads/bfs-3.2.tar.gz#/bfs-3.2/tests/ioq.c
tavianator@graphene $ fd ioq .avfs/home/tavianator/Downloads/bfs-3.2.tar.gz\#/bfs-3.2
.avfs/home/tavianator/Downloads/bfs-3.2.tar.gz#/bfs-3.2/src/ioq.c
.avfs/home/tavianator/Downloads/bfs-3.2.tar.gz#/bfs-3.2/src/ioq.h
.avfs/home/tavianator/Downloads/bfs-3.2.tar.gz#/bfs-3.2/tests/ioq.c

This happens because the ...# virtual directories don't show up in a directory listing (e.g. with ls .avfs/...). It's theoretically possible for fd to special-case AVFS and add the ...# entries itself, but I don't think it's worth it.