(slightly) extended 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

OliverPA
Junior Member
Junior Member
Posts: 20
Joined: 2004-01-24, 18:04 UTC
Location: Vienna, Austria

(slightly) extended file attributes

Post by *OliverPA »

I use hardlinks and reparse point a lot, so I often need to know whether a certain file has more than one instance. TC only displays such information for reparse points, but not for hardlinks.

This content plugin formats the usual file attributes just like the internal plugin but also features two additional fields: rahscel0
ie. read-only / archive / hidden / system file / compressed / encrypted / link (hardlink or reparse point) / 0 sparse file

It'd be swell if these could be supported internally by one of the future versions of TC, especially as the code is quite simple:

Code: Select all

HANDLE hf = INVALID_HANDLE_VALUE;
BY_HANDLE_FILE_INFORMATION bhfi = { 0 };

if((hf = CreateFile(FileName, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING,
  FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE ||
  GetFileInformationByHandle(hf, &bhfi) == FALSE)
{
  CloseHandle(hf);
  return ft_fileerror;
}

char sattr[4 + 4 + 1] = {
  bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY ? sattr[0] = 'r' : '-',
  bhfi.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE ? sattr[1] = 'a' : '-',
  bhfi.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN ? sattr[2] = 'h' : '-',
  bhfi.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM ? sattr[3] = 's' : '-'
};
size_t iattrex = strlen(sattr);

if(bhfi.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) sattr[iattrex++] = 'c';
if(bhfi.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) sattr[iattrex++] = 'e';
if(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
  if(bhfi.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) sattr[iattrex++] = 'l';
}else {
  if(bhfi.nNumberOfLinks > 1) sattr[iattrex++] = 'l';
}
if(bhfi.dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE) sattr[iattrex++] = '0';

strlcpy((char*)FieldValue,sattr,maxlen-1);
CloseHandle(hf);
Download the files (including source) here.
User avatar
van Dusen
Power Member
Power Member
Posts: 684
Joined: 2004-09-16, 19:30 UTC
Location: Sinzig (Rhein), Germany

Post by *van Dusen »

2OliverPA
Thank you for this quite useful plugin. You've declared it as sample plugin, I know. Maybe you're interested in any comments anyway :) :

* Doesn't works with Win98SE (empty ExtAttr-column, even by FAT32 provided flags are not visible). But works with WinXP HE SP1 at least (hence, no chance to test encryption-flag... don't know, if option for sparse files is available for WinXP HE, so I didn't test "0"-flag)

* If you're making a hard link (I've used NTFSlinks from within TC for testing), the source panel isn't refreshed automatically ("Link"-flag "l" isn't shown immediately for linked file). This is seemingly a restriction of TC and not of your sample plugin (same bug as for any other user defined colums, like descript.ion- or global.diz-comments for instance)

* I support yor suggestion to make these flags available internally
icfu
Power Member
Power Member
Posts: 6052
Joined: 2003-09-10, 18:33 UTC

Post by *icfu »

Thanks for this plugin, unfortunately I have missed it at the time of release. :)

Icfu
This account is for sale
theosdikaios
Senior Member
Senior Member
Posts: 228
Joined: 2006-02-04, 13:02 UTC

Post by *theosdikaios »

Nice plugin. :)
Can a programer extend this plugin with an additional column "number of hardlinks"?

Do somebody knows a program for exploring hardlinks? I'm looking for a tool what finds all hardlinks to a "inode" i.e. a list of file names with the same MFT-entry.

TIA.
"Since there are many things which have never happened and never will happen,
and which nevertheless are clearly conceivable, and imply no contradiction,
how can one say they are absolutely impossible?" Leibniz
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

Use NTFS Links plugin. It shows those numbers.
F6, Enter, Tab, F6, Enter, Tab, F6, Enter, Tab... - I like to move IT, move IT!..
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

XPEHOPE3KA
NTFS Links is not a plugin, it's a program for creating hard and symbolic links. :) The plugin you're talking about is NL_Info.

theosdikaios
Do somebody knows a program for exploring hardlinks? I'm looking for a tool what finds all hardlinks to a "inode" i.e. a list of file names with the same MFT-entry.
Try PHM PowerToys.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

Flint wrote:NTFS Links is not a plugin, it's a program for creating hard and symbolic links. :) The plugin you're talking about is NL_Info.
O-o-p-s. Sorry.
theosdikaios
Senior Member
Senior Member
Posts: 228
Joined: 2006-02-04, 13:02 UTC

Post by *theosdikaios »

Thanks for all hints. :)

Maybe we can have a support of hardlinks integrated in TC functions like
- standard attribute string (like this plugin here)
- find duplicate files
- compare by contents
- synchronize dirs

That could prevent users from mistakes that he believes to have some _copies_ but instead he have (only) hardlinks. This false believe can be the reason for data losses (change data or overwrite data).
"Since there are many things which have never happened and never will happen,
and which nevertheless are clearly conceivable, and imply no contradiction,
how can one say they are absolutely impossible?" Leibniz
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

2theosdikaios
This false believe can be the reason for data losses (change data or overwrite data).
What do you mean? I've always thought that hardlinks are safe. :?
F6, Enter, Tab, F6, Enter, Tab, F6, Enter, Tab... - I like to move IT, move IT!..
User avatar
SQUIRE
Senior Member
Senior Member
Posts: 373
Joined: 2005-06-16, 18:07 UTC

Post by *SQUIRE »

XPEHOPE3KA wrote:What do you mean? I've always thought that hardlinks are safe. :?
Yeah, deleting a file name referencing a hard link only deletes the reference count. The data object can only be deleted when the count is zero. Trouble is there is no visual cue whether you're dealing with a junction or hard link. Performing a DEL on a junction is bad news.

See http://ghisler.ch/board/viewtopic.php?p=84760&highlight=&sid=51156afd588f60f2502e7cfdf1a0d7b6#84760
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

SQUIRE
On NTFS there cannot be hardlinks to folders and junctions to files. So you may easily know which type of link you're working with: if you're dealing with a file - it could only be a hard link; if with a folder - it could be only a junction.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
SQUIRE
Senior Member
Senior Member
Posts: 373
Joined: 2005-06-16, 18:07 UTC

Post by *SQUIRE »

2 Flint:

That's perfectly true. What I meant was that unless you clearly name the folder or file, you do not have a visual cue. Misleading sentence construction. :oops:
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

However, the wcx_wipe plugin for TC doesn't know about hardlinks at all! It deletes the file itself, not the counts!
F6, Enter, Tab, F6, Enter, Tab, F6, Enter, Tab... - I like to move IT, move IT!..
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

What I meant was that unless you clearly name the folder or file, you do not have a visual cue.
For junctions there is already a visual cue present: TC displays them with the special icon. For hard links you may specify some color using NL_Info plugin (as well as for junctions). Also there is a good tool NTFS Link (not my NTFS Links!) that integrates into Windows Explorer and
1. shows special overlay icons for hard and symbolic links;
2. fixes the bug with removing junctions by Explorer.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
XPEHOPE3KA
Power Member
Power Member
Posts: 854
Joined: 2006-03-03, 18:23 UTC
Location: Saint-Petersburg, Russia

Post by *XPEHOPE3KA »

Flint
2. fixes the bug with removing junctions by Explorer.
:shock:
System hack? Or is it from MS?
Oh, remember? I'm lazy :) Gimme a link :oops:
F6, Enter, Tab, F6, Enter, Tab, F6, Enter, Tab... - I like to move IT, move IT!..
Post Reply