GNU bug report logs - #6995
24.0.50; get-free-disk-space doesn't return available space in dired

Previous Next

Package: emacs;

Reported by: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>

Date: Tue, 7 Sep 2010 20:01:02 UTC

Severity: normal

Found in version 24.0.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Sat, 18 Sep 2010 15:54:45 +0200
Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:

> With the windows stuff and no call when remote:
>
> (defun get-free-disk-space (dir)
>   (unless (file-remote-p dir)
>     ;; Try to find the number of free blocks.  Non-Posix systems don't
>     ;; always have df, but might have an equivalent system call.
>     (if (fboundp 'file-system-info)
> 	(let ((fsinfo (file-system-info dir)))
> 	  (if fsinfo
> 	      (format "%.0f" (/ (nth 2 fsinfo) 1024))))
>         (when (executable-find directory-free-space-program)
>           (let* ((data   (with-temp-buffer
>                            (call-process directory-free-space-program
>                                          nil t nil
>                                          directory-free-space-args
>                                          dir)
>                            (split-string (buffer-string) "\n" t)))
>                  (values (cdr (split-string (second data)))))
>             (when data (nth 2 values)))))))
>

But may be it's better to have other infos from output of df available:

(defun get-free-disk-space (dir &optional human)
  (unless (file-remote-p dir)
    ;; That is for windows.
    (if (fboundp 'file-system-info)
	(let ((fsinfo (file-system-info dir)))
	  (if fsinfo
	      (format "%.0f" (/ (nth 2 fsinfo) 1024))))
        ;; And this is for Unix/GNULinux.
        (when (executable-find directory-free-space-program)
          (getf (tv-get-disk-info dir human) :available)))))

(defun tv-get-disk-info (dir &optional human)
  (let* (args    (if human
                     (concat directory-free-space-args "h")
                     directory-free-space-args)
         (data   (with-temp-buffer
                   (call-process directory-free-space-program
                                 nil t nil args dir)
                   (split-string (buffer-string) "\n" t)))
         (values (split-string (second data))))
    (loop for i in '(:device :blocks :used :available :capacity :mount-point)
       for j in values
       append (list i j))))

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





This bug report was last modified 14 years and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.