-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Who doesn't like drives? * Add another TODO * Use built in stuff, it's quicker * More special handling for floppies, easier this time * Fix broken test * Set active drive priority, String -> string * Track reason for no scanning * Update DIC version and release notes
- Loading branch information
1 parent
24b08dd
commit fbc9d04
Showing
14 changed files
with
178 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,63 @@ | ||
namespace DICUI.Utilities | ||
using System.IO; | ||
using DICUI.Data; | ||
|
||
namespace DICUI.Utilities | ||
{ | ||
/// <summary> | ||
/// Represents information for a single drive | ||
/// </summary> | ||
public class Drive | ||
{ | ||
/// <summary> | ||
/// Windows drive letter | ||
/// Represents drive type | ||
/// </summary> | ||
public char Letter { get; private set; } | ||
public InternalDriveType? InternalDriveType { get; set; } | ||
|
||
/// <summary> | ||
/// Represents if it is a floppy drive | ||
/// DriveInfo object representing the drive, if possible | ||
/// </summary> | ||
public bool IsFloppy { get; private set; } | ||
public DriveInfo DriveInfo { get; private set; } | ||
|
||
/// <summary> | ||
/// Media label as read by Windows | ||
/// Windows drive letter | ||
/// </summary> | ||
public string VolumeLabel { get; private set; } | ||
public char Letter { get { return DriveInfo?.Name[0] ?? '\0'; } } | ||
|
||
/// <summary> | ||
/// Represents if Windows has marked the drive as active | ||
/// Media label as read by Windows | ||
/// </summary> | ||
public bool MarkedActive { get; private set; } | ||
|
||
private Drive(char letter, string volumeLabel, bool isFloppy, bool markedActive) | ||
public string VolumeLabel | ||
{ | ||
this.Letter = letter; | ||
this.IsFloppy = isFloppy; | ||
this.VolumeLabel = volumeLabel; | ||
this.MarkedActive = markedActive; | ||
get | ||
{ | ||
if (DriveInfo.IsReady) | ||
{ | ||
if (string.IsNullOrWhiteSpace(DriveInfo.VolumeLabel)) | ||
return "track"; | ||
else | ||
return DriveInfo.VolumeLabel; | ||
} | ||
else | ||
{ | ||
return Template.DiscNotDetected; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Create a new Floppy drive instance | ||
/// Drive partition format | ||
/// </summary> | ||
/// <param name="letter">Drive letter to use</param> | ||
/// <returns>Drive object for a Floppy drive</returns> | ||
public static Drive Floppy(char letter) => new Drive(letter, null, true, true); | ||
public string DriveFormat { get { return DriveInfo.DriveFormat; } } | ||
|
||
/// <summary> | ||
/// Create a new Optical drive instance | ||
/// Represents if Windows has marked the drive as active | ||
/// </summary> | ||
/// <param name="letter">Drive letter to use</param> | ||
/// <param name="volumeLabel">Media label, if it exists</param> | ||
/// <param name="active">True if the drive is marked active, false otherwise</param> | ||
/// <returns>Drive object for an Optical drive</returns> | ||
public static Drive Optical(char letter, string volumeLabel, bool active) => new Drive(letter, volumeLabel, false, active); | ||
public bool MarkedActive { get { return DriveInfo.IsReady; } } | ||
|
||
public Drive(InternalDriveType? driveType, DriveInfo driveInfo) | ||
{ | ||
this.InternalDriveType = driveType; | ||
this.DriveInfo = driveInfo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.