Jesus 'n Jim
A mainly PC (some Mac) site w/Software, Computer Repair Info, How-To's on Using Computers
Technical Support 1-360-521-2060 (my business line cell)

whereis(C)

 

whereis finds all the locations of a given filename (if you tell it to).
DOS version Uses UNIX style globbing (? to match single character, * to match 0 or more characters, [] for a set of characters or a range like [A-Z1357ab]), and VMS-style ... recurses into subdirectories.
Windows version uses -d to specify a single directory to start at and you can specify multiple files and ? and * are useable wildcards.
A list of paths is output in 2 columns: left hand column is the size in KiB, and the right hand column is the filepath.

Windows and DOS executeables and source code can be downloaded as a single whereis.zip file. It is under the GPL3 license. lsm file.

Download Now
whereis.zip (version 2.0, 3/13/2011)


03/14/2011  02:54 AM           465,632 whereis.zip

SHA512 whereis.zip
87711b44b858c013 9b66add527120444 1a95e78db4367a2a 0699dfcc7b3f6f93
488aa746474ec48d 2251a7ca5b2db5e5 09a410c7b7a2acc0 a32bc47e61289426

MD5 whereis.zip
eae92249d1513d39c9672a336dc51b15


boilerplate

gcc compiler note: -fpack-struct cannot be used with iostream or anything to do with libstdc++ (including locale which includes iostream) without getting lots of errors.

The dos version is compiled with DJ Delorie's djgpp (gcc for DOS). It can be obtained at DJDelorie.com/djgpp.

The windows version was compiled with mingw-w64. It is available at sf.net.

The GNU compiler set has the peculiar ability to glob filenames at the command line. this can be a nice or an unwanted feature. to get around it, aurround the * with double quotes "*". This includes DJGPP-generated and MinGW-generated code.


Copyright 2008 Jim Michaels

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.


When I wrote the DOS version I had to borrow directory tree walking code. I had to fix it because it used chdir() and that makes a mess out of your current working directory if you are trying to start from somewhere else. I found windows versions that also used chdir() and I didn't like it because it makes a mess. As a result, with the windows version I had to find different code or fix it. I am placing the code under GPL3 license, and I get the aded benefit of being able to search for filespecs in a specified subdirectory and process that file using a function.


DOS version

									
I used glob for dos because it is much more flexible.


C:\prj\whereis\WHEREI~1.1\dos>whereis
whereis - find files in specified subdirectories.
usage: whereis [-?] [-h[elp]] [-v[ersion]]
       whereis filepath [filepath [...]]

finds all the path locations of filenames on the current drive.
-h -help -? or no arguments gives this help.
This program does UNIX style globbing: http://www.delorie.com/djgpp/doc/libc/lib
c_426.html
? matches a single character
* matches 0 or more characters
use / in filepaths instead of \
anything between [] matches those characters as a single character or using - as
 a range like A-Z
... recurses into subdirectories VMS style
example: whereis  /mod/.../zippy*.h ./.../zippy.? searches \mod and current dire
ctory for zippy files.
example: whereis zippy.txt searches current directory for zippy.txt
copyright 2008,2009 Jim Michaels, under GPL3 license.

example:
C:\prj\whereis\wherereis-1.1\dos>whereis \prj\...\whereis*
0.10B   \prj\whereis
0.16B   \prj\whereis\whereis-1.1
16.48KB \prj\whereis\whereis-1.1\dos\whereis.c
94.21KB \prj\whereis\whereis-1.1\dos\whereis.exe
0.51B   \prj\whereis\whereis-1.1\whereis.lsm
15.50KB \prj\whereis\whereis-1.1\win\whereis.cpp
77.31KB \prj\whereis\whereis-1.1\win\whereis.exe
22.59KB \prj\whereis\whereis-1.1\win\whereis.obj
393.22KB        \prj\whereis\whereis-1.1\win\whereis.tds
79.56KB \prj\whereis\whereis.zip

C:\prj\whereis\wherereis-1.1\dos>whereis \prj\...\whereis* \u\...\l50*
0.10B   \prj\whereis
0.16B   \prj\whereis\whereis-1.1
16.48KB \prj\whereis\whereis-1.1\dos\whereis.c
94.21KB \prj\whereis\whereis-1.1\dos\whereis.exe
0.51B   \prj\whereis\whereis-1.1\whereis.lsm
15.50KB \prj\whereis\whereis-1.1\win\whereis.cpp
77.31KB \prj\whereis\whereis-1.1\win\whereis.exe
22.59KB \prj\whereis\whereis-1.1\win\whereis.obj
393.22KB        \prj\whereis\whereis-1.1\win\whereis.tds
79.56KB \prj\whereis\whereis.zip
0.94B   \u\l50.ASM
0.66B   \u\l50.asm.debug
0.54B   \u\l50.co
0.03B   \u\l50.exe
2.32KB  \u\l50.lst

