Esempio n. 1
0
void CShellBrowser::DetermineItemAttributeGroup(int iItemInternal,TCHAR *szGroupHeader,int cchMax) const
{
	TCHAR FullFileName[MAX_PATH];
	std::list<TypeGroup_t>::iterator itr;
	TCHAR szAttributes[32];

	StringCchCopy(FullFileName,SIZEOF_ARRAY(FullFileName),m_CurDir);
	PathAppend(FullFileName,m_pwfdFiles[iItemInternal].cFileName);

	BuildFileAttributeString(FullFileName,szAttributes,
		SIZEOF_ARRAY(szAttributes));

	StringCchCopy(szGroupHeader,cchMax,szAttributes);
}
Esempio n. 2
0
HRESULT BuildFileAttributeString(const TCHAR *lpszFileName, TCHAR *szOutput, DWORD cchMax)
{
    /* FindFirstFile is used instead of GetFileAttributes() or
    GetFileAttributesEx() because of its behaviour
    in relation to system files that normally
    won't have their attributes given (such as the
    pagefile, which neither of the two functions
    above can retrieve the attributes of). */
    WIN32_FIND_DATA wfd;
    HFindFilePtr hFindFile = FindFirstFilePtr(lpszFileName, &wfd);
    HRESULT hr = E_FAIL;

    if(hFindFile)
    {
        hr = BuildFileAttributeString(wfd.dwFileAttributes, szOutput, cchMax);
    }

    return hr;
}
Esempio n. 3
0
	void RunTest(DWORD dwAttributes, const TCHAR *szAttributeStringExpected)
	{
		TCHAR szResourceDirectory[MAX_PATH];
		GetTestResourceDirectory(szResourceDirectory, SIZEOF_ARRAY(szResourceDirectory));

		TCHAR *szOut = PathCombine(m_szFullFileName, szResourceDirectory, L"AttributeFile");
		ASSERT_NE(nullptr, szOut);

		HANDLE hFile = CreateFile(m_szFullFileName, 0, 0, NULL,
			CREATE_NEW, dwAttributes, NULL);
		ASSERT_NE(INVALID_HANDLE_VALUE, hFile);
		CloseHandle(hFile);

		m_bDeleteFile = TRUE;

		TCHAR szAttributeString[8];
		HRESULT hr = BuildFileAttributeString(m_szFullFileName, szAttributeString, SIZEOF_ARRAY(szAttributeString));
		ASSERT_EQ(S_OK, hr);

		EXPECT_STREQ(szAttributeStringExpected, szAttributeString);
	}