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);