// All methods & properties can throw IOException
public sealed class UnixDriveInfo
{
- private Statvfs stat;
- private Fstab fstab;
+ private Native.Statvfs stat;
+ private Native.Fstab fstab;
public UnixDriveInfo (string mountPoint)
{
if (mountPoint == null)
throw new ArgumentNullException ("mountPoint");
- fstab = Syscall.getfsfile (mountPoint);
+ fstab = Native.Syscall.getfsfile (mountPoint);
if (fstab == null)
throw new ArgumentException ("mountPoint isn't valid: " + mountPoint);
// throws ArgumentException if driveName isn't valid
{
if (specialFile == null)
throw new ArgumentNullException ("specialFile");
- Fstab f = Syscall.getfsspec (specialFile);
+ Native.Fstab f = Native.Syscall.getfsspec (specialFile);
if (f == null)
throw new ArgumentException ("specialFile isn't valid: " + specialFile);
return new UnixDriveInfo (f);
}
- private UnixDriveInfo (Fstab fstab)
+ private UnixDriveInfo (Native.Fstab fstab)
{
this.fstab = fstab;
}
public long AvailableFreeSpace {
- get {Refresh (); return (long) (stat.f_bavail * stat.f_bsize);}
+ get {Refresh (); return Convert.ToInt64 (stat.f_bavail * stat.f_bsize);}
}
public string DriveFormat {
// set {}
}
- public ulong MaximumFilenameLength {
- get {Refresh (); return stat.f_namemax;}
+ public long MaximumFilenameLength {
+ get {Refresh (); return Convert.ToInt64 (stat.f_namemax);}
}
public static UnixDriveInfo[] GetDrives ()
{
// throws IOException, UnauthorizedAccessException (no permission)
ArrayList entries = new ArrayList ();
- Syscall.SetLastError ((Error) 0);
- lock (Syscall.fstab_lock) {
- int r = Syscall.setfsent ();
+ lock (Native.Syscall.fstab_lock) {
+ int r = Native.Syscall.setfsent ();
if (r != 1)
throw new IOException ("Error calling setfsent(3)", new UnixIOException ());
try {
- Fstab fs;
- while ((fs = Syscall.getfsent()) != null) {
+ Native.Fstab fs;
+ while ((fs = Native.Syscall.getfsent()) != null) {
// avoid virtual entries, such as "swap"
if (fs.fs_file.StartsWith ("/"))
entries.Add (new UnixDriveInfo (fs));
}
}
finally {
- Syscall.endfsent ();
+ Native.Syscall.endfsent ();
}
}
return (UnixDriveInfo[]) entries.ToArray (typeof(UnixDriveInfo));
private bool Refresh (bool throwException)
{
- int r = Syscall.statvfs (fstab.fs_file, out stat);
+ int r = Native.Syscall.statvfs (fstab.fs_file, out stat);
if (r == -1 && throwException) {
- Error e = Syscall.GetLastError ();
+ Native.Errno e = Native.Syscall.GetLastError ();
throw new IOException (UnixMarshal.GetErrorDescription (e),
UnixMarshal.CreateExceptionForError (e));
}