예제 #1
0
        public static VolumeProbeResult ProbeVolume(PlatformIO.DriveInfo drive)
        {
            VolumeProbeResult result = VolumeProbeResult.Unknown;

            if (drive == null)
            {
                throw new ArgumentNullException("drive");
            }

            if (!drive.IsReady)
            {
                throw new ArgumentException("Drive is not ready", "drive");
            }

            // check for audio cd first -
            // win32 also mounts audio cds as filesystems
            if (drive.HasAudioCdVolume)
            {
                return(VolumeProbeResult.AudioCd);
            }
            else if (drive.IsMounted)
            {
                return(VolumeProbeResult.Filesystem);
            }

            return(result);
        }
예제 #2
0
        // <summary>
        /// Probes a volume, creates the appropriate VolumeScanner and returns a general interface to it.
        /// </summary>
        /// <param name="drive">Drive to be scanned</param>
        /// <param name="database">VolumeDatabase object</param>
        /// <param name="options">ScannerOptions for all possible scanners</param>
        /// <returns>Interface to the proper VolumeScanner</returns>
        public static IVolumeScanner GetScannerForVolume(PlatformIO.DriveInfo drive,
                                                         VolumeDatabase database,
                                                         ScannerOptions[] options)
        {
            if (drive == null)
            {
                throw new ArgumentNullException("drive");
            }

            if (!drive.IsReady)
            {
                throw new ArgumentException("Drive is not ready", "drive");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            IVolumeScanner    scanner = null;
            VolumeProbeResult result  = ProbeVolume(drive);

            switch (result)
            {
            case VolumeProbeResult.Filesystem:
                scanner = new FilesystemVolumeScanner(drive,
                                                      database,
                                                      GetOptions <FilesystemScannerOptions>(options));
                break;

            case VolumeProbeResult.AudioCd:
                scanner = new AudioCdVolumeScanner(drive,
                                                   database,
                                                   GetOptions <AudioCdScannerOptions>(options));
                break;

            case VolumeProbeResult.Unknown:
                throw new ArgumentException("Volume is of an unknown type");

            default:
                throw new NotImplementedException(string.Format("VolumeProbeResult {0} is not implemented", result.ToString()));
            }

            return(scanner);
        }