using System.Diagnostics;

class Program
{
    static void Main()
    {
        string filesDir = "../files";
        string filePath = Path.Combine(filesDir, "bigfile.dat");
        string copyPath = Path.Combine(filesDir, "bigfile_copy.dat");
        string movedCopyPath = Path.Combine(filesDir, "moved_bigfile_copy.dat");
        string movedDirPath = "../files_moved";
        int blockSize = 1024 * 1024; // 1 MB
        int iterations = 100; // 100 MB

        if (!Directory.Exists(filesDir))
            Directory.CreateDirectory(filesDir);

        byte[] buffer = new byte[blockSize];
        for (int i = 0; i < buffer.Length; i++)
            buffer[i] = (byte)'A';

        var swWrite = Stopwatch.StartNew();
        using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write))
        {
            for (int i = 0; i < iterations; i++)
                fs.Write(buffer, 0, buffer.Length);
        }
        swWrite.Stop();
        Console.WriteLine($"C# Write time: {swWrite.ElapsedMilliseconds} ms");

        var swCopy = Stopwatch.StartNew();
        File.Copy(filePath, copyPath, true);
        swCopy.Stop();
        Console.WriteLine($"C# Copy time: {swCopy.ElapsedMilliseconds} ms");

        var swRead = Stopwatch.StartNew();
        using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
        {
            byte[] readBuffer = new byte[blockSize];
            while (fs.Read(readBuffer, 0, readBuffer.Length) > 0) { }
        }
        swRead.Stop();
        Console.WriteLine($"C# Read time: {swRead.ElapsedMilliseconds} ms");

        var swAttr = Stopwatch.StartNew();
        FileAttributes originalAttrs = File.GetAttributes(filePath);
        File.SetAttributes(filePath, originalAttrs | FileAttributes.Hidden);
        File.SetAttributes(filePath, originalAttrs);
        swAttr.Stop();
        Console.WriteLine($"File attribute toggle time: {swAttr.ElapsedMilliseconds} ms");

        var swMoveFile = Stopwatch.StartNew();
        File.Move(copyPath, movedCopyPath, true);
        swMoveFile.Stop();
        Console.WriteLine($"Move file time: {swMoveFile.ElapsedMilliseconds} ms");

        if (!Directory.Exists(movedDirPath))
            Directory.CreateDirectory(movedDirPath);

        var swMoveDir = Stopwatch.StartNew();
        Directory.Move(filesDir, Path.Combine(movedDirPath, "files"));
        swMoveDir.Stop();
        Console.WriteLine($"Move directory time: {swMoveDir.ElapsedMilliseconds} ms");

        Console.WriteLine("Listing fixed drives:");
        var fixedDrives = DriveInfo.GetDrives()
                                        .Where(d => d.IsReady &&
                                                    d.DriveType == DriveType.Fixed &&
                                                    d.DriveFormat != "squashfs" &&
                                                    d.DriveFormat != "tracefs" &&
                                                    d.DriveFormat != "pstorefs" &&
                                                    d.DriveFormat != "bpf_fs" &&
                                                    d.DriveFormat != "rpc_pipefs");

        foreach (var drive in fixedDrives)
        {
            Console.WriteLine($"Drive: {drive.Name} | " + 
                              $"Type: {drive.DriveType} | Format: {drive.DriveFormat} | " + 
                              $"Total: {drive.TotalSize / (1024 * 1024)} MB | " + 
                              $"Free: {drive.AvailableFreeSpace / (1024 * 1024)} MB");
        }
    }
}