Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

fix(domain): create the containing dir of user config before writing the file

Lars Bergerc1def0b8512b
diff --git a/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs b/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs
index 91642463..62b2d15d 100644
--- a/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs
+++ b/GlazeWM.Domain/UserConfigs/CommandHandlers/EvaluateUserConfigHandler.cs
@@ -74,13 +74,15 @@ namespace GlazeWM.Domain.UserConfigs.CommandHandlers
var assembly = Assembly.GetEntryAssembly();
var sampleConfigResourceName = "GlazeWM.Bootstrapper.sample-config.yaml";
+ // Create containing directory. Needs to be created before writing to the file.
+ Directory.CreateDirectory(Path.GetDirectoryName(userConfigPath));
+
// Get the embedded sample user config from the entry assembly.
using (Stream stream = assembly.GetManifestResourceStream(sampleConfigResourceName))
{
// Write the sample user config to the appropriate destination.
using (var fileStream = new FileStream(userConfigPath, FileMode.Create, FileAccess.Write))
{
- Directory.CreateDirectory(Path.GetDirectoryName(userConfigPath));
stream.CopyTo(fileStream);
}
}