summaryrefslogtreecommitdiff
path: root/libguile/filesys.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-27Identify scm_is_vector with scm_is_simple_vectorDaniel Llorens1-5/+5
This patch fixes the bug (vector-ref #1@1(1 2 3) 1) => 2. * libguile/vectors.c: (scm_is_vector): just as scm_is_simple_vector. * libguile/filesys.c, libguile/random.c, libguile/stime.c, libguile/trees.c, libguile/validate.h: use scm_is_vector instead of scm_is_simple_vector. * libguile/sort.c - scm_restricted_vector_sort_x: use scm_array_handle_writable_elements instead of scm_vector_writable_elements, to work with non-vector rank-1 array objects. - scm_sort_x: check for scm_is_array instead of scm_is_vector. Rank check is in restricted_vector_sort_x. - scm_sort: ditto. - scm_stable_sort_x: like scm_restricted_vector_sort_x. - scm_stable_sort: like scm_sort. * test-suite/tests/arrays.test: fix header. * test-suite/tests/random.test: new coverage test covering random:normal-vector! * test-suite/Makefile.am: include random.test in make check.
2013-11-28More private-gc excisionsAndy Wingo1-11/+14
* libguile/private-gc.h (SCM_DOUBLECELL_ALIGNED_P): Remove; unused. * libguile/filesys.c (MAX, MIN): Move definitions here, from private-gc.h. (scm_sendfile, scm_readdir): Adapt uses of SCM_MAX and SCM_MIN to use MAX or MIN.
2013-04-14Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-17/+44
Conflicts: GUILE-VERSION libguile/array-map.c libguile/fports.h libguile/gc.h libguile/inline.h libguile/ports.c libguile/ports.h libguile/print.c libguile/r6rs-ports.c libguile/read.c test-suite/tests/00-socket.test
2013-04-08Miscellaneous 'sendfile' fixes and improved tests.Mark H Weaver1-7/+13
* libguile/filesys.c (scm_sendfile): In Linux-style sendfile(2) code, if EINTR or EAGAIN occurs, set result to 1 (not 0) so that we actually keep going. In non-sendfile(2) code, deal gracefully with short reads due to EOF. * test-suite/tests/filesys.test ("sendfile"): Use 'let*' to guarantee the needed order of operations: write (test-file) and then read it. Add code to check the written data (not just the returned length) in all tests, including the cases that hit EOF prematurely.
2013-04-07Change `sendfile' to loop until everything has been sent.Ludovic Courtès1-13/+34
* libguile/filesys.c (scm_sendfile)[HAVE_SYS_SENDFILE_H && HAVE_SENDFILE]: Compare RESULT with C_COUNT. Loop until C_COUNT bytes have been sent. * doc/ref/posix.texi (File System): Update the description. Explain the new semantics. * test-suite/tests/filesys.test ("sendfile"): Rewrite using `pass-if-equal'. Check the return value for all the tests. ["file with offset past the end", "file with offset near the end"]: New tests.
2013-03-28Merge remote-tracking branch 'origin/stable-2.0'Mark H Weaver1-107/+145
Conflicts: configure.ac libguile/deprecated.c libguile/deprecated.h libguile/filesys.h libguile/fluids.c libguile/fports.c libguile/gc.c libguile/guile.c libguile/numbers.c libguile/objcodes.c libguile/r6rs-ports.c libguile/smob.c libguile/socket.c libguile/threads.h module/language/scheme/decompile-tree-il.scm module/language/tree-il/peval.scm test-suite/tests/syncase.test
2013-03-25sendfile: Make sure we have a Linux-style `sendfile'.Ludovic Courtès1-1/+3
* libguile/filesys.c (scm_sendfile): Change conditional to HAVE_SYS_SENDFILE_H && HAVE_SENDFILE.
2013-03-25sendfile: Check return value of `lseek'.Ludovic Courtès1-1/+4
* libguile/filesys.c (scm_sendfile): Check return value of `lseek_or_lseek64', and use `SCM_SYSERROR' upon error.
2013-03-22Add bindings for `sendfile'.Ludovic Courtès1-0/+91
* configure.ac: Check for <sys/sendfile.h> and `sendfile'. * libguile/filesys.c (scm_sendfile): New function. * libguile/filesys.h (scm_sendfile): New declaration. * test-suite/tests/filesys.test ("sendfile"): New test prefix. * doc/ref/posix.texi (File System): Document `sendfile'.
2013-03-09simplify filesys.c via gnulib's select and fstat modulesAndy Wingo1-53/+10
* libguile/filesys.c: Instead of using scm_std_select, just use select, relying on gnulib to provide it to us. Likewise, rely on fstat.
2013-03-04Use `scm_is_eq' in filesys.c.Ludovic Courtès1-2/+2
* libguile/filesys.c (is_file_name_separator): Use `scm_is_eq' instead of `=='. Fixes <http://hydra.nixos.org/build/4261579>.
2013-02-24cleanup to filesys.c's handling of file name separatorsAndy Wingo1-49/+22
* libguile/filesys.c (is_file_name_separator): New helper, as in load.c. (scm_dirname, scm_basename, scm_i_relativize_path): Use is_file_name_separator.
2013-02-24simplify scm_stat on mingwAndy Wingo1-6/+0
* libguile/filesys.c (scm_stat): Don't munge the filename on MinGW; gnulib does that for us.
2013-02-19copy-file and load-objcode use O_BINARYAndy Wingo1-1/+1
* libguile/filesys.c (scm_copy_file): * libguile/objcodes.c (scm_load_objcode): Use O_BINARY. Thanks to Eli Zaretskii for the patch.
2013-02-19better handling of windows file name conventionsAndy Wingo1-1/+19
* libguile/filesys.c (scm_system_file_name_convention): New function. Exported to Scheme only. * module/ice-9/boot-9.scm (file-name-separator?, absolute-file-name?): New predicates. (file-name-separator-string): New global variable. (in-vicinity): Use the new procedures. (load-user-init, try-module-autoload): Use file-name-separator-string. (load-in-vicinity): Update canonical->suffix. Consistently use the term "file name" throughout. * module/ice-9/psyntax.scm (include): Use global `absolute-file-name?'. * module/ice-9/psyntax-pp.scm: Regenerate.
2012-07-06Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-3/+3
Conflicts: libguile/expand.c libguile/hashtab.c libguile/ports.c libguile/vectors.c libguile/weaks.c module/language/ecmascript/compile-tree-il.scm module/language/tree-il/effects.scm module/language/tree-il/fix-letrec.scm module/language/tree-il/peval.scm test-suite/tests/peval.test
2012-07-06add check for fchmodAndy Wingo1-2/+3
* configure.ac: Add a check for fchmod. * libguile/filesys.c (scm_chmod): Guard the fchmod case with HAVE_FCHMOD.
2012-07-06remove mkdir alias in filesys.c for mingwAndy Wingo1-1/+0
* libguile/filesys.c (mkdir): Remove alias, as gnulib handles this for us.
2012-05-21Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-22/+30
Conflicts: module/language/tree-il/analyze.scm module/language/tree-il/effects.scm module/language/tree-il/fix-letrec.scm module/language/tree-il/peval.scm test-suite/tests/cse.test test-suite/tests/peval.test
2012-05-15Fix relative file name canonicalization with empty %LOAD-PATH entries.Ludovic Courtès1-22/+30
* libguile/filesys.c (scm_i_relativize_path): Don't attempt to canonicalize when encountering an entry of IN_PATH that is the empty string. * test-suite/tests/ports.test (with-load-path): New macro. ("%file-port-name-canonicalization"): New test prefix.
2012-02-08Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-24/+25
Conflicts: GUILE-VERSION libguile/gc-malloc.c libguile/ports.c
2012-02-02Improve the usage of variable names in C docstrings.Bake Timmons1-24/+25
* libguile/alist.c: * libguile/array-map.c: * libguile/arrays.c: * libguile/bitvectors.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/generalized-arrays.c: * libguile/hashtab.c: * libguile/ioext.c: * libguile/load.c: * libguile/numbers.c: * libguile/ports.c: * libguile/posix.c: * libguile/print.c: * libguile/procprop.c: * libguile/promises.c: * libguile/simpos.c: * libguile/socket.c: * libguile/srfi-1.c: * libguile/srfi-13.c: * libguile/srfi-14.c: * libguile/stacks.c: * libguile/stime.c: * libguile/strings.c: * libguile/struct.c: * libguile/symbols.c: * libguile/threads.c: * libguile/weak-table.c: * libguile/weak-vector.c: Make the variable names in the C docstrings more consistent. Replace a few instances of @var with @code when appropriate.
2012-01-30Merge commit '9b0975f1dc41ddd10d81fb5b0965b9e9a54ef37a'Andy Wingo1-27/+5
Conflicts: libguile/foreign.c module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm
2012-01-16Update Gnulib to v0.0-6827-g39c3009; use the `dirfd' module.Ludovic Courtès1-27/+5
* m4/gnulib-cache.m4: Use `dirfd'. * libguile/filesys.c: Include Gnulib's <dirent.h> directly. (dirfd): Remove. Suggested by Bruno Haible <bruno@clisp.org>.
2011-11-08locking for putc, putsAndy Wingo1-4/+4
* libguile/ports.c (scm_putc, scm_puts): * libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into _unlocked and locked variants. Change all callers to use the _unlocked versions.
2011-11-08locking on port buffering operationsAndy Wingo1-1/+1
* libguile/ports.c (scm_fill_input_unlocked, scm_fill_input) (scm_end_input, scm_end_input_unlocked, scm_flush) (scm_flush_unlocked): Add locking and _unlocked variants. * libguile/filesys.c: * libguile/fports.c: * libguile/gdbint.c: * libguile/r6rs-ports.c: * libguile/read.c: * libguile/rw.c: Adapt callers to use _unlocked variants.
2011-07-13Fix `open' mode bits on GNU/Hurd.Ludovic Courtès1-9/+14
* libguile/filesys.c (scm_open): Fix check for read-write flags for systems such as GNU/Hurd, where O_RDWR == (O_WRONLY | O_RDONLY) and O_RDONLY != 0.
2011-07-13Define `O_NOTRANS' on GNU/Hurd.Ludovic Courtès1-1/+4
* libguile/filesys.c (scm_init_filesys): Define `O_NOTRANS' when available.
2011-06-30HAVE_POSIX warning fixAndy Wingo1-0/+2
* libguile/filesys.c (scm_dir_free, scm_dir_print): Don't compile when not HAVE_POSIX.
2011-06-17remove win32-dirent.[ch]Andy Wingo1-5/+1
* libguile/win32-dirent.c: * libguile/win32-dirent.h: Remove these files. MinGW has opendir and readdir support, I hear. * configure.ac: * libguile/filesys.c: * libguile/Makefile.am: Adapt.
2011-05-20fix compile error in mingw fstat socket detectionAndy Wingo1-1/+1
* libguile/filesys.c (fstat_Win32) [__MINGW32__]: Apparently there is no _S_IFSOCK on mingw32. Thanks to Volker Grabsch for the report.
2011-04-25Compile more file system related procedures when `--disable-posix'.Ludovic Courtès1-202/+200
* libguile/filesys.c (scm_tc16_dir, scm_directory_stream_p, scm_opendir, scm_readdir, scm_rewinddir, scm_closedir, scm_dir_print, scm_dir_free, scm_lstat): Compile unconditionally.
2011-04-15Allow compilation with `--disable-posix'.Ludovic Courtès1-189/+314
Reported by Dmitry Dzhus <dima@dzhus.org>. * configure.ac: Remove `AC_LIBOBJ([filesys])'. Document `--disable-posix' as omitting non-essential POSIX interfaces. * libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Add `filesys.c'. (DOT_DOC_FILES): Add `filesys.doc'. (EXTRA_libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): Remove `filesys.c'. * libguile/posix.c (scm_mkstemp, scm_access): Move to `filesys.c'. (scm_init_posix): Move `R_OK' etc. to `filesys.c'. * libguile/filesys.c (scm_chown, scm_chmod, scm_umask, scm_open_fdes, scm_open, scm_close, scm_close_fdes, scm_link, scm_tc16_dir, scm_directory_stream_p, scm_opendir, scm_readdir, scm_rewinddir, scm_closedir, scm_dir_print, scm_dir_free, scm_chdir, scm_getcwd, set_element, fill_select_type, get_element, retrieve_select_type, scm_select, scm_fcntl, scm_fsync, scm_symlink, scm_readlink, scm_lstat, scm_copy_file): Conditionalize on HAVE_POSIX. (scm_mkstemp, scm_access): New functions. (scm_init_filesys): Conditionalize `scm_tc16_dir', `O_RDONLY', etc. on HAVE_POSIX. Define `R_OK', `W_OK', etc. * libguile/fports.c (fport_print): Use `scm_ttyname' only when HAVE_POSIX. * libguile/i18n.c (lock_locale_mutex, unlock_locale_mutex): New functions. Update users of `scm_i_locale_mutex' to use them. * libguile/init.c (scm_i_init_guile): Always call `scm_init_filesys'. * meta/guile-tools.in (main): Use `setlocale' only when it is defined. * module/ice-9/boot-9.scm: Always load `ice-9/posix'.
2011-03-17fix code that causes warnings on gcc 4.6Andy Wingo1-4/+1
* libguile/arrays.c (scm_i_read_array): * libguile/backtrace.c (display_backtrace_body): * libguile/filesys.c (scm_readdir) * libguile/i18n.c (chr_to_case): * libguile/ports.c (register_finalizer_for_port): * libguile/posix.c (scm_nice): * libguile/stacks.c (scm_make_stack): Clean up a number of set-but-unused vars. Thanks to Douglas Mencken for the report. * libguile/numbers.c (scm_log, scm_exp): Fix a few #if cases that should be #ifdef.
2010-04-19filesystem trickery to scm_i_relativize_path in filesys.c; bugfix.Andy Wingo1-0/+46
* libguile/filesys.h: * libguile/filesys.c (scm_i_relativize_path): New function, moved here from fports.c. Internal for now; we can make it external though if people like its interface. * libguile/fports.c (fport_canonicalize_filename): Move all of the tricky bits to filesys.c. Also fixes a bug in which a delimiter wasn't stripped.
2010-04-19formatting fixAndy Wingo1-1/+2
* libguile/filesys.c (scm_canonicalize_path): Format fix.
2010-04-09remove libguile/lang.h, deprecate %nil (in favor of #nil)Andy Wingo1-2/+1
* libguile/Makefile.am: * libguile/init.c: * libguile/lang.c: * libguile/lang.h: Remove lang.c and lang.h. * libguile/pairs.h (SCM_NIL_P, SCM_NULL_OR_NIL_P): Moved here. * module/ice-9/deprecated.scm (%nil): %nil definition moved here. * libguile/alist.c: * libguile/async.c: * libguile/backtrace.c: * libguile/boolean.c: * libguile/dynl.c: * libguile/eval.c: * libguile/filesys.c: * libguile/fluids.c: * libguile/list.c: * libguile/load.c: * libguile/options.c: * libguile/posix.c: * libguile/print.c: * libguile/promises.c: * libguile/sort.c: * libguile/throw.c: * libguile/trees.c: * libguile/vectors.c: * libguile/vm.c: * libguile/weaks.c: * srfi/srfi-1.c: <libguile/lang.h> references removed.
2010-01-17nanosecond timestamp support in stat and utimeAndy Wingo1-1/+16
* libguile/posix.h: * libguile/posix.c (scm_utime): Add optional nanosecond arguments. This is an incompatible change on the C level, but it's unlikely people are using this POSIX wrapper function, because they would just use the POSIX function directly. Hopefully, anyway. * module/system/base/compile.scm (call-with-output-file/atomic): Propagate source timestamps to targets with nanosecond precision, if available. Fixes build on systems with ext4 filesystems. * libguile/filesys.c (scm_stat2scm): * module/ice-9/posix.scm (stat:atimensec, stat:mtimensec) (stat:ctimensec): Add three new elements to Scheme stat structures, for nanosecond-level timestamps. * configure.ac: Add checks for utimensat, and for nanosecond fields in struct stat. We should switch to using Gnulib things for these, though. * doc/ref/posix.texi (File System): Add documentation for utime's additional arguments, and nanosecond stat timestamp accessors.
2009-12-15Use Gnulib's `sys_stat' module; update Gnulib.Ludovic Courtès1-63/+0
* .x-sc_prohibit_S_IS_definition: New file. * m4/gnulib-cache.m4: Add `sys_stat'. * libguile/filesys.c: Remove `S_IS*' macro definitions for Ultrix and MinGW.
2009-12-08SCM_CELL in filesys.[ch]Andy Wingo1-8/+8
* libguile/filesys.h (SCM_DIR_FLAG_OPEN, SCM_DIR_OPEN_P) * libguile/filesys.c (scm_readdir, scm_rewinddir, scm_closedir) (scm_dir_print, scm_dir_free): Fix SCM_CELL macro usage.
2009-12-05remove a bunch of needless scm_permanent_object callsAndy Wingo1-1/+1
* libguile/array-handle.c: * libguile/bytevectors.c: * libguile/deprecated.c: * libguile/eval.c: * libguile/feature.c: * libguile/filesys.c: * libguile/gc.c: * libguile/gdbint.c: * libguile/goops.c: * libguile/instructions.c: * libguile/load.c: * libguile/modules.c: * libguile/numbers.c: * libguile/options.c: * libguile/ports.c: * libguile/scmsigs.c: * libguile/srcprop.c: * libguile/srfi-4.c: * libguile/stacks.c: * libguile/threads.c: * libguile/vm.c: Remove calls to scm_permanent_object, as they are no longer needed with the BDW GC.
2009-11-16Use Gnulib's `inet_ntop' and `inet_pton' modules.Ludovic Courtès1-2/+2
* m4/gnulib-cache.m4: Add `inet_ntop' and `inet_pton'. * configure.ac: Don't check for `inet_ntop' and `inet_pton'. * libguile/socket.c (scm_inet_pton, scm_inet_ntop): Compile regardless of `HAVE_INET_PTON' and `HAVE_INET_NTOP' respectively. * libguile/filesys.c: Use <stdlib.h> instead of <canonicalize.h>.
2009-08-20Use string accessors in scm_basename and scm_dirnameMichael Gran1-21/+39
* libguile/filesys.c (basename, dirname): don't unpack strings. Use string accessor functions.
2009-06-19new function: canonicalize-path. use when autocompilingAndy Wingo1-0/+22
* libguile/filesys.h: * libguile/filesys.c (scm_canonicalize_path): New function, canonicalize-path. * module/system/base/compile.scm (compiled-file-name): Canonicalize the filename so that compiling e.g. ../foo.scm doesn't compile to ~/.guile-ccache/1.9/../foo.scm.
2009-06-17Change Guile license to LGPLv3+Neil Jerram1-6/+7
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2009-06-03add exception-on-error optional arg to `stat' in schemeAndy Wingo1-11/+21
* libguile/filesys.h: * libguile/filesys.c (scm_stat): Add optional arg, exception-on-error, which if #f (not the default) will just return #f instead of raising an exception if the stat fails.
2008-09-13Include <config.h> in all C files; use `#ifdef HAVE_CONFIG_H' rather than `#if'.Ludovic Courtès1-1/+1
2008-08-20Never define `_GNU_SOURCE' explicitly since `AC_USE_SYSTEM_EXTENSIONS'Ludovic Courtès1-1/+0
takes care of it. Conflicts: ChangeLog configure.in libguile/eval.c libguile/srfi-14.c libguile/threads.c
2007-07-29Changes from arch/CVS synchronizationLudovic Courtès1-17/+1
2007-01-15merge from 1.8Kevin Ryde1-20/+20