public static long GetAvailableDiskSpace(string path) { #if ENABLE_UNIX_SPECIFIC // get info about the device the file will be saved on Mono.Unix.Native.Statvfs stat = new Mono.Unix.Native.Statvfs(); Mono.Unix.Native.Syscall.statvfs(path, out stat); long freeSpace = (long)(stat.f_bavail * stat.f_bsize); return(freeSpace); #else throw new System.NotImplementedException(); #endif }
public static long GetAvailableDiskSpace(string path) { OperatingSystem os = Environment.OSVersion; PlatformID pid = os.Platform; if (pid == PlatformID.Unix) { // get info about the device the file will be saved on Mono.Unix.Native.Statvfs stat = new Mono.Unix.Native.Statvfs(); Mono.Unix.Native.Syscall.statvfs(path, out stat); long freeSpace = (long)(stat.f_bavail * stat.f_bsize); return(freeSpace); } else { throw new NotImplementedException(); } }
public static bool TryCopy(IntPtr source, out Statvfs destination) { return(ToStatvfs(source, out destination) == 0); }
private static extern int ToStatvfs(IntPtr source, out Statvfs destination);
public static bool TryCopy(ref Statvfs source, IntPtr destination) { return(FromStatvfs(ref source, destination) == 0); }
private static extern int FromStatvfs(ref Statvfs source, IntPtr destination);
private void UpdateDetailsBox() { if(detailsBox.Visible) { FileNode active = slices.ActiveSlice.GetActiveNode(); GLib.File activeFile = GLib.FileFactory.NewForPath(active.File); if(!active.IsDirectory) { detailLabelContents.Visible = false; detailValueContents.Visible = false; detailEntryName.Text = active.FileName; String infoString = "standard::size,standard::content-type,filesystem:free,time::modified,time::access,owner::user,owner::group"; GLib.FileInfo info = activeFile.QueryInfo(infoString, FileQueryInfoFlags.None, null); String sizeString = info.GetAttributeAsString("standard::size"); detailValueSize.Text = String.Format(new FileSizeFormatProvider(), "{0:fs}", Convert.ToUInt64(sizeString)); detailValueType.Text = Gnome.Vfs.Mime.GetDescription(info.ContentType) + " (" + info.ContentType + ")"; DateTime tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::access"))); detailValueAccessed.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::modified"))); detailValueModified.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); detailValueSpace.Text = String.Format(new FileSizeFormatProvider(), "{0:fs}", Convert.ToUInt64(info.GetAttributeString("filesystem:free"))); detailValueOwner.Text = info.GetAttributeString("owner::user"); detailValueGroup.Text = info.GetAttributeString("owner::group"); } else { detailLabelContents.Visible = true; detailValueContents.Visible = true; detailValueSize.Text = "[unsupported]"; detailEntryName.Text = active.FileName; detailValueType.Text = "Directory"; String infoString = "time::modified,time::access,owner::user,owner::group"; GLib.FileInfo info = activeFile.QueryInfo(infoString, FileQueryInfoFlags.None, null); DateTime tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::access"))); detailValueAccessed.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::modified"))); detailValueModified.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); detailValueContents.Text = active.NumChildren + " items (" + active.NumDirs + " folders)"; detailValueOwner.Text = info.GetAttributeString("owner::user"); detailValueGroup.Text = info.GetAttributeString("owner::group"); } Mono.Unix.Native.Statvfs fsbuf = new Mono.Unix.Native.Statvfs(); Mono.Unix.Native.Syscall.statvfs(slices.ActiveSlice.GetActiveNode().File, out fsbuf); detailValueSpace.Text = String.Format(new FileSizeFormatProvider(), "{0:fs}", fsbuf.f_bavail * fsbuf.f_bsize); UpdateDetailPermissions(); if(detailValueOwner.Text == Mono.Unix.UnixUserInfo.GetRealUser().UserName) { EnableDetailPermissions(true); } else { EnableDetailPermissions(false); } } }
public static int statvfs( string path, out Statvfs buf) { throw new System.NotImplementedException(); }
public static int fstatvfs(int fd, out Statvfs buf) { throw new System.NotImplementedException(); }
private static int ToStatvfs(IntPtr source, out Statvfs destination) { throw new System.NotImplementedException(); }
private static int FromStatvfs(ref Statvfs source, IntPtr destination) { throw new System.NotImplementedException(); }
public static extern int fstatvfs (int fd, out Statvfs buf);
public static extern int statvfs ( [MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))] string path, out Statvfs buf);
private void UpdateDetailsBox() { if (detailsBox.Visible) { FileNode active = slices.ActiveSlice.GetActiveNode(); GLib.File activeFile = GLib.FileFactory.NewForPath(active.File); if (!active.IsDirectory) { detailLabelContents.Visible = false; detailValueContents.Visible = false; detailEntryName.Text = active.FileName; String infoString = "standard::size,standard::content-type,filesystem:free,time::modified,time::access,owner::user,owner::group"; GLib.FileInfo info = activeFile.QueryInfo(infoString, FileQueryInfoFlags.None, null); String sizeString = info.GetAttributeAsString("standard::size"); detailValueSize.Text = String.Format(new FileSizeFormatProvider(), "{0:fs}", Convert.ToUInt64(sizeString)); detailValueType.Text = Gnome.Vfs.Mime.GetDescription(info.ContentType) + " (" + info.ContentType + ")"; DateTime tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::access"))); detailValueAccessed.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::modified"))); detailValueModified.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); detailValueSpace.Text = String.Format(new FileSizeFormatProvider(), "{0:fs}", Convert.ToUInt64(info.GetAttributeString("filesystem:free"))); detailValueOwner.Text = info.GetAttributeString("owner::user"); detailValueGroup.Text = info.GetAttributeString("owner::group"); } else { detailLabelContents.Visible = true; detailValueContents.Visible = true; detailValueSize.Text = "[unsupported]"; detailEntryName.Text = active.FileName; detailValueType.Text = "Directory"; String infoString = "time::modified,time::access,owner::user,owner::group"; GLib.FileInfo info = activeFile.QueryInfo(infoString, FileQueryInfoFlags.None, null); DateTime tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::access"))); detailValueAccessed.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); tempTime = NodeManager.ConvertFromUnixTimestamp(Convert.ToUInt64(info.GetAttributeAsString("time::modified"))); detailValueModified.Text = tempTime.ToString("ddd, dd MMM yyyy HH':'mm':'ss"); detailValueContents.Text = active.NumChildren + " items (" + active.NumDirs + " folders)"; detailValueOwner.Text = info.GetAttributeString("owner::user"); detailValueGroup.Text = info.GetAttributeString("owner::group"); } Mono.Unix.Native.Statvfs fsbuf = new Mono.Unix.Native.Statvfs(); Mono.Unix.Native.Syscall.statvfs(slices.ActiveSlice.GetActiveNode().File, out fsbuf); detailValueSpace.Text = String.Format(new FileSizeFormatProvider(), "{0:fs}", fsbuf.f_bavail * fsbuf.f_bsize); UpdateDetailPermissions(); if (detailValueOwner.Text == Mono.Unix.UnixUserInfo.GetRealUser().UserName) { EnableDetailPermissions(true); } else { EnableDetailPermissions(false); } } }