views:

172

answers:

3

When searching for files with FindFirst() I get an attribute value in the TSearchRec.Attr field of 2080. It is not specified in the help as there are only these values available and no combination of them yields 2080:

1 faReadOnly
2 faHidden
4 faSysFile
8 faVolumeID
16 faDirectory
32 faArchive
64 faSymLink
71 faAnyFile

Does anyone know what 2080 means and why I get that attribute value? The OS is XP embedded.

+6  A: 

It turns out that the file found by FindFirst() was compressed and thus had the compressed bit set. Took me a while to figure out and I could not find a reference on the web that stated the actual value of TSearchRec.Attr when the compressed bit is set. Unclicking "Compress file" in the files advanced properties did the trick.

Niklas Winde
Note that it is allowed to accept your own answer...
Jeroen Pluimers
Patience, Jeroen. There's a two-day waiting period before you're allowed to do that, as I understand it.
Rob Kennedy
Just learned something new today. Thanks!--jeroen
Jeroen Pluimers
+3  A: 

In JclFileUtils unit from Jedi Code Library I found:

faNormalFile        = $00000080;
...
faNotContentIndexed = $00002000;

If 2080 is in hex then this is it.

Look also at: http://www.tek-tips.com/viewthread.cfm?qid=1543818&page=9

EDIT: While 2080 id decimal, and 2080 dec = 820 hex then attributes are combination of:

 faArchive     = $00000020;
 faCompressed  = $00000800;
Michał Niklas
It's not hex, it's just an integer. But thanks for the link, it was useful!
Niklas Winde
+4  A: 

Attributes in TSearchRec map directly to the Windows file attributes used with the TWin32FindData record from FindFirstFile.

In hex (always render bit fields in hex, not decimal), 2080 is $0820, where it's clear there are two bits set. The lower bit corresponds to File_Attribute_Archive, or Delphi's faArchive, and the upper bit corresponds to File_Attribute_Compressed. It has no equivalent in the units that come with Delphi, but you can use the JclFileUtils.faCompressed symbol from the JCL.

Rob Kennedy