Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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;

This will extract the faDirectory bit and you dont have to worry about the compression bit set or not.

if ((sr.Attr AND faDirectory) <> 0) then

begin 
     .......
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top