blob: 40bb2d5c05c4a2f31ee12dd55f508ffcefb5d190 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="DriveUtilities.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// The drive utilities.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Utilities
{
using System.Collections.Generic;
using System.IO;
using HandBrakeWPF.Model;
/// <summary>
/// The drive utilities.
/// </summary>
public class DriveUtilities
{
/// <summary>
/// Get a list of available DVD drives which are ready and contain DVD content.
/// </summary>
/// <returns>A List of Drives with their details</returns>
public static List<DriveInformation> GetDrives()
{
var drives = new List<DriveInformation>();
DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();
int id = 0;
foreach (DriveInfo curDrive in theCollectionOfDrives)
{
if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady)
{
if (Directory.Exists(curDrive.RootDirectory + "VIDEO_TS") ||
Directory.Exists(curDrive.RootDirectory + "BDMV"))
{
drives.Add(
new DriveInformation
{
Id = id,
VolumeLabel = curDrive.VolumeLabel,
RootDirectory = curDrive.RootDirectory.ToString()
});
id++;
}
}
}
return drives;
}
public static bool HasMinimumDiskSpace(string destination, long minimumInBytes)
{
string drive = Path.GetPathRoot(destination);
if (!string.IsNullOrEmpty(drive) && !drive.StartsWith("\\"))
{
DriveInfo c = new DriveInfo(drive);
if (c.AvailableFreeSpace < minimumInBytes)
{
return false;
}
}
return true;
}
}
}
|