[WCX] Add constants for file attributes

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

[WCX] Add constants for file attributes

Post by *Dalai »

Hi there :).

While working with the WCX interface I came across the file attributes that can be set in ReadHeader(Ex) functions. I wanted to use them and was stumped when I realized that there are no constants defined for them!

I strongly recommend to add some constants for these to the WCX interface definition because using magic numbers instead of properly named constants is bad (and not recommended). This is what I've added to my definition:

Code: Select all

const
  PK_ATTR_READONLY  = $1;
  PK_ATTR_HIDDEN    = $2;
  PK_ATTR_SYSTEM    = $4;
  PK_ATTR_VOLID     = $8;
  PK_ATTR_DIRECTORY = $10;
  PK_ATTR_ARCHIVE   = $20;
  PK_ATTR_ANYFILE   = $3F;
For C++ this would probably something like this:

Code: Select all

#define PK_ATTR_READONLY  0x1
#define PK_ATTR_HIDDEN    0x2
#define PK_ATTR_SYSTEM    0x4
#define PK_ATTR_VOLID     0x8
#define PK_ATTR_DIRECTORY 0x10
#define PK_ATTR_ARCHIVE   0x20
#define PK_ATTR_ANYFILE   0x3F
Feel free to use them if you want.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [WCX] Add constants for file attributes

Post by *ghisler(Author) »

There is no need, because TC uses the standard constants from FindFirstFile. You can find an overview here:
https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WCX] Add constants for file attributes

Post by *Dalai »

Oh, OK. Well, then it's probably a good idea to state this fact in the WCX interface description, or better yet, to add these constants to the interface description so developers don't have to look them up somewhere else.

[EDIT]
The value 0x8 (Volume ID file) isn't mentioned in the MS docs.
[/EDIT]

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [WCX] Add constants for file attributes

Post by *ghisler(Author) »

You should not set the volume id attribute. It was used for the volume id in the root of a drive, but FindFirstFile no longer reports any volume ids this way.
Author of Total Commander
https://www.ghisler.com
Post Reply