<commit_before>using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
using IronAHK.Rusty.Cores.Common.Mapper;
using IronAHK.Rusty.Cores.Common.Drives;

namespace IronAHK.Rusty
{
    partial class Core
    {
        // TODO: organise Disk.cs

        /// <summary>
        /// Ejects/retracts the tray in a CD or DVD drive, or sets a drive's volume label.
        /// </summary>
        /// <param name="command"></param>
        /// <param name="drive">The drive letter.</param>
        /// <param name="value"></param>
        public static void Drive(string command, string drive = null, string value = null)
        {
            var cmd = command.ToLowerInvariant();

            #region cmd Eject

            if(cmd == Keyword_Eject) {
                if(!string.IsNullOrEmpty(drive)) {
                    var lowDriv = SystemDriveFactory.CreateSystemDrive(new DriveInfo(drive));
                    lowDriv.Eject();
                }
            }

            #endregion
        }

        /// <summary>
        /// Retrieves various types of information about the computer's drive(s).<commit_msg>impl. Disk Commands Label and Retract<commit_after>using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
using IronAHK.Rusty.Cores.Common.Mapper;
using IronAHK.Rusty.Cores.Common.Drives;

namespace IronAHK.Rusty
{
    partial class Core
    {
        // TODO: organise Disk.cs

        /// <summary>
        /// Ejects/retracts the tray in a CD or DVD drive, or sets a drive's volume label.
        /// </summary>
        /// <param name="command"></param>
        /// <param name="drive">The drive letter.</param>
        /// <param name="value"></param>
        public static void Drive(string command, string drive = null, string value = null)
        {
            var cmd = command.ToLowerInvariant();

            #region cmd Eject

            if(cmd == Keyword_Eject && string.IsNullOrEmpty(value)) {
                if(!string.IsNullOrEmpty(drive)) {
                    var lowDriv = SystemDriveFactory.CreateSystemDrive(new DriveInfo(drive));
                    lowDriv.Eject();
                }
            }

            #endregion

            #region cmd Retract / Close

            if(cmd == Keyword_Eject && !string.IsNullOrEmpty(value) && value == "1") {
                if(!string.IsNullOrEmpty(drive)) {
                    var lowDriv = SystemDriveFactory.CreateSystemDrive(new DriveInfo(drive));
                    lowDriv.Retract();
                }
            }

            #endregion

            #region cmd Label

            if(cmd == Keyword_Label) {
                if(!string.IsNullOrEmpty(drive)) {
                    try {
                        var drv = new DriveInfo(drive);
                        drv.VolumeLabel = string.IsNullOrEmpty(value) ? "" : value;
                    } catch(Exception) {
                        ErrorLevel = 1;
                        return;
                    }
                }

            }

            #endregion
        }

        /// <summary>
        /// Retrieves various types of information about the computer's drive(s).
{'fraction_non_alphanumeric': 0.10940438871473354, 'fraction_numerical': 0.0006269592476489029, 'mean_word_length': 1.5879967558799675, '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': '7276892', 'n_tokens_mistral': 875, 'n_tokens_neox': 832, 'n_words': 202}