<commit_before>#include "pch.h"

////////////////////////////////////////////////////////////////////////////////
//
// Helper Functions
//
////////////////////////////////////////////////////////////////////////////////

bool IsWindows9x()
{
    static bool bChecked = false;
    static bool bIs9x;

    if (!bChecked)
    {
        OSVERSIONINFO osversioninfo;

        osversioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

        ZVerify(GetVersionEx(&osversioninfo));

        bIs9x = osversioninfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
        bChecked = true;
    }

    return bIs9x;
}


////////////////////////////////////////////////////////////////////////////////
//
// ZFile
//
////////////////////////////////////////////////////////////////////////////////

// BUILD_DX9: added for DX9 but can stay for DX7 as well
ZFile::ZFile( )
{
	m_p = NULL;
	m_handle = INVALID_HANDLE_VALUE;
}


ZFile::ZFile(const PathString& strPath, DWORD how) : 
    m_p(NULL)
{
	// BT - CSS - 12/8/2011 - Fixing 128 character path limit.
	DWORD dwDesiredAccess = GENERIC_READ;
	DWORD dwShareMode = FILE_SHARE_WRITE;
	DWORD dwCreationDisposition = OPEN_EXISTING;

	if((how & OF_WRITE) == OF_WRITE)
		dwDesiredAccess = GENERIC_WRITE;

	if((how & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE)
		dwShareMode = FILE_SHARE_READ;

	if((how & OF_CREATE) == OF_CREATE)
		dwCreationDisposition = CREATE_ALWAYS;

	// Unicode markers / wide format enables up to 32K path length. 
	PathString unicodePath("\\\\?\\");

	// If the path is relative, don't use unicode marker.
	if(strPath.Left(1) == ZString(".") || strPath.FindAny("//") == -1)
		unicodePath = strPath;
	else
		unicodePath += strPath;

	WCHAR* pszw = new WCHAR[unicodePath.GetLength() + 1];
    int result = MultiByteToWideChar(CP_ACP, 0, unicodePath, unicodePath.GetLength(), pszw, unicodePath.GetLength());
	pszw[result] = NULL;

	m_handle = CreateFileW(pszw, dwDesiredAccess,  dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);

	delete pszw;
	// BT - End fix.
}

ZFile::~ZFile()
{
    if (m_p) {
        UnmapViewOfFile(m_p);
        CloseHandle(m_hfileMapping);
    }
}

bool ZFile::IsValid()
{
     return m_handle != (HANDLE)HFILE_ERROR;
}

DWORD ZFile::Read(void* p, DWORD length)
{
    DWORD cbActual;

    ReadFile(m_handle, p, length, (LPDWORD)&cbActual, NULL);
    return cbActual;
}<commit_msg>this puts the R6 base.cpp back in Zlib (undo BackTracks change)<commit_after>#include "pch.h"

////////////////////////////////////////////////////////////////////////////////
//
// Helper Functions
//
////////////////////////////////////////////////////////////////////////////////

bool IsWindows9x()
{
    static bool bChecked = false;
    static bool bIs9x;

    if (!bChecked)
    {
        OSVERSIONINFO osversioninfo;

        osversioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);

        ZVerify(GetVersionEx(&osversioninfo));

        bIs9x = osversioninfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
        bChecked = true;
    }

    return bIs9x;
}


////////////////////////////////////////////////////////////////////////////////
//
// ZFile
//
////////////////////////////////////////////////////////////////////////////////

// BUILD_DX9: added for DX9 but can stay for DX7 as well
ZFile::ZFile( )
{
	m_p = NULL;
	m_handle = INVALID_HANDLE_VALUE;
}


ZFile::ZFile(const PathString& strPath, DWORD how) : 
    m_p(NULL)
{
    OFSTRUCT rob;
    m_handle = (HANDLE)OpenFile(strPath, &rob, how);
}

ZFile::~ZFile()
{
    if (m_p) {
        UnmapViewOfFile(m_p);
        CloseHandle(m_hfileMapping);
    }
}

bool ZFile::IsValid()
{
     return m_handle != (HANDLE)HFILE_ERROR;
}

DWORD ZFile::Read(void* p, DWORD length)
{
    DWORD cbActual;

    ReadFile(m_handle, p, length, (LPDWORD)&cbActual, NULL);
    return cbActual;
}
{'fraction_non_alphanumeric': 0.26992422262869087, 'fraction_numerical': 0.009145544813169584, 'mean_word_length': 1.788055353241078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '304118', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1192, 'n_words': 254}