<commit_before>using System.IO;
using Arkivverket.Arkade.Core.Base;
using Arkivverket.Arkade.GUI.Properties;

namespace Arkivverket.Arkade.GUI.Util
{
    public static class ArkadeProcessingAreaLocationSetting
    {
        public static string Get()
        {
            Settings.Default.Reload();
            
            return Settings.Default.ArkadeProcessingAreaLocation;
        }

        public static void Set(string locationSetting)
        {
            Settings.Default.ArkadeProcessingAreaLocation = locationSetting;

            Settings.Default.Save();
        }

        public static bool IsValid()
        {
            try
            {
                string definedLocation = Get();

                return DirectoryIsWritable(definedLocation);
            }
            catch
            {
                return false; // Invalid path string in settings 
            }
        }

        public static bool IsApplied()
        {
            string appliedLocation = ArkadeProcessingArea.Location?.FullName ?? string.Empty;
            
            string definedLocation = Get();

            return appliedLocation.Equals(definedLocation);
        }

        private static bool DirectoryIsWritable(string directory)
        {
            if (string.IsNullOrWhiteSpace(directory))
                return false;

            string tmpFile = Path.Combine(directory, Path.GetRandomFileName());

            try
            {
                using (File.Create(tmpFile, 1, FileOptions.DeleteOnClose))
                {
                    // Attempt to write temporary file to the directory
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
<commit_msg>Test directory creation access by creating a directory (not a file)<commit_after>using System.IO;
using Arkivverket.Arkade.Core.Base;
using Arkivverket.Arkade.GUI.Properties;

namespace Arkivverket.Arkade.GUI.Util
{
    public static class ArkadeProcessingAreaLocationSetting
    {
        public static string Get()
        {
            Settings.Default.Reload();
            
            return Settings.Default.ArkadeProcessingAreaLocation;
        }

        public static void Set(string locationSetting)
        {
            Settings.Default.ArkadeProcessingAreaLocation = locationSetting;

            Settings.Default.Save();
        }

        public static bool IsValid()
        {
            try
            {
                string definedLocation = Get();

                return DirectoryIsWritable(definedLocation);
            }
            catch
            {
                return false; // Invalid path string in settings 
            }
        }

        public static bool IsApplied()
        {
            string appliedLocation = ArkadeProcessingArea.Location?.FullName ?? string.Empty;
            
            string definedLocation = Get();

            return appliedLocation.Equals(definedLocation);
        }

        private static bool DirectoryIsWritable(string directory)
        {
            if (string.IsNullOrWhiteSpace(directory))
                return false;

            string tmpDirectory = Path.Combine(directory, "arkade-writeaccess-test");

            try
            {
                Directory.CreateDirectory(tmpDirectory);

                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                if (Directory.Exists(tmpDirectory))
                    Directory.Delete(tmpDirectory);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.06739726027397261, 'fraction_numerical': 0.000273972602739726, 'mean_word_length': 1.4356237491661108, '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': '5397242', 'n_tokens_mistral': 863, 'n_tokens_neox': 813, 'n_words': 181}