<commit_before>﻿using System;
using System.IO;

namespace CCSWE.IO
{
    /// <summary>
    /// Helper methods for file operations
    /// </summary>
    public static class FileUtils
    {
        #region Public Methods
        /// <summary>
        /// Safely deletes a file. Useful for situations where it would be nice if the file was deleted but it's ok if it isn't.
        /// </summary>
        /// <param name="path">The name of the file to be deleted.</param>
        /// <returns><c>true</c> if the file was deleted</returns>
        public static bool SafeDelete(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return false;
            }

            try
            {
                return new FileInfo(path).SafeDelete();
            }
            catch (Exception)
            {
                // Move along nothing to see here
            }

            return false;
        }

        /// <summary>
        /// Safely moves a file. Useful for situations where it would be nice if the file was moved but it's ok if it isn't.
        /// </summary>
        /// <param name="sourcePath">The name of the file to move.</param>
        /// <param name="destinationPath">The new path for the file.</param>
        /// <returns><c>true</c> if the file was moved.</returns>
        public static bool SafeMove(string sourcePath, string destinationPath)
        {
            if (string.IsNullOrWhiteSpace(sourcePath))
            {
                return false;
            }

            if (string.IsNullOrWhiteSpace(destinationPath))
            {
                return false;
            }

            try
            {
                File.Move(sourcePath, destinationPath);

                return true;<commit_msg>Creating the destination directory prior to move if it doesn't exist<commit_after>﻿using System;
using System.IO;

namespace CCSWE.IO
{
    /// <summary>
    /// Helper methods for file operations
    /// </summary>
    public static class FileUtils
    {
        #region Public Methods
        /// <summary>
        /// Safely deletes a file. Useful for situations where it would be nice if the file was deleted but it's ok if it isn't.
        /// </summary>
        /// <param name="path">The name of the file to be deleted.</param>
        /// <returns><c>true</c> if the file was deleted</returns>
        public static bool SafeDelete(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return false;
            }

            try
            {
                return new FileInfo(path).SafeDelete();
            }
            catch (Exception)
            {
                // Move along nothing to see here
            }

            return false;
        }

        /// <summary>
        /// Safely moves a file. Useful for situations where it would be nice if the file was moved but it's ok if it isn't.
        /// </summary>
        /// <param name="sourcePath">The name of the file to move.</param>
        /// <param name="destinationPath">The new path for the file.</param>
        /// <returns><c>true</c> if the file was moved.</returns>
        public static bool SafeMove(string sourcePath, string destinationPath)
        {
            if (string.IsNullOrWhiteSpace(sourcePath))
            {
                return false;
            }

            if (string.IsNullOrWhiteSpace(destinationPath))
            {
                return false;
            }

            try
            {
                var destinationDirectory = Path.GetDirectoryName(destinationPath);

                if (string.IsNullOrWhiteSpace(destinationDirectory))
                {
                    return false;
                }

                if (!Directory.Exists(destinationDirectory))
                {
                    Directory.CreateDirectory(destinationDirectory);
                }

                File.Move(sourcePath, destinationPath);

                return true;
{'fraction_non_alphanumeric': 0.09497762307309796, 'fraction_numerical': 0.0, 'mean_word_length': 1.4191220685508117, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, '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': '6116466', 'n_tokens_mistral': 996, 'n_tokens_neox': 950, 'n_words': 317}