mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 14:30:34 +02:00
Document ‘in-vicinity’.
* module/ice-9/boot-9.scm (in-vicinity): Rename ‘vicinity’ to ‘directory’. Add docstring. * doc/ref/posix.texi (File System): Document it. Suggested-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
parent
af0123c8b9
commit
755f703dcb
2 changed files with 13 additions and 5 deletions
|
@ -1223,6 +1223,11 @@ valid separators. Thus, programs should not assume that
|
||||||
separator---e.g., when extracting the components of a file name.
|
separator---e.g., when extracting the components of a file name.
|
||||||
@end defvr
|
@end defvr
|
||||||
|
|
||||||
|
@deffn {Scheme Procedure} in-vicinity @var{directory} @var{file}
|
||||||
|
Concatenate @var{directory} and @var{file}, adding
|
||||||
|
@code{file-name-separator-string} (by default slash) in between if it is
|
||||||
|
not already present. This helps create file names.
|
||||||
|
@end deffn
|
||||||
|
|
||||||
@node User Information
|
@node User Information
|
||||||
@subsection User Information
|
@subsection User Information
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
;;; -*- mode: scheme; coding: utf-8; -*-
|
;;; -*- mode: scheme; coding: utf-8; -*-
|
||||||
|
|
||||||
;;;; Copyright (C) 1995-2014, 2016-2024 Free Software Foundation, Inc.
|
;;;; Copyright (C) 1995-2014, 2016-2025 Free Software Foundation, Inc.
|
||||||
;;;;
|
;;;;
|
||||||
;;;; This library is free software; you can redistribute it and/or
|
;;;; This library is free software; you can redistribute it and/or
|
||||||
;;;; modify it under the terms of the GNU Lesser General Public
|
;;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -2144,12 +2144,15 @@ non-locally, that exit determines the continuation."
|
||||||
(file-name-separator-at-index? 2)
|
(file-name-separator-at-index? 2)
|
||||||
(file-name-separator-at-index? 0)))))))
|
(file-name-separator-at-index? 0)))))))
|
||||||
|
|
||||||
(define (in-vicinity vicinity file)
|
(define (in-vicinity directory file)
|
||||||
(let ((tail (let ((len (string-length vicinity)))
|
"Concatenate @var{directory} and @var{file}, adding
|
||||||
|
@code{file-name-separator-string} (by default slash) in between if it is
|
||||||
|
not already present. This helps create file names."
|
||||||
|
(let ((tail (let ((len (string-length directory)))
|
||||||
(if (zero? len)
|
(if (zero? len)
|
||||||
#f
|
#f
|
||||||
(string-ref vicinity (- len 1))))))
|
(string-ref directory (- len 1))))))
|
||||||
(string-append vicinity
|
(string-append directory
|
||||||
(if (or (not tail) (file-name-separator? tail))
|
(if (or (not tail) (file-name-separator? tail))
|
||||||
""
|
""
|
||||||
file-name-separator-string)
|
file-name-separator-string)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue