Chris Gehlker wrote:
I guess efs doesn’t really have anything like that either, now that you
mention it. From a given file of directory you can trace up the file
hierarchy because you have that information encoded in it’s full path name
but you can’t search down the hierarchy without using the expensive method
that find is using. I remember that efs didn’t have aliases and symlinks
aren’t the same thing.
I want to caveat my earlier message about slocate. It does build this
index, but it is particular to Linux installations. I mean, I’m sure that
you could easily compile and install it on any nx-ish OS, but you won’t
find it there commonly, so it probably won’t be of any use to you.
A further speedbump:
All of this talk about i-nodes and filesystems illustrates the fact that
there isn’t a portable way to do what you want, because there are at least
three /commonly/ used filesystems on Linux, another three for the rest of
the Unix world, and probably yet another three for the other common OSes.
This isn’t counting network FSes.
Basically yes. There is API for treating the filesystem as a database.
Sherlock exposes this API to the user but any app can use it as well.
And OS/X doesn’t provide a command-line interface to this API?
By the way, I’m curious: I was a long-time NeXTSTEP user. Under NeXTSTEP,
‘find / -name *.app’ wouldn’t do what you wanted it to. Not all
applications under NeXT were packaged as 'app’s; for example, you’d miss
all of the applications in /bin. Are /all/ executables suffixed by 'app’
in OS/X? If not, you’d need something else from find, probably:
find / -type f -perm +1
which, even then, probably wouldn’t work, because people aren’t careful
about their permissions. A short search on my machine turned up a bunch of
QT header files :-/
It occurs to me as I’m writing this that it might be possible for Ruby to
use the /fastest/ underlying search mechanism. Something like:
class Locate
METHODS = [ ‘linux’, ‘macos’, ‘windows’ ]
def initialize
METHODS.each do | platform, method |
if RUBY_PLATFORM =~ /#{platform}/i
instance_eval "alias :locate #{method}"
break
end
end
instance_eval "alias :locate :find" unless defined? locate
end
def linux(*args, &block)
`locate #{args.to_s}`.split("\n").each(&block)
end
def macos(*args, &block)
`clisherloc #{args.to_s}`.split("\n").each(&block)
end
#...
end