summaryrefslogtreecommitdiff
path: root/src/dosfns.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2000-12-07 14:53:45 +0000
committerEli Zaretskii <eliz@gnu.org>2000-12-07 14:53:45 +0000
commit1e938ebf05545734aad193ea283d5e163a99c169 (patch)
tree6d7866159eb4f52f78f2148dfc217059b5c558c6 /src/dosfns.c
parenta6b35f3774e0ea746d03e4d7adc66de79cbe9eb0 (diff)
downloademacs-1e938ebf05545734aad193ea283d5e163a99c169.tar.gz
(Ffile_system_info): New function.
(syms_of_dosfns): Defsubr it.
Diffstat (limited to 'src/dosfns.c')
-rw-r--r--src/dosfns.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/dosfns.c b/src/dosfns.c
index 25aede212ef..dd958041662 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -38,9 +38,12 @@ Boston, MA 02111-1307, USA. */
#include "dosfns.h"
#include "msdos.h"
#include "dispextern.h"
+#include "charset.h"
+#include "coding.h"
#include <dpmi.h>
#include <go32.h>
#include <dirent.h>
+#include <sys/vfs.h>
#ifndef __DJGPP_MINOR__
# define __tb _go32_info_block.linear_address_of_transfer_buffer;
@@ -508,6 +511,32 @@ x_set_title (f, name)
}
#endif /* !HAVE_X_WINDOWS */
+DEFUN ("file-system-info", Ffile_system_info, Sfile_system_info, 1, 1, 0,
+ "Return storage information about the file system FILENAME is on.\n\
+Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total\n\
+storage of the file system, FREE is the free storage, and AVAIL is the\n\
+storage available to a non-superuser. All 3 numbers are in bytes.\n\
+If the underlying system call fails, value is nil.")
+ (filename)
+ Lisp_Object filename;
+{
+ struct statfs stfs;
+ Lisp_Object encoded, value;
+
+ CHECK_STRING (filename, 0);
+ filename = Fexpand_file_name (filename, Qnil);
+ encoded = ENCODE_FILE (filename);
+
+ if (statfs (XSTRING (encoded)->data, &stfs))
+ value = Qnil;
+ else
+ value = list3 (make_float ((double) stfs.f_bsize * stfs.f_blocks),
+ make_float ((double) stfs.f_bsize * stfs.f_bfree),
+ make_float ((double) stfs.f_bsize * stfs.f_bavail));
+
+ return value;
+}
+
void
dos_cleanup (void)
{
@@ -536,6 +565,7 @@ syms_of_dosfns ()
defsubr (&Smsdos_set_keyboard);
defsubr (&Sinsert_startup_screen);
defsubr (&Smsdos_mouse_disable);
+ defsubr (&Sfile_system_info);
#ifndef HAVE_X_WINDOWS
defsubr (&Smsdos_mouse_p);
#endif