C:\prj\whereis\wherereis-1.1\dos>whereis \u\...\l[25][50]*
1.06KB  \u\l25.asm
0.01B   \u\l25.co
0.03B   \u\l25.exe
0.94B   \u\l50.ASM
0.66B   \u\l50.asm.debug
0.54B   \u\l50.co
0.03B   \u\l50.exe
2.32KB  \u\l50.lst

C:\prj\whereis\wherereis-1.1\dos>

WINDOWS version

I used glob for dos because it is much more flexible.
now for the windows version. it is different and uses the windows search
facilities.





C:\prj\whereis\whereis-1.1\win>whereis
whereis - find files in specified subdirectories.
usage: whereis [-?] [-h[elp]] [-v[ersion]]
       whereis [-d[ir[ectory]] dirpath] file [file [...]]

finds all the path locations of filenames on the current drive.
-d dirpath specifies a base directory to start from.
-h -help -? or no arguments gives this help.
? matches a single character
* matches 0 or more characters
example: whereis -d c:\t zippy.*  searches c:\t for files with basename zippy.
example: whereis -d c:\windows\system32 *.exe *.dll *.ocx  searches system folde
r for executeables & ActiveX controls.
example: whereis zippy.txt searches current directory for zippy.txt
No copyright notice given, but I am putting one here nonetheless: directory walk
 function Copyright 2000 Michael D. Ober, modified/fixed by Jim Michaels
copyright 2008,2009 Jim Michaels, under GPL3 license.

C:\prj\whereis\whereris-1.1\win>whereis -d c:\prj *.lsm
TSE-Shell C:\prj\whereis\WHEREI~1.1\win>whereis -d c:\prj *.lsm
0.52B   c:\prj\bootsave\bootsave-1.1\bootsave.lsm
1.31KB  c:\prj\bracematcher\bracematcher-1.1\bracematcher.lsm
0.49B   c:\prj\contrib\squid-2.4.PRE-STABLE\auth_modules\MSNT\msntauth-v2.0.lsm
0.38B   c:\prj\contrib\ssmtp-2.38.7\ssmtp.lsm
0.57B   c:\prj\contrib\ssmtp-2.38.7\RCS\ssmtp.lsm,v
0.54B   c:\prj\createfile\createfile-3.7\createfile.lsm
0.68B   c:\prj\df\df-2.5\df.lsm
0.46B   c:\prj\dosvid\dosvid-1.1\dosvid.lsm
0.45B   c:\prj\du\du-1.1\du.lsm
0.51B   c:\prj\dxftopov\dxftopov-0.1.5\dxftopov.lsm
0.59B   c:\prj\extract512bytesfromfile\extract512bytesfromfile-1.1\extract512byt
esfromfile.lsm
0.52B   c:\prj\hibernate\hibernate-1.0\hibernate.lsm
0.48B   c:\prj\mbr\mbr-1.4\mbr.lsm
0.46B   c:\prj\md5\md5-1.0\md5.lsm
0.60B   c:\prj\menu6\menu-6.3\menu.lsm
0.50B   c:\prj\phone\phone-1.7\phone.lsm
0.50B   c:\prj\pwdgen\pwdgen-1.6\pwdgen.lsm
1.09KB  c:\prj\refocus\digikam-0.9.4\digikam.lsm
0.49B   c:\prj\sha512\sha512-1.0\sha512.lsm
0.69B   c:\prj\tbirdmailsplit\tbirdmailsplit-1.3\tbirdmailsplit.lsm
0.61B   c:\prj\uniq\uniq-1.1\uniq.lsm
0.51B   c:\prj\whereis\whereis-1.1\whereis.lsm
0.75B   c:\prj\which\which-1.4\which.lsm
0.50B   c:\prj\win32\randline-1.1\randline.lsm
0.50B   c:\prj\win32\randlinecenter-1.1\randlinecenter.lsm
0.81B   c:\prj\wipe\wipe-1.7\wipe.lsm
0.76B   c:\prj\zapdupes\zapdupes-1.2\zapdupes.lsm

C:\prj\whereis\wherereis-1.1\win>dir
 Volume in drive C is maxtor320
 Volume Serial Number is ACB2-51DD

 Directory of C:\prj\whereis\WHEREI~1.1\win

01/15/2009  10:40 PM    <DIR>          .
01/15/2009  10:40 PM    <DIR>          ..
12/29/2008  01:22 AM             4,182 bcc.cmd
01/15/2009  05:30 PM                44 build.cmd
10/03/2007  02:26 PM            35,147 gpl.txt
01/15/2009  10:40 PM            15,502 whereis.cpp
01/15/2009  10:40 PM            77,312 whereis.exe
01/15/2009  10:40 PM            22,594 whereis.obj
01/15/2009  10:40 PM           393,216 whereis.tds
               7 File(s)        547,997 bytes
               2 Dir(s)  91,446,489,088 bytes free

C:\prj\whereis\wherereis-1.1\win>whereis *.cpp
15.50KB .\whereis.cpp

C:\prj\whereis\wherereis-1.1\win>

---------------------------------------------------------------------------