mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
拆分代码4
This commit is contained in:
27
shell/Commands/FileSystem/TouchCommand.cs
Normal file
27
shell/Commands/FileSystem/TouchCommand.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
|
||||
namespace CMLeonOS.Commands.FileSystem
|
||||
{
|
||||
public static class TouchCommand
|
||||
{
|
||||
public static void CreateEmptyFile(CMLeonOS.FileSystem fileSystem, string args, Action<string> showError, Action<string> showSuccess)
|
||||
{
|
||||
if (string.IsNullOrEmpty(args))
|
||||
{
|
||||
showError("Please specify a file name");
|
||||
showError("touch <filename>");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
fileSystem.WriteFile(args, "");
|
||||
showSuccess($"Empty file '{args}' created successfully");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
showError($"Error creating file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user