コード例 #1
0
    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
    }
コード例 #2
0
ファイル: Portable.cs プロジェクト: secforks/Bless
    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();
        }
    }
コード例 #3
0
 public static bool TryCopy(IntPtr source, out Statvfs destination)
 {
     return(ToStatvfs(source, out destination) == 0);
 }
コード例 #4
0
 private static extern int ToStatvfs(IntPtr source, out Statvfs destination);
コード例 #5
0
 public static bool TryCopy(ref Statvfs source, IntPtr destination)
 {
     return(FromStatvfs(ref source, destination) == 0);
 }
コード例 #6
0
 private static extern int FromStatvfs(ref Statvfs source, IntPtr destination);
コード例 #7
0
ファイル: MainWindow.cs プロジェクト: sebclarke/Glomp
    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);
            }
        }
    }
コード例 #8
0
 public static int statvfs(
     string path, out Statvfs buf)
 {
     throw new System.NotImplementedException();
 }
コード例 #9
0
 public static int fstatvfs(int fd, out Statvfs buf)
 {
     throw new System.NotImplementedException();
 }
コード例 #10
0
 private static int ToStatvfs(IntPtr source, out Statvfs destination)
 {
     throw new System.NotImplementedException();
 }
コード例 #11
0
 private static int FromStatvfs(ref Statvfs source, IntPtr destination)
 {
     throw new System.NotImplementedException();
 }
コード例 #12
0
		public static extern int fstatvfs (int fd, out Statvfs buf);
コード例 #13
0
		public static extern int statvfs (
		[MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileNameMarshaler))]
		string path, out Statvfs buf);
コード例 #14
0
    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);
            }
        }
    }