Example #1
0
BOOL COXProcess::GetCreationTime(COleDateTime& oleTime) const
{
	FILETIME creationTime;
	if(!GetCreationTime(creationTime))
		return FALSE;

	COleDateTime timeCopy(creationTime);
	oleTime=timeCopy;

	return TRUE;
}
//! Haponov function
void FileContextMenuExt::processSelectedFiles(std::wstring ws_name)
{
    std::wstring atLast = ws_name;
    
    //------------------
    //! Haponov: get a wstring with filename only - WO full path

    std::size_t found = atLast.find_last_of(L"/\\");
    atLast = atLast.substr(found + 1);					

    //------------------
    //! Haponov: create file handle for further usage

    HANDLE hFile = CreateFile(ws_name.c_str(),
        GENERIC_READ,
        FILE_SHARE_READ,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);
    if (hFile == INVALID_HANDLE_VALUE)
    {
        atLast = L"error opening file";
        return;
    }

    //-------------------
    // Haponov: get a wstring with size of file

    DWORD dwFileSize = GetFileSize(hFile, NULL);
    std::wstring result_size = std::to_wstring(dwFileSize);

    // Haponov: put spaces into size - "размер в удобочитаемом виде"
    unsigned int curLength = result_size.length();
    if (curLength > 3)
    {
        curLength -= 3;
        for (int i=3; curLength < result_size.length(); i += 4, curLength -= 3)
        {
            if (curLength > result_size.length() || !curLength) break;
            result_size.insert(result_size.end() - i, ' ');
        }
    }

    //------------------------
    // Haponov: get a string with creation time of file

    wchar_t temp_forCreationTime[MAX_PATH];
    if (!GetCreationTime(hFile, temp_forCreationTime, ARRAYSIZE(temp_forCreationTime)))
        return;
    std::wstring resultCreationTime(temp_forCreationTime);	

    //-------------------------
    // Haponov: get a string with ala checksum

    DWORD checksum = getCheckSum(ws_name);
    std::wstring result_checkSum = std::to_wstring(checksum);

    //-------------------------
    // Haponov: create a resulting string for displaying

    atLast += L";   size: ";   atLast += result_size;  
    atLast += L" KB;   creation time: ";  	atLast += resultCreationTime; 
    atLast += L"   checksum: ";   atLast += result_checkSum;

    // Haponov: protect shared std::set<std::wstring> sortedFiles
    mu.lock(); 
    sortedFiles.insert(atLast);
    mu.unlock();
    return;
}