我在投影文件系统中为文件提供了不同的属性。 我在枚举回调以及占位符中都这样做:
// GetDirectoryEnumerationCallback()
PRJ_FILE_BASIC_INFO fileBasicInfo = { 0 };
auto file = &holder->files[holder->index];
fileBasicInfo.IsDirectory = file->IsDirectory;
fileBasicInfo.FileSize = file->IsDirectory ? 0 : file->FileSize;
fileBasicInfo.ChangeTime = file->ChangeTime;
fileBasicInfo.CreationTime = file->CreationTime;
fileBasicInfo.FileAttributes = file->FileAttributes;
fileBasicInfo.LastAccessTime = file->LastAccessTime;
fileBasicInfo.LastWriteTime = file->LastWriteTime;
holder->index++;
wprintf(L"Enumerator (0x%08x)\n", fileBasicInfo.FileAttributes);
//FILE_ATTRIBUTE_ARCHIVE
if (holder->searchExpression.empty() || PrjFileNameMatch(file->Name, holder->searchExpression.c_str())) {
hr = PrjFillDirEntryBuffer(file->Name,
&fileBasicInfo,
dirEntryBufferHandle);
break;
}
和
PRJ_PLACEHOLDER_INFO placeholderInfo = {};
placeholderInfo.FileBasicInfo.IsDirectory = file.IsDirectory;
placeholderInfo.FileBasicInfo.FileSize = file.IsDirectory ? 0 : file.FileSize;
placeholderInfo.FileBasicInfo.ChangeTime = file.ChangeTime;
placeholderInfo.FileBasicInfo.CreationTime = file.CreationTime;
placeholderInfo.FileBasicInfo.FileAttributes = file.FileAttributes;
placeholderInfo.FileBasicInfo.LastAccessTime = file.LastAccessTime;
placeholderInfo.FileBasicInfo.LastWriteTime = file.LastWriteTime;
wprintf(L"SendAttribute (0x%08x)\n", placeholderInfo.FileBasicInfo.FileAttributes);
for (size_t i = 0; i < sizeof(file.Hash); i++)
placeholderInfo.VersionInfo.ContentID[i] = wctob(file.Hash[i]);
hr = PrjWritePlaceholderInfo(this->context,
path.c_str(),
&placeholderInfo,
sizeof(placeholderInfo));
我使用以下属性0x00001000
(FILE_ATTRIBUTE_OFFLINE
)和0x00000080
(FILE_ATTRIBUTE_NORMAL
)。但是,当我使用Get-ItemProperty
或attrib.exe
时,它返回0x00000020
(FILE_ATTRIBUTE_ARCHIVE
)或如果我尚未打开文件0x400020
({{1} }。
从文档中看起来很简单。但是我无法正常工作。