using System; using System.Collections; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Text; namespace System.IO { /// Provides access to information on a drive. /// 1 // Token: 0x020001AD RID: 429 [ComVisible(true)] [Serializable] public sealed class DriveInfo : ISerializable { // Token: 0x06001618 RID: 5656 RVA: 0x0005518C File Offset: 0x0005338C private DriveInfo(DriveInfo._DriveType _drive_type, string path, string fstype) { this._drive_type = _drive_type; this.drive_format = fstype; this.path = path; } /// Provides access to information on the specified drive. /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z'. A null value is not valid. /// The drive letter cannot be null. /// The first letter of is not an uppercase or lowercase letter from 'a' to 'z'.-or- does not refer to a valid drive. // Token: 0x06001619 RID: 5657 RVA: 0x000551AC File Offset: 0x000533AC public DriveInfo(string driveName) { DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo driveInfo in drives) { if (driveInfo.path == driveName) { this.path = driveInfo.path; this.drive_format = driveInfo.drive_format; this.path = driveInfo.path; return; } } throw new ArgumentException("The drive name does not exist", "driveName"); } /// Populates a object with the data needed to serialize the target object. /// The object to populate with data. /// The destination (see ) for this serialization. // Token: 0x0600161A RID: 5658 RVA: 0x00055224 File Offset: 0x00053424 void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { throw new NotImplementedException(); } // Token: 0x0600161B RID: 5659 RVA: 0x0005522C File Offset: 0x0005342C private static void GetDiskFreeSpace(string path, out ulong availableFreeSpace, out ulong totalSize, out ulong totalFreeSpace) { MonoIOError monoIOError; if (!DriveInfo.GetDiskFreeSpaceInternal(path, out availableFreeSpace, out totalSize, out totalFreeSpace, out monoIOError)) { throw MonoIO.GetException(path, monoIOError); } } /// Indicates the amount of available free space on a drive. /// The amount of free space available on the drive, in bytes. /// Access to the drive information is denied. /// An I/O error occurred (for example, a disk error or a drive was not ready). /// 1 // Token: 0x170003E2 RID: 994 // (get) Token: 0x0600161C RID: 5660 RVA: 0x00055254 File Offset: 0x00053454 public long AvailableFreeSpace { get { ulong num; ulong num2; ulong num3; DriveInfo.GetDiskFreeSpace(this.path, out num, out num2, out num3); return (long)((num <= 9223372036854775807UL) ? num : 9223372036854775807UL); } } /// Gets the total amount of free space available on a drive. /// The total free space available on a drive, in bytes. /// Access to the drive information is denied. /// An I/O error occurred (for example, a disk error or a drive was not ready). /// 1 // Token: 0x170003E3 RID: 995 // (get) Token: 0x0600161D RID: 5661 RVA: 0x00055290 File Offset: 0x00053490 public long TotalFreeSpace { get { ulong num; ulong num2; ulong num3; DriveInfo.GetDiskFreeSpace(this.path, out num, out num2, out num3); return (long)((num3 <= 9223372036854775807UL) ? num3 : 9223372036854775807UL); } } /// Gets the total size of storage space on a drive. /// The total size of the drive, in bytes. /// Access to the drive information is denied. /// An I/O error occurred (for example, a disk error or a drive was not ready). /// 1 // Token: 0x170003E4 RID: 996 // (get) Token: 0x0600161E RID: 5662 RVA: 0x000552CC File Offset: 0x000534CC public long TotalSize { get { ulong num; ulong num2; ulong num3; DriveInfo.GetDiskFreeSpace(this.path, out num, out num2, out num3); return (long)((num2 <= 9223372036854775807UL) ? num2 : 9223372036854775807UL); } } /// Gets or sets the volume label of a drive. /// The volume label. /// Access to the drive information is denied.-or-The volume label is being set on a network or CD-ROM drive. /// An I/O error occurred (for example, a disk error or a drive was not ready). /// The caller does not have the required permission. /// 1 /// /// /// // Token: 0x170003E5 RID: 997 // (get) Token: 0x0600161F RID: 5663 RVA: 0x00055308 File Offset: 0x00053508 // (set) Token: 0x06001620 RID: 5664 RVA: 0x00055324 File Offset: 0x00053524 [MonoTODO("Currently get only works on Mono/Unix; set not implemented")] public string VolumeLabel { get { if (this._drive_type != DriveInfo._DriveType.Windows) { return this.path; } return this.path; } set { throw new NotImplementedException(); } } /// Gets the name of the file system, such as NTFS or FAT32. /// The name of the file system on the specified drive. /// Access to the drive information is denied. /// The drive does not exist or is not mapped. /// An I/O error occurred (for example, a disk error or a drive was not ready). /// 1 // Token: 0x170003E6 RID: 998 // (get) Token: 0x06001621 RID: 5665 RVA: 0x0005532C File Offset: 0x0005352C public string DriveFormat { get { return this.drive_format; } } /// Gets the drive type. /// One of the values. /// 1 // Token: 0x170003E7 RID: 999 // (get) Token: 0x06001622 RID: 5666 RVA: 0x00055334 File Offset: 0x00053534 public DriveType DriveType { get { return (DriveType)DriveInfo.GetDriveTypeInternal(this.path); } } /// Gets the name of a drive. /// The name of the drive. /// 1 // Token: 0x170003E8 RID: 1000 // (get) Token: 0x06001623 RID: 5667 RVA: 0x00055344 File Offset: 0x00053544 public string Name { get { return this.path; } } /// Gets the root directory of a drive. /// A object that contains the root directory of the drive. /// 1 /// /// /// // Token: 0x170003E9 RID: 1001 // (get) Token: 0x06001624 RID: 5668 RVA: 0x0005534C File Offset: 0x0005354C public DirectoryInfo RootDirectory { get { return new DirectoryInfo(this.path); } } /// Gets a value indicating whether a drive is ready. /// true if the drive is ready; false if the drive is not ready. /// 1 // Token: 0x170003EA RID: 1002 // (get) Token: 0x06001625 RID: 5669 RVA: 0x0005535C File Offset: 0x0005355C [MonoTODO("It always returns true")] public bool IsReady { get { return this._drive_type == DriveInfo._DriveType.Windows || true; } } // Token: 0x06001626 RID: 5670 RVA: 0x00055370 File Offset: 0x00053570 private static StreamReader TryOpen(string name) { if (File.Exists(name)) { return new StreamReader(name, Encoding.ASCII); } return null; } // Token: 0x06001627 RID: 5671 RVA: 0x0005538C File Offset: 0x0005358C private static DriveInfo[] LinuxGetDrives() { DriveInfo[] array; using (StreamReader streamReader = DriveInfo.TryOpen("/proc/mounts")) { ArrayList arrayList = new ArrayList(); string text; while ((text = streamReader.ReadLine()) != null) { if (!text.StartsWith("rootfs")) { int num = text.IndexOf(' '); if (num != -1) { string text2 = text.Substring(num + 1); num = text2.IndexOf(' '); if (num != -1) { string text3 = text2.Substring(0, num); text2 = text2.Substring(num + 1); num = text2.IndexOf(' '); if (num != -1) { string text4 = text2.Substring(0, num); arrayList.Add(new DriveInfo(DriveInfo._DriveType.Linux, text3, text4)); } } } } } array = (DriveInfo[])arrayList.ToArray(typeof(DriveInfo)); } return array; } // Token: 0x06001628 RID: 5672 RVA: 0x0005549C File Offset: 0x0005369C private static DriveInfo[] UnixGetDrives() { DriveInfo[] array = null; try { using (StreamReader streamReader = DriveInfo.TryOpen("/proc/sys/kernel/ostype")) { if (streamReader != null) { string text = streamReader.ReadLine(); if (text == "Linux") { array = DriveInfo.LinuxGetDrives(); } } } if (array != null) { return array; } } catch (Exception) { } return new DriveInfo[] { new DriveInfo(DriveInfo._DriveType.GenericUnix, "/", "unixfs") }; } // Token: 0x06001629 RID: 5673 RVA: 0x00055558 File Offset: 0x00053758 private static DriveInfo[] WindowsGetDrives() { throw new NotImplementedException(); } /// Retrieves the drive names of all logical drives on a computer. /// An array of type that represents the logical drives on a computer. /// An I/O error occurred (for example, a disk error or a drive was not ready). /// The caller does not have the required permission. /// 1 /// /// /// /// // Token: 0x0600162A RID: 5674 RVA: 0x00055560 File Offset: 0x00053760 [MonoTODO("Currently only implemented on Mono/Linux")] public static DriveInfo[] GetDrives() { int platform = (int)Environment.Platform; if (platform == 4 || platform == 128 || platform == 6) { return DriveInfo.UnixGetDrives(); } return DriveInfo.WindowsGetDrives(); } /// Returns a drive name as a string. /// The name of the drive. /// 1 // Token: 0x0600162B RID: 5675 RVA: 0x00055598 File Offset: 0x00053798 public override string ToString() { return this.Name; } // Token: 0x0600162C RID: 5676 [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool GetDiskFreeSpaceInternal(string pathName, out ulong freeBytesAvail, out ulong totalNumberOfBytes, out ulong totalNumberOfFreeBytes, out MonoIOError error); // Token: 0x0600162D RID: 5677 [MethodImpl(MethodImplOptions.InternalCall)] private static extern uint GetDriveTypeInternal(string rootPathName); // Token: 0x0400064A RID: 1610 private DriveInfo._DriveType _drive_type; // Token: 0x0400064B RID: 1611 private string drive_format; // Token: 0x0400064C RID: 1612 private string path; // Token: 0x020001AE RID: 430 private enum _DriveType { // Token: 0x0400064E RID: 1614 GenericUnix, // Token: 0x0400064F RID: 1615 Linux, // Token: 0x04000650 RID: 1616 Windows } } }