Format of NTFS description stream

For files, we use the Windows Summary Information Property Set API, and PIDSI_COMMENTS property.

That uses the \005SummaryInformation NTFS ADS stream. Sample code to read the comment:

BOOL fOk = FALSE;
HRESULT hr;

IPropertySetStorage* pStg = 0;
if (SUCCEEDED(hr = StgOpenStorageEx(pPath.GetString(), STGM_SHARE_EXCLUSIVE | STGM_READ, STGFMT_ANY, 0, 0, 0,
	IID_IPropertySetStorage, reinterpret_cast<void**>(&pStg))))
{
	IPropertyStorage* pSet = 0;
	if (SUCCEEDED(hr = pStg->Open(FMTID_SummaryInformation, STGM_SHARE_EXCLUSIVE | STGM_READ, &pSet)))
	{
		PROPSPEC ps;
		PROPVARIANT pv;

		ps.ulKind = PRSPEC_PROPID;
		ps.propid = PIDSI_COMMENTS;

		PropVariantInit(&pv);
		if (SUCCEEDED(hr = pSet->ReadMultiple(1, &ps, &pv)))
		{
			if (strComment.FromPropVariant(&pv) && !strComment.Empty())
				fOk = TRUE;
		}
		PropVariantClear(&pv);
		pSet->Release();
	}
	pStg->Release();
}

(This won't always be used for file types that have their own way of storing descriptions inside the file itself, where Opus knows and is able to write the formats. e.g. MP3 ID3 tags or JPG EXIF tags can be used to store descriptions as well.)

For folders (also for files, but I think only for non-comment data like Opus-specific labels), we have our own format which will be under the \007OpusMetaInformation NTFS ADS stream.

The start of that data will be this structure (all DWORD and int fields are 4 bytes):

	DWORD		omd_dwSize;
	DWORD		omd_dwFlags;
	int			omd_iRating;
	DWORD		omd_dwCommentSize;
	...more data up to omd_dwSize size...
	...the size may vary depending on Opus version...

Immediately after that will be the comment string in WCHARs (two bytes per char) and null terminated, but only if omd_dwCommentSize is non-zero. (If it is zero, there won't be any string, not even a null.) Following that there may be other data.

1 Like