<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: filew32.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 08:42:13 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef INCLUDED_STORE_FILEW32_HXX
#define INCLUDED_STORE_FILEW32_HXX

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

typedef HANDLE HSTORE;

/*========================================================================
 *
 * File I/O (inline) implementation.
 *
 *======================================================================*/
/*
 * __store_errcode_map.
 */
static const __store_errcode_mapping_st __store_errcode_map[] =
{
    { ERROR_SUCCESS,           store_E_None             },
    { ERROR_FILE_NOT_FOUND,    store_E_NotExists        },
    { ERROR_ACCESS_DENIED,     store_E_AccessViolation  },
    { ERROR_LOCK_FAILED,       store_E_LockingViolation },
    { ERROR_LOCK_VIOLATION,    store_E_LockingViolation },
    { ERROR_INVALID_HANDLE,    store_E_InvalidHandle    },
    { ERROR_INVALID_PARAMETER, store_E_InvalidParameter },
    { ERROR_DISK_FULL,         store_E_OutOfSpace       },
    { ERROR_HANDLE_DISK_FULL,  store_E_OutOfSpace       },
};

/*
 * __store_errno.
 */
inline sal_uInt32 __store_errno (void)
{
    return (sal_uInt32)::GetLastError();
}

/*
 * __store_malign.
 */
inline sal_uInt32 __store_malign (void)
{
    // Check Win32 platform.
    OSVERSIONINFO osinfo;

    osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    ::GetVersionEx (&osinfo);

    if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
    {
        // Determine memory allocation granularity.
        SYSTEM_INFO info;

        ::GetSystemInfo (&info);
        return ((sal_uInt32)(info.dwAllocationGranularity));
    }
    return (sal_uInt32)(-1);
}

/*
 * __store_fmap (readonly).
 */
inline HSTORE __store_fmap (HSTORE hFile)
{
    return ::CreateFileMapping (
        hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL);
}

/*
 * __store_funmap.
 */
inline void __store_funmap (HSTORE hMap)
{
    ::CloseHandle (hMap);
}

/*
 * __store_mmap (readonly).
 */
inline sal_uInt8* __store_mmap (HSTORE h, sal_uInt32 k, sal_uInt32 n)
{
    return (sal_uInt8*)::MapViewOfFile (h, FILE_MAP_READ, 0, k, n);
}

/*
 * __store_munmap.
 */
inline void __store_munmap (sal_uInt8 *p, sal_uInt32 n)
{
    ::UnmapViewOfFile (p);
}

/*
 * __store_fopen.
 */
inline storeError __store_fopen (
    const sal_Char *pszName, sal_uInt32 nMode, HSTORE &rhFile)
{
    // Access mode.
    DWORD nAccessMode = GENERIC_READ;

    if (nMode & store_File_OpenWrite)
        nAccessMode |= GENERIC_WRITE;

    if (nAccessMode == GENERIC_READ)
        nMode |= store_File_OpenNoCreate;

    // Share mode.
    DWORD nShareMode = FILE_SHARE_READ;
    if (!(nMode & store_File_OpenWrite))
        nShareMode |= FILE_SHARE_WRITE;

    // Open action.
    DWORD nOpenAction = 0;<commit_msg>INTEGRATION: CWS warnings01 (1.4.8); FILE MERGED 2005/11/21 09:15:27 sb 1.4.8.1: #i53898# Made code warning-free.<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: filew32.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-20 00:32:12 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef INCLUDED_STORE_FILEW32_HXX
#define INCLUDED_STORE_FILEW32_HXX

#pragma warning(push,1) // disable warnings within system headers
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma warning(pop)

typedef HANDLE HSTORE;

/*========================================================================
 *
 * File I/O (inline) implementation.
 *
 *======================================================================*/
/*
 * __store_errcode_map.
 */
static const __store_errcode_mapping_st __store_errcode_map[] =
{
    { ERROR_SUCCESS,           store_E_None             },
    { ERROR_FILE_NOT_FOUND,    store_E_NotExists        },
    { ERROR_ACCESS_DENIED,     store_E_AccessViolation  },
    { ERROR_LOCK_FAILED,       store_E_LockingViolation },
    { ERROR_LOCK_VIOLATION,    store_E_LockingViolation },
    { ERROR_INVALID_HANDLE,    store_E_InvalidHandle    },
    { ERROR_INVALID_PARAMETER, store_E_InvalidParameter },
    { ERROR_DISK_FULL,         store_E_OutOfSpace       },
    { ERROR_HANDLE_DISK_FULL,  store_E_OutOfSpace       },
};

/*
 * __store_errno.
 */
inline sal_uInt32 __store_errno (void)
{
    return (sal_uInt32)::GetLastError();
}

/*
 * __store_malign.
 */
inline sal_uInt32 __store_malign (void)
{
    // Check Win32 platform.
    OSVERSIONINFO osinfo;

    osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    ::GetVersionEx (&osinfo);

    if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
    {
        // Determine memory allocation granularity.
        SYSTEM_INFO info;

        ::GetSystemInfo (&info);
        return ((sal_uInt32)(info.dwAllocationGranularity));
    }
    return (sal_uInt32)(-1);
}

/*
 * __store_fmap (readonly).
 */
inline HSTORE __store_fmap (HSTORE hFile)
{
    return ::CreateFileMapping (
        hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL);
}

/*
 * __store_funmap.
 */
inline void __store_funmap (HSTORE hMap)
{
    ::CloseHandle (hMap);
}

/*
 * __store_mmap (readonly).
 */
inline sal_uInt8* __store_mmap (HSTORE h, sal_uInt32 k, sal_uInt32 n)
{
    return (sal_uInt8*)::MapViewOfFile (h, FILE_MAP_READ, 0, k, n);
}

/*
 * __store_munmap.
 */
inline void __store_munmap (sal_uInt8 *p, sal_uInt32)
{
    ::UnmapViewOfFile (p);
}

/*
 * __store_fopen.
 */
inline storeError __store_fopen (
    const sal_Char *pszName, sal_uInt32 nMode, HSTORE &rhFile)
{
    // Access mode.
    DWORD nAccessMode = GENERIC_READ;

    if (nMode & store_File_OpenWrite)
        nAccessMode |= GENERIC_WRITE;

    if (nAccessMode == GENERIC_READ)
        nMode |= store_File_OpenNoCreate;

    // Share mode.
    DWORD nShareMode = FILE_SHARE_READ;
    if (!(nMode & store_File_OpenWrite))
        nShareMode |= FILE_SHARE_WRITE;

    // Open action.
    DWORD nOpenAction = 0;
{'fraction_non_alphanumeric': 0.16916796734301837, 'fraction_numerical': 0.02413254892544123, 'mean_word_length': 3.4833153928955864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '2099431', 'n_tokens_mistral': 2821, 'n_tokens_neox': 2634, 'n_words': 684}