I'm working on a program that should retrieve attributes of all files from chosen directory in std::vector.
This code shows how I'm getting file attributes:
DWORD attr_flags = GetFileAttributes(file_path);
if (attr_flags == INVALID_FILE_ATTRIBUTES) {
std::cout << "Invalid file attributes." << std::endl;
return;
}
And the code parses retrieved flags like this:
if (attr_flags & FILE_ATTRIBUTE_ARCHIVE) {
attrs.push_back(defines::Attributes::kArchive);
attr_flags &= ~FILE_ATTRIBUTE_ARCHIVE;
}
if (attr_flags & FILE_ATTRIBUTE_COMPRESSED) {
attrs.push_back(defines::Attributes::kCompressed);
attr_flags &= ~FILE_ATTRIBUTE_COMPRESSED;
}
/* etc... */
So, after all I'm printing result to console and get this:
Can anyone, please, tell me, why all files (not even archive) has archive attribute?
P.S: MSDN tell's
FILE_ATTRIBUTE_ARCHIVE 32 (0x20)
A file or directory that is an archive file or directory. Applications typically use this attribute to mark files for backup or removal .
The "archive" attribute doesn't mean "this file is an archive" (like a ZIP or 7Z file). Rather, it typically means "this file needs to be backed up":
On Windows and OS/2, when a file is created or modified, the archive bit is set, and when the file has been backed up, the archive bit is cleared. Thus, the meaning of the archive bit is: this file is due for archiving, or: this file has not been archived.
An incremental backup task may use the archive bit to distinguish which files have already been backed up, and select only the new or modified files for backup.
I don't think it's being used much in practice anymore (if it ever was).