Article View: borland.public.cppbuilder.nativeapi
Article #227Re: Determining an files true type
From: Bob Gonder
Date: Tue, 15 Jul 2008 00:14
Date: Tue, 15 Jul 2008 00:14
42 lines
2692 bytes
2692 bytes
Mike Collins wrote:
>Got a bit of a conceptual question here. I have a piece of code that
>performs a recursive search of the users hard disk and generates a list of
>files. Nothing new here. My code is based around the FindFirstFile /
>FindNextFile API's. From what I can see, there doesn't seem to be a way to
>specify a wildcard search mask i.e. *.exe so it seems necessary to check for
>.exe extension within the search, which I do like this:
I use "*.exe" just fine.
What problem are you having with it?
This bit from one of my apps:
* do all files for this directory */
void AddNewFiles(const char*Directory,const char* ext)
{ HANDLE ff;
WIN32_FIND_DATA fblk;
char filename[MAXPATH];
sprintf(filename,"%s*.%s",Directory,ext);
ff=FindFirstFile(filename,&fblk);
>C:\WINDOWS\Installer\$PatchCache$\Managed\9040110900063D11C8EF10054038389C\11.0.5614\SCANOST.EXE_1033
>
>when I examine the properties, they appear as executable files (although
>they appear to be back-ups and are not executable). Based on this, I was
>wondering what the best option is to truly determine a executable?
>
>My first thoughts are to just ignore them as they are not executable
>per-say, but i'm interested in how the dir commend determines there file
>type. Simply looking for ".exe" in the file name would not work because it
>is possible to have a text document with the name "textfile.exe.txt".
The file type is the *last-dotted-item*
So your example is still type .txt, even with .exe embeded.
More relevant would be if you thought data.hexed was an exe.
I think if you used "*.exe" in your FFF, you would also be
presented with .EXE_1033, but your current code is more
stringent with it's AnsiCompareIC(".exe") rejecting it.
Technical Details
Message-ID:
<smpn74968j0hh99lggbsq0sapaca7g55l7@4ax.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.isoc.lu!newsgroups.borland.com!not-for-mailReferences:
<487bd893@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,179fe31b934cb3c9 X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <none@nowhere.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Determining an files true type Date: Mon, 14 Jul 2008 17:14:16 -0700 Message-ID: <smpn74968j0hh99lggbsq0sapaca7g55l7@4ax.com> References: <487bd893@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.147.31 X-Trace: newsgroups.borland.com 1216080854 67.77.147.31 (14 Jul 2008 17:14:14 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.isoc.lu!newsgroups.borland.com!not-for-mail