Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 91171db

Browse files
committed
Use correct byte count for 0.5GB; add comments; remove unused code
1 parent ee1b074 commit 91171db

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

UniqueFileGenerator/FileHandler.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ public sealed class FileHandler
1010

1111
public FileHandler(Settings settings)
1212
{
13-
ArgumentNullException.ThrowIfNull(settings);
14-
15-
Settings = settings;
13+
Settings = settings ?? throw new ArgumentNullException(nameof(settings));
1614
}
1715

16+
/// <summary>
17+
/// Create FileData instances using the settings.
18+
/// </summary>
1819
private IEnumerable<FileData> GetFileData()
1920
{
2021
var stringFactory = new RandomStringFactory(Settings.CharacterTypes);
@@ -32,6 +33,9 @@ private IEnumerable<FileData> GetFileData()
3233
}
3334
}
3435

36+
/// <summary>
37+
/// Create and write files to the drive.
38+
/// </summary>
3539
public void CreateFiles()
3640
{
3741
var hasSufficientSpace = EnsureSufficientDriveSpace();
@@ -82,11 +86,11 @@ public void CreateFiles()
8286
private bool? EnsureSufficientDriveSpace()
8387
{
8488
// Don't allow the drive space to drop below this size in bytes.
85-
const long driveSpaceToKeepAvailable = 500_000_000; // Roughly 0.5GB
89+
const long driveSpaceToKeepAvailable = 536_870_912; // 0.5GB
8690

8791
try
8892
{
89-
var appPath = System.AppContext.BaseDirectory; // System.Reflection.Assembly.GetExecutingAssembly().Location;
93+
var appPath = System.AppContext.BaseDirectory;
9094

9195
var rootPath = Path.GetPathRoot(appPath);
9296
if (rootPath == null)
@@ -103,7 +107,10 @@ public void CreateFiles()
103107
}
104108
}
105109

106-
private class FileData
110+
/// <summary>
111+
/// Represents the data necessary to save a file on the drive.
112+
/// </summary>
113+
private record class FileData
107114
{
108115
public string Name { get; }
109116
public string Content { get; }

0 commit comments

Comments
 (0)