From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: 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 Organization: ThierryVolpiatto Message-ID: <87r5grxil6.fsf@tux.homenetwork> References: <87d3sp5olh.fsf@tux.homenetwork> <83aanm5dyk.fsf@gnu.org> <87pqwh3hiu.fsf@tux.homenetwork> <87hbhq97h0.fsf@tux.homenetwork> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1284819053 2826 80.91.229.12 (18 Sep 2010 14:10:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 18 Sep 2010 14:10:53 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 18 16:10:52 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Owy7w-0008CG-65 for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Sep 2010 16:10:52 +0200 Original-Received: from localhost ([127.0.0.1]:37520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Owy7v-0004wc-KE for geb-bug-gnu-emacs@m.gmane.org; Sat, 18 Sep 2010 10:10:51 -0400 Original-Received: from [140.186.70.92] (port=54950 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Owy7q-0004wF-8P for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 10:10:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Owy7o-00012Q-T8 for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 10:10:46 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59967) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Owy7o-00012H-Rm for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 10:10:44 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Owxsb-0000aJ-W1; Sat, 18 Sep 2010 09:55:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87d3sp5olh.fsf@tux.homenetwork> Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Sep 2010 13:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6995 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.12848180692239 (code B ref -1); Sat, 18 Sep 2010 13:55:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Sep 2010 13:54:29 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Owxs5-0000a4-5W for submit@debbugs.gnu.org; Sat, 18 Sep 2010 09:54:29 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Owxs2-0000Zz-TS for submit@debbugs.gnu.org; Sat, 18 Sep 2010 09:54:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwxuK-0006Jz-Nd for submit@debbugs.gnu.org; Sat, 18 Sep 2010 09:56:51 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:59265) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwxuK-0006Jt-Kt for submit@debbugs.gnu.org; Sat, 18 Sep 2010 09:56:48 -0400 Original-Received: from [140.186.70.92] (port=41410 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwxuJ-00033F-E4 for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 09:56:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwxuI-0006Iq-57 for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 09:56:47 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:44348) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwxuH-0006IV-Rv for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 09:56:46 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OwxuD-0008L9-DA for bug-gnu-emacs@gnu.org; Sat, 18 Sep 2010 15:56:41 +0200 Original-Received: from 46.78.88-79.rev.gaoland.net ([79.88.78.46]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 18 Sep 2010 15:56:41 +0200 Original-Received: from thierry.volpiatto by 46.78.88-79.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 18 Sep 2010 15:56:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 53 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 46.78.88-79.rev.gaoland.net User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:88PysMTULsFepXHAGSTQSBZzoLw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 18 Sep 2010 09:55:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40288 Archived-At: Thierry Volpiatto 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