<commit_before>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2020.  All rights reserved
 */
#include "../../StroikaPreComp.h"

#if qPlatform_Windows
#include <Windows.h>
#include <winioctl.h>
#endif

#include "../../Characters/Format.h"
#include "../../Characters/String.h"
#include "../../Characters/StringBuilder.h"
#include "../../Characters/String_Constant.h"
#include "../../Characters/ToString.h"
#include "../../Memory/SmallStackBuffer.h"

#include "Disk.h"

using namespace Stroika::Foundation;
using namespace Stroika::Foundation::Characters;
using namespace Stroika::Foundation::Containers;
using namespace Stroika::Foundation::IO;
using namespace Stroika::Foundation::IO::FileSystem;

/*
 *  I thought this might be useful. maybe at some point? But so far it doesn't appear super useful
 *  or needed.
 *  But we can use this to find out the disk kind for physical devices
 *  --LGP 2015-09-30
 */
#ifndef qCaptureDiskDeviceInfoWindows_
#define qCaptureDiskDeviceInfoWindows_ 0
#endif

#if qCaptureDiskDeviceInfoWindows_
#include <devguid.h>
#include <regstr.h>
#include <setupapi.h>
#pragma comment(lib, "Setupapi.lib")
DEFINE_GUID (GUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
#endif

#if qCompiler_cpp17InlineStaticMemberOfTemplateLinkerUndefined_Buggy
/*
 ********************************************************************************
 **************************** Configuration::DefaultNames ***********************
 ********************************************************************************
 */
namespace Stroika::Foundation::Configuration {
    template <>
    constexpr EnumNames<Foundation::IO::FileSystem::BlockDeviceKind> DefaultNames<Foundation::IO::FileSystem::BlockDeviceKind>::k;
}
#endif

/*
 ********************************************************************************
 ************************** IO::FileSystem::DiskInfoType ************************
 ********************************************************************************
 */
String DiskInfoType::ToString () const
{
    StringBuilder sb;
    sb += L"{";
    sb += L"Device-Name: '" + fDeviceName + L"', ";
    if (fDeviceKind) {
        sb += L"Device-Kind: '" + Characters::ToString (*fDeviceKind) + L"', ";
    }
    if (fSizeInBytes) {
        sb += L"Size-In-Bytes: " + Characters::ToString (*fSizeInBytes) + L", ";
    }
    sb += L"}";
    return sb.str ();
}

/*
 ********************************************************************************
 **************************** FileSystem::GetAvailableDisks *********************
 ********************************************************************************
 */
#if qCaptureDiskDeviceInfoWindows_
namespace {
    list<wstring> GetPhysicalDiskDeviceInfo_ ()
    {
        HDEVINFO      hDeviceInfoSet;
        ULONG         ulMemberIndex;<commit_msg>fix regression due to filesystem change<commit_after>/*
 * Copyright(c) Sophist Solutions, Inc. 1990-2020.  All rights reserved
 */
#include "../../StroikaPreComp.h"

#if qPlatform_Windows
#include <Windows.h>
#include <winioctl.h>
#endif

#include "../../Characters/Format.h"
#include "../../Characters/String.h"
#include "../../Characters/StringBuilder.h"
#include "../../Characters/String_Constant.h"
#include "../../Characters/ToString.h"
#include "../../Memory/SmallStackBuffer.h"

#include "Disk.h"

using namespace Stroika::Foundation;
using namespace Stroika::Foundation::Characters;
using namespace Stroika::Foundation::Containers;
using namespace Stroika::Foundation::IO;
using namespace Stroika::Foundation::IO::FileSystem;

/*
 *  I thought this might be useful. maybe at some point? But so far it doesn't appear super useful
 *  or needed.
 *  But we can use this to find out the disk kind for physical devices
 *  --LGP 2015-09-30
 */
#ifndef qCaptureDiskDeviceInfoWindows_
#define qCaptureDiskDeviceInfoWindows_ 0
#endif

#if qCaptureDiskDeviceInfoWindows_
#include <devguid.h>
#include <regstr.h>
#include <setupapi.h>
#pragma comment(lib, "Setupapi.lib")
DEFINE_GUID (GUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
#endif

#if qCompiler_cpp17InlineStaticMemberOfTemplateLinkerUndefined_Buggy
/*
 ********************************************************************************
 **************************** Configuration::DefaultNames ***********************
 ********************************************************************************
 */
namespace Stroika::Foundation::Configuration {
    template <>
    constexpr EnumNames<Foundation::IO::FileSystem::BlockDeviceKind> DefaultNames<Foundation::IO::FileSystem::BlockDeviceKind>::k;
}
#endif

/*
 ********************************************************************************
 ************************** IO::FileSystem::DiskInfoType ************************
 ********************************************************************************
 */
String DiskInfoType::ToString () const
{
    StringBuilder sb;
    sb += L"{";
    sb += L"Device-Name: " + Characters::ToString (fDeviceName) + L", ";
    if (fDeviceKind) {
        sb += L"Device-Kind: '" + Characters::ToString (*fDeviceKind) + L"', ";
    }
    if (fSizeInBytes) {
        sb += L"Size-In-Bytes: " + Characters::ToString (*fSizeInBytes) + L", ";
    }
    sb += L"}";
    return sb.str ();
}

/*
 ********************************************************************************
 **************************** FileSystem::GetAvailableDisks *********************
 ********************************************************************************
 */
#if qCaptureDiskDeviceInfoWindows_
namespace {
    list<wstring> GetPhysicalDiskDeviceInfo_ ()
    {
        HDEVINFO      hDeviceInfoSet;
        ULONG         ulMemberIndex;
{'fraction_non_alphanumeric': 0.3299325609545219, 'fraction_numerical': 0.017292062943109112, 'mean_word_length': 5.580204778156997, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '7246615', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1539, 'n_words': 333}