streamly-fsevents (empty) → 0.1.0
raw patch · 20 files changed
+9235/−0 lines, 20 filesdep +Win32dep +basedep +containerssetup-changed
Dependencies added: Win32, base, containers, directory, filepath, fusion-plugin, hspec, mtl, streamly, streamly-core, streamly-fsevents, temporary
Files
- Changelog.md +5/−0
- LICENSE +95/−0
- README.md +2/−0
- Setup.hs +6/−0
- configure +4317/−0
- configure.ac +23/−0
- src/Streamly/FileSystem/Event.hs +45/−0
- src/Streamly/Internal/FS/Event.hs +244/−0
- src/Streamly/Internal/FS/Event/Darwin.c +287/−0
- src/Streamly/Internal/FS/Event/Darwin.h +63/−0
- src/Streamly/Internal/FS/Event/Darwin.hs +1111/−0
- src/Streamly/Internal/FS/Event/Linux.hs +1278/−0
- src/Streamly/Internal/FS/Event/Windows.hs +618/−0
- src/config.h.in +43/−0
- streamly-fsevents.cabal +288/−0
- test/Streamly/Test/FileSystem/Event.hs +28/−0
- test/Streamly/Test/FileSystem/Event/Common.hs +437/−0
- test/Streamly/Test/FileSystem/Event/Darwin.hs +86/−0
- test/Streamly/Test/FileSystem/Event/Linux.hs +208/−0
- test/Streamly/Test/FileSystem/Event/Windows.hs +51/−0
+ Changelog.md view
@@ -0,0 +1,5 @@+# Changelog++## 0.1.0++- Initial release
+ LICENSE view
@@ -0,0 +1,95 @@+Copyright (c) 2017, Composewell Technologies+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice,+this list of conditions and the following disclaimer in the documentation+and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors+may be used to endorse or promote products derived from this software without+specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.++-------------------------------------------------------------------------------+fsnotify-0.3.0.1 (http://hackage.haskell.org/package/fsnotify-0.3.0.1/)+-------------------------------------------------------------------------------+Copyright (c) 2012, Mark Dittmer++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Mark Dittmer nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.++-------------------------------------------------------------------------------+hfsevents-0.1.6 (http://hackage.haskell.org/package/hfsevents-0.1.6)+-------------------------------------------------------------------------------+Copyright (c) 2012, Luite Stegeman++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Luite Stegeman nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,2 @@+Please refer to the [streamly](https://github.com/composewell/streamly/blob/master/docs/User/Project/README.md)+package for tutorials and other documentation.
+ Setup.hs view
@@ -0,0 +1,6 @@+module Main (main) where++import Distribution.Simple++main :: IO ()+main = defaultMainWithHooks autoconfUserHooks
+ configure view
@@ -0,0 +1,4317 @@+#! /bin/sh+# Guess values for system-dependent variables and create Makefiles.+# Generated by GNU Autoconf 2.71 for streamly 0.11.0.+#+# Report bugs to <streamly@composewell.com>.+#+#+# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation,+# Inc.+#+#+# This configure script is free software; the Free Software Foundation+# gives unlimited permission to copy, distribute and modify it.+## -------------------- ##+## M4sh Initialization. ##+## -------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+as_nop=:+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else $as_nop+ case `(set -o) 2>/dev/null` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac+fi++++# Reset variables that may have inherited troublesome values from+# the environment.++# IFS needs to be set, to space, tab, and newline, in precisely that order.+# (If _AS_PATH_WALK were called with IFS unset, it would have the+# side effect of setting IFS to empty, thus disabling word splitting.)+# Quoting is to prevent editors from complaining about space-tab.+as_nl='+'+export as_nl+IFS=" "" $as_nl"++PS1='$ '+PS2='> '+PS4='+ '++# Ensure predictable behavior from utilities with locale-dependent output.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# We cannot yet rely on "unset" to work, but we need these variables+# to be unset--not just set to an empty or harmless value--now, to+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct+# also avoids known problems related to "unset" and subshell syntax+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH+do eval test \${$as_var+y} \+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done++# Ensure that fds 0, 1, and 2 are open.+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi+if (exec 3>&2) ; then :; else exec 2>/dev/null; fi++# The user is always right.+if ${PATH_SEPARATOR+false} :; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# Find who we are. Look in the path if we contain no directory separator.+as_myself=+case $0 in #((+ *[\\/]* ) as_myself=$0 ;;+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ test -r "$as_dir$0" && as_myself=$as_dir$0 && break+ done+IFS=$as_save_IFS++ ;;+esac+# We did not find ourselves, most probably we were run as `sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+ as_myself=$0+fi+if test ! -f "$as_myself"; then+ printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+ exit 1+fi+++# Use a proper internal environment variable to ensure we don't fall+ # into an infinite loop, continuously re-executing ourselves.+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then+ _as_can_reexec=no; export _as_can_reexec;+ # We cannot yet assume a decent shell, so we have to provide a+# neutralization value for shells without unset; and this also+# works around shells that cannot unset nonexistent variables.+# Preserve -v and -x to the replacement shell.+BASH_ENV=/dev/null+ENV=/dev/null+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+case $- in # ((((+ *v*x* | *x*v* ) as_opts=-vx ;;+ *v* ) as_opts=-v ;;+ *x* ) as_opts=-x ;;+ * ) as_opts= ;;+esac+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}+# Admittedly, this is quite paranoid, since all the known shells bail+# out after a failed `exec'.+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255+ fi+ # We don't want this to propagate to other subprocesses.+ { _as_can_reexec=; unset _as_can_reexec;}+if test "x$CONFIG_SHELL" = x; then+ as_bourne_compatible="as_nop=:+if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '\${1+\"\$@\"}'='\"\$@\"'+ setopt NO_GLOB_SUBST+else \$as_nop+ case \`(set -o) 2>/dev/null\` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac+fi+"+ as_required="as_fn_return () { (exit \$1); }+as_fn_success () { as_fn_return 0; }+as_fn_failure () { as_fn_return 1; }+as_fn_ret_success () { return 0; }+as_fn_ret_failure () { return 1; }++exitcode=0+as_fn_success || { exitcode=1; echo as_fn_success failed.; }+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }+if ( set x; as_fn_ret_success y && test x = \"\$1\" )+then :++else \$as_nop+ exitcode=1; echo positional parameters were not saved.+fi+test x\$exitcode = x0 || exit 1+blah=\$(echo \$(echo blah))+test x\"\$blah\" = xblah || exit 1+test -x / || exit 1"+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"+ if (eval "$as_required") 2>/dev/null+then :+ as_have_required=yes+else $as_nop+ as_have_required=no+fi+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null+then :++else $as_nop+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+as_found=false+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ as_found=:+ case $as_dir in #(+ /*)+ for as_base in sh bash ksh sh5; do+ # Try only shells that exist, to save several forks.+ as_shell=$as_dir$as_base+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&+ as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null+then :+ CONFIG_SHELL=$as_shell as_have_required=yes+ if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null+then :+ break 2+fi+fi+ done;;+ esac+ as_found=false+done+IFS=$as_save_IFS+if $as_found+then :++else $as_nop+ if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&+ as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null+then :+ CONFIG_SHELL=$SHELL as_have_required=yes+fi+fi+++ if test "x$CONFIG_SHELL" != x+then :+ export CONFIG_SHELL+ # We cannot yet assume a decent shell, so we have to provide a+# neutralization value for shells without unset; and this also+# works around shells that cannot unset nonexistent variables.+# Preserve -v and -x to the replacement shell.+BASH_ENV=/dev/null+ENV=/dev/null+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+case $- in # ((((+ *v*x* | *x*v* ) as_opts=-vx ;;+ *v* ) as_opts=-v ;;+ *x* ) as_opts=-x ;;+ * ) as_opts= ;;+esac+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}+# Admittedly, this is quite paranoid, since all the known shells bail+# out after a failed `exec'.+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255+fi++ if test x$as_have_required = xno+then :+ printf "%s\n" "$0: This script requires a shell more modern than all"+ printf "%s\n" "$0: the shells that I found on your system."+ if test ${ZSH_VERSION+y} ; then+ printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should"+ printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later."+ else+ printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and+$0: streamly@composewell.com about your system, including+$0: any error possibly output before this message. Then+$0: install a modern shell, or manually run the script+$0: under such a shell if you do have one."+ fi+ exit 1+fi+fi+fi+SHELL=${CONFIG_SHELL-/bin/sh}+export SHELL+# Unset more variables known to interfere with behavior of common tools.+CLICOLOR_FORCE= GREP_OPTIONS=+unset CLICOLOR_FORCE GREP_OPTIONS++## --------------------- ##+## M4sh Shell Functions. ##+## --------------------- ##+# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+ { eval $1=; unset $1;}+}+as_unset=as_fn_unset+++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+ return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+ set +e+ as_fn_set_status $1+ exit $1+} # as_fn_exit+# as_fn_nop+# ---------+# Do nothing but, unlike ":", preserve the value of $?.+as_fn_nop ()+{+ return $?+}+as_nop=as_fn_nop++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++ case $as_dir in #(+ -*) as_dir=./$as_dir;;+ esac+ test -d "$as_dir" || eval $as_mkdir_p || {+ as_dirs=+ while :; do+ case $as_dir in #(+ *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(+ *) as_qdir=$as_dir;;+ esac+ as_dirs="'$as_qdir' $as_dirs"+ as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_dir" : 'X\(//\)[^/]' \| \+ X"$as_dir" : 'X\(//\)$' \| \+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_dir" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ test -d "$as_dir" && break+ done+ test -z "$as_dirs" || eval "mkdir $as_dirs"+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p++# as_fn_executable_p FILE+# -----------------------+# Test if FILE is an executable regular file.+as_fn_executable_p ()+{+ test -f "$1" && test -x "$1"+} # as_fn_executable_p+# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null+then :+ eval 'as_fn_append ()+ {+ eval $1+=\$2+ }'+else $as_nop+ as_fn_append ()+ {+ eval $1=\$$1\$2+ }+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null+then :+ eval 'as_fn_arith ()+ {+ as_val=$(( $* ))+ }'+else $as_nop+ as_fn_arith ()+ {+ as_val=`expr "$@" || test $? -eq 1`+ }+fi # as_fn_arith++# as_fn_nop+# ---------+# Do nothing but, unlike ":", preserve the value of $?.+as_fn_nop ()+{+ return $?+}+as_nop=as_fn_nop++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+ as_status=$1; test $as_status -eq 0 && as_status=1+ if test "$4"; then+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+ fi+ printf "%s\n" "$as_me: error: $2" >&2+ as_fn_exit $as_status+} # as_fn_error++if expr a : '\(a\)' >/dev/null 2>&1 &&+ test "X`expr 00001 : '.*\(...\)'`" = X001; then+ as_expr=expr+else+ as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+ as_basename=basename+else+ as_basename=false+fi++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+ as_dirname=dirname+else+ as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+ X"$0" : 'X\(//\)$' \| \+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$0" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`++# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits+++ as_lineno_1=$LINENO as_lineno_1a=$LINENO+ as_lineno_2=$LINENO as_lineno_2a=$LINENO+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)+ sed -n '+ p+ /[$]LINENO/=+ ' <$as_myself |+ sed '+ s/[$]LINENO.*/&-/+ t lineno+ b+ :lineno+ N+ :loop+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/+ t loop+ s/-\n.*//+ ' >$as_me.lineno &&+ chmod +x "$as_me.lineno" ||+ { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }++ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have+ # already done that, so ensure we don't try to do so again and fall+ # in an infinite loop. This has already happened in practice.+ _as_can_reexec=no; export _as_can_reexec+ # Don't try to exec as it changes $[0], causing all sort of problems+ # (the dirname of $[0] is not the place where we might find the+ # original and so on. Autoconf is especially sensitive to this).+ . "./$as_me.lineno"+ # Exit status is that of the last command.+ exit+}+++# Determine whether it's possible to make 'echo' print without a newline.+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed+# for compatibility with existing Makefiles.+ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+ case `echo 'xy\c'` in+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.+ xy) ECHO_C='\c';;+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null+ ECHO_T=' ';;+ esac;;+*)+ ECHO_N='-n';;+esac++# For backward compatibility with old third-party macros, we provide+# the shell variables $as_echo and $as_echo_n. New code should use+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.+as_echo='printf %s\n'+as_echo_n='printf %s'+++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+ rm -f conf$$.dir/conf$$.file+else+ rm -f conf$$.dir+ mkdir conf$$.dir 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+ if ln -s conf$$.file conf$$ 2>/dev/null; then+ as_ln_s='ln -s'+ # ... but there are two gotchas:+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.+ # In both cases, we have to default to `cp -pR'.+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+ as_ln_s='cp -pR'+ elif ln conf$$.file conf$$ 2>/dev/null; then+ as_ln_s=ln+ else+ as_ln_s='cp -pR'+ fi+else+ as_ln_s='cp -pR'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null++if mkdir -p . 2>/dev/null; then+ as_mkdir_p='mkdir -p "$as_dir"'+else+ test -d ./-p && rmdir ./-p+ as_mkdir_p=false+fi++as_test_x='test -x'+as_executable_p=as_fn_executable_p++# Sed expression to map a string onto a valid CPP name.+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"++# Sed expression to map a string onto a valid variable name.+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"+++test -n "$DJDIR" || exec 7<&0 </dev/null+exec 6>&1++# Name of the host.+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,+# so uname gets run too.+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`++#+# Initializations.+#+ac_default_prefix=/usr/local+ac_clean_files=+ac_config_libobj_dir=.+LIBOBJS=+cross_compiling=no+subdirs=+MFLAGS=+MAKEFLAGS=++# Identity of this package.+PACKAGE_NAME='streamly'+PACKAGE_TARNAME='streamly'+PACKAGE_VERSION='0.11.0'+PACKAGE_STRING='streamly 0.11.0'+PACKAGE_BUGREPORT='streamly@composewell.com'+PACKAGE_URL='https://streamly.composewell.com'++ac_subst_vars='LTLIBOBJS+LIBOBJS+OBJEXT+EXEEXT+ac_ct_CC+CPPFLAGS+LDFLAGS+CFLAGS+CC+target_alias+host_alias+build_alias+LIBS+ECHO_T+ECHO_N+ECHO_C+DEFS+mandir+localedir+libdir+psdir+pdfdir+dvidir+htmldir+infodir+docdir+oldincludedir+includedir+runstatedir+localstatedir+sharedstatedir+sysconfdir+datadir+datarootdir+libexecdir+sbindir+bindir+program_transform_name+prefix+exec_prefix+PACKAGE_URL+PACKAGE_BUGREPORT+PACKAGE_STRING+PACKAGE_VERSION+PACKAGE_TARNAME+PACKAGE_NAME+PATH_SEPARATOR+SHELL'+ac_subst_files=''+ac_user_opts='+enable_option_checking+with_compiler+'+ ac_precious_vars='build_alias+host_alias+target_alias+CC+CFLAGS+LDFLAGS+LIBS+CPPFLAGS'+++# Initialize some variables set by options.+ac_init_help=+ac_init_version=false+ac_unrecognized_opts=+ac_unrecognized_sep=+# The variables have the same names as the options, with+# dashes changed to underlines.+cache_file=/dev/null+exec_prefix=NONE+no_create=+no_recursion=+prefix=NONE+program_prefix=NONE+program_suffix=NONE+program_transform_name=s,x,x,+silent=+site=+srcdir=+verbose=+x_includes=NONE+x_libraries=NONE++# Installation directory options.+# These are left unexpanded so users can "make install exec_prefix=/foo"+# and all the variables that are supposed to be based on exec_prefix+# by default will actually change.+# Use braces instead of parens because sh, perl, etc. also accept them.+# (The list follows the same order as the GNU Coding Standards.)+bindir='${exec_prefix}/bin'+sbindir='${exec_prefix}/sbin'+libexecdir='${exec_prefix}/libexec'+datarootdir='${prefix}/share'+datadir='${datarootdir}'+sysconfdir='${prefix}/etc'+sharedstatedir='${prefix}/com'+localstatedir='${prefix}/var'+runstatedir='${localstatedir}/run'+includedir='${prefix}/include'+oldincludedir='/usr/include'+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'+infodir='${datarootdir}/info'+htmldir='${docdir}'+dvidir='${docdir}'+pdfdir='${docdir}'+psdir='${docdir}'+libdir='${exec_prefix}/lib'+localedir='${datarootdir}/locale'+mandir='${datarootdir}/man'++ac_prev=+ac_dashdash=+for ac_option+do+ # If the previous option needs an argument, assign it.+ if test -n "$ac_prev"; then+ eval $ac_prev=\$ac_option+ ac_prev=+ continue+ fi++ case $ac_option in+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;+ *=) ac_optarg= ;;+ *) ac_optarg=yes ;;+ esac++ case $ac_dashdash$ac_option in+ --)+ ac_dashdash=yes ;;++ -bindir | --bindir | --bindi | --bind | --bin | --bi)+ ac_prev=bindir ;;+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)+ bindir=$ac_optarg ;;++ -build | --build | --buil | --bui | --bu)+ ac_prev=build_alias ;;+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)+ build_alias=$ac_optarg ;;++ -cache-file | --cache-file | --cache-fil | --cache-fi \+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)+ ac_prev=cache_file ;;+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)+ cache_file=$ac_optarg ;;++ --config-cache | -C)+ cache_file=config.cache ;;++ -datadir | --datadir | --datadi | --datad)+ ac_prev=datadir ;;+ -datadir=* | --datadir=* | --datadi=* | --datad=*)+ datadir=$ac_optarg ;;++ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \+ | --dataroo | --dataro | --datar)+ ac_prev=datarootdir ;;+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)+ datarootdir=$ac_optarg ;;++ -disable-* | --disable-*)+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid feature name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"enable_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval enable_$ac_useropt=no ;;++ -docdir | --docdir | --docdi | --doc | --do)+ ac_prev=docdir ;;+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)+ docdir=$ac_optarg ;;++ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)+ ac_prev=dvidir ;;+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)+ dvidir=$ac_optarg ;;++ -enable-* | --enable-*)+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid feature name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"enable_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval enable_$ac_useropt=\$ac_optarg ;;++ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \+ | --exec | --exe | --ex)+ ac_prev=exec_prefix ;;+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \+ | --exec=* | --exe=* | --ex=*)+ exec_prefix=$ac_optarg ;;++ -gas | --gas | --ga | --g)+ # Obsolete; use --with-gas.+ with_gas=yes ;;++ -help | --help | --hel | --he | -h)+ ac_init_help=long ;;+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)+ ac_init_help=recursive ;;+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)+ ac_init_help=short ;;++ -host | --host | --hos | --ho)+ ac_prev=host_alias ;;+ -host=* | --host=* | --hos=* | --ho=*)+ host_alias=$ac_optarg ;;++ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)+ ac_prev=htmldir ;;+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \+ | --ht=*)+ htmldir=$ac_optarg ;;++ -includedir | --includedir | --includedi | --included | --include \+ | --includ | --inclu | --incl | --inc)+ ac_prev=includedir ;;+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \+ | --includ=* | --inclu=* | --incl=* | --inc=*)+ includedir=$ac_optarg ;;++ -infodir | --infodir | --infodi | --infod | --info | --inf)+ ac_prev=infodir ;;+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)+ infodir=$ac_optarg ;;++ -libdir | --libdir | --libdi | --libd)+ ac_prev=libdir ;;+ -libdir=* | --libdir=* | --libdi=* | --libd=*)+ libdir=$ac_optarg ;;++ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \+ | --libexe | --libex | --libe)+ ac_prev=libexecdir ;;+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \+ | --libexe=* | --libex=* | --libe=*)+ libexecdir=$ac_optarg ;;++ -localedir | --localedir | --localedi | --localed | --locale)+ ac_prev=localedir ;;+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)+ localedir=$ac_optarg ;;++ -localstatedir | --localstatedir | --localstatedi | --localstated \+ | --localstate | --localstat | --localsta | --localst | --locals)+ ac_prev=localstatedir ;;+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)+ localstatedir=$ac_optarg ;;++ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)+ ac_prev=mandir ;;+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)+ mandir=$ac_optarg ;;++ -nfp | --nfp | --nf)+ # Obsolete; use --without-fp.+ with_fp=no ;;++ -no-create | --no-create | --no-creat | --no-crea | --no-cre \+ | --no-cr | --no-c | -n)+ no_create=yes ;;++ -no-recursion | --no-recursion | --no-recursio | --no-recursi \+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)+ no_recursion=yes ;;++ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \+ | --oldin | --oldi | --old | --ol | --o)+ ac_prev=oldincludedir ;;+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)+ oldincludedir=$ac_optarg ;;++ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)+ ac_prev=prefix ;;+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)+ prefix=$ac_optarg ;;++ -program-prefix | --program-prefix | --program-prefi | --program-pref \+ | --program-pre | --program-pr | --program-p)+ ac_prev=program_prefix ;;+ -program-prefix=* | --program-prefix=* | --program-prefi=* \+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)+ program_prefix=$ac_optarg ;;++ -program-suffix | --program-suffix | --program-suffi | --program-suff \+ | --program-suf | --program-su | --program-s)+ ac_prev=program_suffix ;;+ -program-suffix=* | --program-suffix=* | --program-suffi=* \+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)+ program_suffix=$ac_optarg ;;++ -program-transform-name | --program-transform-name \+ | --program-transform-nam | --program-transform-na \+ | --program-transform-n | --program-transform- \+ | --program-transform | --program-transfor \+ | --program-transfo | --program-transf \+ | --program-trans | --program-tran \+ | --progr-tra | --program-tr | --program-t)+ ac_prev=program_transform_name ;;+ -program-transform-name=* | --program-transform-name=* \+ | --program-transform-nam=* | --program-transform-na=* \+ | --program-transform-n=* | --program-transform-=* \+ | --program-transform=* | --program-transfor=* \+ | --program-transfo=* | --program-transf=* \+ | --program-trans=* | --program-tran=* \+ | --progr-tra=* | --program-tr=* | --program-t=*)+ program_transform_name=$ac_optarg ;;++ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)+ ac_prev=pdfdir ;;+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)+ pdfdir=$ac_optarg ;;++ -psdir | --psdir | --psdi | --psd | --ps)+ ac_prev=psdir ;;+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)+ psdir=$ac_optarg ;;++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil)+ silent=yes ;;++ -runstatedir | --runstatedir | --runstatedi | --runstated \+ | --runstate | --runstat | --runsta | --runst | --runs \+ | --run | --ru | --r)+ ac_prev=runstatedir ;;+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \+ | --run=* | --ru=* | --r=*)+ runstatedir=$ac_optarg ;;++ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)+ ac_prev=sbindir ;;+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \+ | --sbi=* | --sb=*)+ sbindir=$ac_optarg ;;++ -sharedstatedir | --sharedstatedir | --sharedstatedi \+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \+ | --sharedst | --shareds | --shared | --share | --shar \+ | --sha | --sh)+ ac_prev=sharedstatedir ;;+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \+ | --sha=* | --sh=*)+ sharedstatedir=$ac_optarg ;;++ -site | --site | --sit)+ ac_prev=site ;;+ -site=* | --site=* | --sit=*)+ site=$ac_optarg ;;++ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)+ ac_prev=srcdir ;;+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)+ srcdir=$ac_optarg ;;++ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \+ | --syscon | --sysco | --sysc | --sys | --sy)+ ac_prev=sysconfdir ;;+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)+ sysconfdir=$ac_optarg ;;++ -target | --target | --targe | --targ | --tar | --ta | --t)+ ac_prev=target_alias ;;+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)+ target_alias=$ac_optarg ;;++ -v | -verbose | --verbose | --verbos | --verbo | --verb)+ verbose=yes ;;++ -version | --version | --versio | --versi | --vers | -V)+ ac_init_version=: ;;++ -with-* | --with-*)+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid package name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"with_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval with_$ac_useropt=\$ac_optarg ;;++ -without-* | --without-*)+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid package name: \`$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"with_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval with_$ac_useropt=no ;;++ --x)+ # Obsolete; use --with-x.+ with_x=yes ;;++ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \+ | --x-incl | --x-inc | --x-in | --x-i)+ ac_prev=x_includes ;;+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)+ x_includes=$ac_optarg ;;++ -x-libraries | --x-libraries | --x-librarie | --x-librari \+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)+ ac_prev=x_libraries ;;+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)+ x_libraries=$ac_optarg ;;++ -*) as_fn_error $? "unrecognized option: \`$ac_option'+Try \`$0 --help' for more information"+ ;;++ *=*)+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`+ # Reject names that are not valid shell variable names.+ case $ac_envvar in #(+ '' | [0-9]* | *[!_$as_cr_alnum]* )+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;+ esac+ eval $ac_envvar=\$ac_optarg+ export $ac_envvar ;;++ *)+ # FIXME: should be removed in autoconf 3.0.+ printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&+ printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"+ ;;++ esac+done++if test -n "$ac_prev"; then+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`+ as_fn_error $? "missing argument to $ac_option"+fi++if test -n "$ac_unrecognized_opts"; then+ case $enable_option_checking in+ no) ;;+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;+ *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;+ esac+fi++# Check all directory arguments for consistency.+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \+ datadir sysconfdir sharedstatedir localstatedir includedir \+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \+ libdir localedir mandir runstatedir+do+ eval ac_val=\$$ac_var+ # Remove trailing slashes.+ case $ac_val in+ */ )+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`+ eval $ac_var=\$ac_val;;+ esac+ # Be sure to have absolute directory names.+ case $ac_val in+ [\\/$]* | ?:[\\/]* ) continue;;+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;+ esac+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"+done++# There might be people who depend on the old broken behavior: `$host'+# used to hold the argument of --host etc.+# FIXME: To remove some day.+build=$build_alias+host=$host_alias+target=$target_alias++# FIXME: To remove some day.+if test "x$host_alias" != x; then+ if test "x$build_alias" = x; then+ cross_compiling=maybe+ elif test "x$build_alias" != "x$host_alias"; then+ cross_compiling=yes+ fi+fi++ac_tool_prefix=+test -n "$host_alias" && ac_tool_prefix=$host_alias-++test "$silent" = yes && exec 6>/dev/null+++ac_pwd=`pwd` && test -n "$ac_pwd" &&+ac_ls_di=`ls -di .` &&+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||+ as_fn_error $? "working directory cannot be determined"+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||+ as_fn_error $? "pwd does not report name of working directory"+++# Find the source files, if location was not specified.+if test -z "$srcdir"; then+ ac_srcdir_defaulted=yes+ # Try the directory containing this script, then the parent directory.+ ac_confdir=`$as_dirname -- "$as_myself" ||+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_myself" : 'X\(//\)[^/]' \| \+ X"$as_myself" : 'X\(//\)$' \| \+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_myself" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ srcdir=$ac_confdir+ if test ! -r "$srcdir/$ac_unique_file"; then+ srcdir=..+ fi+else+ ac_srcdir_defaulted=no+fi+if test ! -r "$srcdir/$ac_unique_file"; then+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"+fi+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"+ac_abs_confdir=`(+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"+ pwd)`+# When building in place, set srcdir=.+if test "$ac_abs_confdir" = "$ac_pwd"; then+ srcdir=.+fi+# Remove unnecessary trailing slashes from srcdir.+# Double slashes in file names in object file debugging info+# mess up M-x gdb in Emacs.+case $srcdir in+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;+esac+for ac_var in $ac_precious_vars; do+ eval ac_env_${ac_var}_set=\${${ac_var}+set}+ eval ac_env_${ac_var}_value=\$${ac_var}+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}+ eval ac_cv_env_${ac_var}_value=\$${ac_var}+done++#+# Report the --help message.+#+if test "$ac_init_help" = "long"; then+ # Omit some internal or obsolete options to make the list less imposing.+ # This message is too long to be a string in the A/UX 3.1 sh.+ cat <<_ACEOF+\`configure' configures streamly 0.11.0 to adapt to many kinds of systems.++Usage: $0 [OPTION]... [VAR=VALUE]...++To assign environment variables (e.g., CC, CFLAGS...), specify them as+VAR=VALUE. See below for descriptions of some of the useful variables.++Defaults for the options are specified in brackets.++Configuration:+ -h, --help display this help and exit+ --help=short display options specific to this package+ --help=recursive display the short help of all the included packages+ -V, --version display version information and exit+ -q, --quiet, --silent do not print \`checking ...' messages+ --cache-file=FILE cache test results in FILE [disabled]+ -C, --config-cache alias for \`--cache-file=config.cache'+ -n, --no-create do not create output files+ --srcdir=DIR find the sources in DIR [configure dir or \`..']++Installation directories:+ --prefix=PREFIX install architecture-independent files in PREFIX+ [$ac_default_prefix]+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX+ [PREFIX]++By default, \`make install' will install all the files in+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify+an installation prefix other than \`$ac_default_prefix' using \`--prefix',+for instance \`--prefix=\$HOME'.++For better control, use the options below.++Fine tuning of the installation directories:+ --bindir=DIR user executables [EPREFIX/bin]+ --sbindir=DIR system admin executables [EPREFIX/sbin]+ --libexecdir=DIR program executables [EPREFIX/libexec]+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]+ --libdir=DIR object code libraries [EPREFIX/lib]+ --includedir=DIR C header files [PREFIX/include]+ --oldincludedir=DIR C header files for non-gcc [/usr/include]+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]+ --infodir=DIR info documentation [DATAROOTDIR/info]+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]+ --mandir=DIR man documentation [DATAROOTDIR/man]+ --docdir=DIR documentation root [DATAROOTDIR/doc/streamly]+ --htmldir=DIR html documentation [DOCDIR]+ --dvidir=DIR dvi documentation [DOCDIR]+ --pdfdir=DIR pdf documentation [DOCDIR]+ --psdir=DIR ps documentation [DOCDIR]+_ACEOF++ cat <<\_ACEOF+_ACEOF+fi++if test -n "$ac_init_help"; then+ case $ac_init_help in+ short | recursive ) echo "Configuration of streamly 0.11.0:";;+ esac+ cat <<\_ACEOF++Optional Packages:+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)+GHC++Some influential environment variables:+ CC C compiler command+ CFLAGS C compiler flags+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a+ nonstandard directory <lib dir>+ LIBS libraries to pass to the linker, e.g. -l<library>+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if+ you have headers in a nonstandard directory <include dir>++Use these variables to override the choices made by `configure' or to help+it to find libraries and programs with nonstandard names/locations.++Report bugs to <streamly@composewell.com>.+streamly home page: <https://streamly.composewell.com>.+_ACEOF+ac_status=$?+fi++if test "$ac_init_help" = "recursive"; then+ # If there are subdirs, report their specific --help.+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue+ test -d "$ac_dir" ||+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||+ continue+ ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+ ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`+ # A ".." for each directory in $ac_dir_suffix.+ ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`+ case $ac_top_builddir_sub in+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;+ esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+ .) # We are building in place.+ ac_srcdir=.+ ac_top_srcdir=$ac_top_builddir_sub+ ac_abs_top_srcdir=$ac_pwd ;;+ [\\/]* | ?:[\\/]* ) # Absolute name.+ ac_srcdir=$srcdir$ac_dir_suffix;+ ac_top_srcdir=$srcdir+ ac_abs_top_srcdir=$srcdir ;;+ *) # Relative name.+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+ ac_top_srcdir=$ac_top_build_prefix$srcdir+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix++ cd "$ac_dir" || { ac_status=$?; continue; }+ # Check for configure.gnu first; this name is used for a wrapper for+ # Metaconfig's "Configure" on case-insensitive file systems.+ if test -f "$ac_srcdir/configure.gnu"; then+ echo &&+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive+ elif test -f "$ac_srcdir/configure"; then+ echo &&+ $SHELL "$ac_srcdir/configure" --help=recursive+ else+ printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2+ fi || ac_status=$?+ cd "$ac_pwd" || { ac_status=$?; break; }+ done+fi++test -n "$ac_init_help" && exit $ac_status+if $ac_init_version; then+ cat <<\_ACEOF+streamly configure 0.11.0+generated by GNU Autoconf 2.71++Copyright (C) 2021 Free Software Foundation, Inc.+This configure script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it.+_ACEOF+ exit+fi++## ------------------------ ##+## Autoconf initialization. ##+## ------------------------ ##++# ac_fn_c_try_compile LINENO+# --------------------------+# Try to compile conftest.$ac_ext, and return whether this succeeded.+ac_fn_c_try_compile ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ rm -f conftest.$ac_objext conftest.beam+ if { { ac_try="$ac_compile"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compile") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ grep -v '^ *+' conftest.err >conftest.er1+ cat conftest.er1 >&5+ mv -f conftest.er1 conftest.err+ fi+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && {+ test -z "$ac_c_werror_flag" ||+ test ! -s conftest.err+ } && test -s conftest.$ac_objext+then :+ ac_retval=0+else $as_nop+ printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=1+fi+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_compile++# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR+# ------------------------------------------------------------------+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR+# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR.+ac_fn_check_decl ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ as_decl_name=`echo $2|sed 's/ *(.*//'`+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5+printf %s "checking whether $as_decl_name is declared... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`+ eval ac_save_FLAGS=\$$6+ as_fn_append $6 " $5"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+#ifndef $as_decl_name+#ifdef __cplusplus+ (void) $as_decl_use;+#else+ (void) $as_decl_name;+#endif+#endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$3=yes"+else $as_nop+ eval "$3=no"+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ eval $6=\$ac_save_FLAGS++fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_check_decl+ac_configure_args_raw=+for ac_arg+do+ case $ac_arg in+ *\'*)+ ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ as_fn_append ac_configure_args_raw " '$ac_arg'"+done++case $ac_configure_args_raw in+ *$as_nl*)+ ac_safe_unquote= ;;+ *)+ ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab.+ ac_unsafe_a="$ac_unsafe_z#~"+ ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"+ ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;+esac++cat >config.log <<_ACEOF+This file contains any messages produced by compilers while+running configure, to aid debugging if configure makes a mistake.++It was created by streamly $as_me 0.11.0, which was+generated by GNU Autoconf 2.71. Invocation command line was++ $ $0$ac_configure_args_raw++_ACEOF+exec 5>>config.log+{+cat <<_ASUNAME+## --------- ##+## Platform. ##+## --------- ##++hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`+uname -m = `(uname -m) 2>/dev/null || echo unknown`+uname -r = `(uname -r) 2>/dev/null || echo unknown`+uname -s = `(uname -s) 2>/dev/null || echo unknown`+uname -v = `(uname -v) 2>/dev/null || echo unknown`++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`++/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`++_ASUNAME++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ printf "%s\n" "PATH: $as_dir"+ done+IFS=$as_save_IFS++} >&5++cat >&5 <<_ACEOF+++## ----------- ##+## Core tests. ##+## ----------- ##++_ACEOF+++# Keep a trace of the command line.+# Strip out --no-create and --no-recursion so they do not pile up.+# Strip out --silent because we don't want to record it for future runs.+# Also quote any args containing shell meta-characters.+# Make two passes to allow for proper duplicate-argument suppression.+ac_configure_args=+ac_configure_args0=+ac_configure_args1=+ac_must_keep_next=false+for ac_pass in 1 2+do+ for ac_arg+ do+ case $ac_arg in+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil)+ continue ;;+ *\'*)+ ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ case $ac_pass in+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;+ 2)+ as_fn_append ac_configure_args1 " '$ac_arg'"+ if test $ac_must_keep_next = true; then+ ac_must_keep_next=false # Got value, back to normal.+ else+ case $ac_arg in+ *=* | --config-cache | -C | -disable-* | --disable-* \+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \+ | -with-* | --with-* | -without-* | --without-* | --x)+ case "$ac_configure_args0 " in+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;+ esac+ ;;+ -* ) ac_must_keep_next=true ;;+ esac+ fi+ as_fn_append ac_configure_args " '$ac_arg'"+ ;;+ esac+ done+done+{ ac_configure_args0=; unset ac_configure_args0;}+{ ac_configure_args1=; unset ac_configure_args1;}++# When interrupted or exit'd, cleanup temporary files, and complete+# config.log. We remove comments because anyway the quotes in there+# would cause problems or look ugly.+# WARNING: Use '\'' to represent an apostrophe within the trap.+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.+trap 'exit_status=$?+ # Sanitize IFS.+ IFS=" "" $as_nl"+ # Save into config.log some information that might help in debugging.+ {+ echo++ printf "%s\n" "## ---------------- ##+## Cache variables. ##+## ---------------- ##"+ echo+ # The following way of writing the cache mishandles newlines in values,+(+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do+ eval ac_val=\$$ac_var+ case $ac_val in #(+ *${as_nl}*)+ case $ac_var in #(+ *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+ esac+ case $ac_var in #(+ _ | IFS | as_nl) ;; #(+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+ *) { eval $ac_var=; unset $ac_var;} ;;+ esac ;;+ esac+ done+ (set) 2>&1 |+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(+ *${as_nl}ac_space=\ *)+ sed -n \+ "s/'\''/'\''\\\\'\'''\''/g;+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"+ ;; #(+ *)+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+ ;;+ esac |+ sort+)+ echo++ printf "%s\n" "## ----------------- ##+## Output variables. ##+## ----------------- ##"+ echo+ for ac_var in $ac_subst_vars+ do+ eval ac_val=\$$ac_var+ case $ac_val in+ *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+ esac+ printf "%s\n" "$ac_var='\''$ac_val'\''"+ done | sort+ echo++ if test -n "$ac_subst_files"; then+ printf "%s\n" "## ------------------- ##+## File substitutions. ##+## ------------------- ##"+ echo+ for ac_var in $ac_subst_files+ do+ eval ac_val=\$$ac_var+ case $ac_val in+ *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+ esac+ printf "%s\n" "$ac_var='\''$ac_val'\''"+ done | sort+ echo+ fi++ if test -s confdefs.h; then+ printf "%s\n" "## ----------- ##+## confdefs.h. ##+## ----------- ##"+ echo+ cat confdefs.h+ echo+ fi+ test "$ac_signal" != 0 &&+ printf "%s\n" "$as_me: caught signal $ac_signal"+ printf "%s\n" "$as_me: exit $exit_status"+ } >&5+ rm -f core *.core core.conftest.* &&+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&+ exit $exit_status+' 0+for ac_signal in 1 2 13 15; do+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal+done+ac_signal=0++# confdefs.h avoids OS command line length limits that DEFS can exceed.+rm -f -r conftest* confdefs.h++printf "%s\n" "/* confdefs.h */" > confdefs.h++# Predefined preprocessor variables.++printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h+++# Let the site file select an alternate cache file if it wants to.+# Prefer an explicitly selected file to automatically selected ones.+if test -n "$CONFIG_SITE"; then+ ac_site_files="$CONFIG_SITE"+elif test "x$prefix" != xNONE; then+ ac_site_files="$prefix/share/config.site $prefix/etc/config.site"+else+ ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"+fi++for ac_site_file in $ac_site_files+do+ case $ac_site_file in #(+ */*) :+ ;; #(+ *) :+ ac_site_file=./$ac_site_file ;;+esac+ if test -f "$ac_site_file" && test -r "$ac_site_file"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5+printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;}+ sed 's/^/| /' "$ac_site_file" >&5+ . "$ac_site_file" \+ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "failed to load site script $ac_site_file+See \`config.log' for more details" "$LINENO" 5; }+ fi+done++if test -r "$cache_file"; then+ # Some versions of bash will fail to source /dev/null (special files+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5+printf "%s\n" "$as_me: loading cache $cache_file" >&6;}+ case $cache_file in+ [\\/]* | ?:[\\/]* ) . "$cache_file";;+ *) . "./$cache_file";;+ esac+ fi+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5+printf "%s\n" "$as_me: creating cache $cache_file" >&6;}+ >$cache_file+fi++# Test code for whether the C compiler supports C89 (global declarations)+ac_c_conftest_c89_globals='+/* Does the compiler advertise C89 conformance?+ Do not test the value of __STDC__, because some compilers set it to 0+ while being otherwise adequately conformant. */+#if !defined __STDC__+# error "Compiler does not advertise C89 conformance"+#endif++#include <stddef.h>+#include <stdarg.h>+struct stat;+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */+struct buf { int x; };+struct buf * (*rcsopen) (struct buf *, struct stat *, int);+static char *e (p, i)+ char **p;+ int i;+{+ return p[i];+}+static char *f (char * (*g) (char **, int), char **p, ...)+{+ char *s;+ va_list v;+ va_start (v,p);+ s = g (p, va_arg (v,int));+ va_end (v);+ return s;+}++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has+ function prototypes and stuff, but not \xHH hex character constants.+ These do not provoke an error unfortunately, instead are silently treated+ as an "x". The following induces an error, until -std is added to get+ proper ANSI mode. Curiously \x00 != x always comes out true, for an+ array size at least. It is necessary to write \x00 == 0 to get something+ that is true only with -std. */+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters+ inside strings and character constants. */+#define FOO(x) '\''x'\''+int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];++int test (int i, double x);+struct s1 {int (*f) (int a);};+struct s2 {int (*f) (double a);};+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),+ int, int);'++# Test code for whether the C compiler supports C89 (body of main).+ac_c_conftest_c89_main='+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);+'++# Test code for whether the C compiler supports C99 (global declarations)+ac_c_conftest_c99_globals='+// Does the compiler advertise C99 conformance?+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L+# error "Compiler does not advertise C99 conformance"+#endif++#include <stdbool.h>+extern int puts (const char *);+extern int printf (const char *, ...);+extern int dprintf (int, const char *, ...);+extern void *malloc (size_t);++// Check varargs macros. These examples are taken from C99 6.10.3.5.+// dprintf is used instead of fprintf to avoid needing to declare+// FILE and stderr.+#define debug(...) dprintf (2, __VA_ARGS__)+#define showlist(...) puts (#__VA_ARGS__)+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))+static void+test_varargs_macros (void)+{+ int x = 1234;+ int y = 5678;+ debug ("Flag");+ debug ("X = %d\n", x);+ showlist (The first, second, and third items.);+ report (x>y, "x is %d but y is %d", x, y);+}++// Check long long types.+#define BIG64 18446744073709551615ull+#define BIG32 4294967295ul+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)+#if !BIG_OK+ #error "your preprocessor is broken"+#endif+#if BIG_OK+#else+ #error "your preprocessor is broken"+#endif+static long long int bignum = -9223372036854775807LL;+static unsigned long long int ubignum = BIG64;++struct incomplete_array+{+ int datasize;+ double data[];+};++struct named_init {+ int number;+ const wchar_t *name;+ double average;+};++typedef const char *ccp;++static inline int+test_restrict (ccp restrict text)+{+ // See if C++-style comments work.+ // Iterate through items via the restricted pointer.+ // Also check for declarations in for loops.+ for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)+ continue;+ return 0;+}++// Check varargs and va_copy.+static bool+test_varargs (const char *format, ...)+{+ va_list args;+ va_start (args, format);+ va_list args_copy;+ va_copy (args_copy, args);++ const char *str = "";+ int number = 0;+ float fnumber = 0;++ while (*format)+ {+ switch (*format++)+ {+ case '\''s'\'': // string+ str = va_arg (args_copy, const char *);+ break;+ case '\''d'\'': // int+ number = va_arg (args_copy, int);+ break;+ case '\''f'\'': // float+ fnumber = va_arg (args_copy, double);+ break;+ default:+ break;+ }+ }+ va_end (args_copy);+ va_end (args);++ return *str && number && fnumber;+}+'++# Test code for whether the C compiler supports C99 (body of main).+ac_c_conftest_c99_main='+ // Check bool.+ _Bool success = false;+ success |= (argc != 0);++ // Check restrict.+ if (test_restrict ("String literal") == 0)+ success = true;+ char *restrict newvar = "Another string";++ // Check varargs.+ success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);+ test_varargs_macros ();++ // Check flexible array members.+ struct incomplete_array *ia =+ malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));+ ia->datasize = 10;+ for (int i = 0; i < ia->datasize; ++i)+ ia->data[i] = i * 1.234;++ // Check named initializers.+ struct named_init ni = {+ .number = 34,+ .name = L"Test wide string",+ .average = 543.34343,+ };++ ni.number = 58;++ int dynamic_array[ni.number];+ dynamic_array[0] = argv[0][0];+ dynamic_array[ni.number - 1] = 543;++ // work around unused variable warnings+ ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''+ || dynamic_array[ni.number - 1] != 543);+'++# Test code for whether the C compiler supports C11 (global declarations)+ac_c_conftest_c11_globals='+// Does the compiler advertise C11 conformance?+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L+# error "Compiler does not advertise C11 conformance"+#endif++// Check _Alignas.+char _Alignas (double) aligned_as_double;+char _Alignas (0) no_special_alignment;+extern char aligned_as_int;+char _Alignas (0) _Alignas (int) aligned_as_int;++// Check _Alignof.+enum+{+ int_alignment = _Alignof (int),+ int_array_alignment = _Alignof (int[100]),+ char_alignment = _Alignof (char)+};+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");++// Check _Noreturn.+int _Noreturn does_not_return (void) { for (;;) continue; }++// Check _Static_assert.+struct test_static_assert+{+ int x;+ _Static_assert (sizeof (int) <= sizeof (long int),+ "_Static_assert does not work in struct");+ long int y;+};++// Check UTF-8 literals.+#define u8 syntax error!+char const utf8_literal[] = u8"happens to be ASCII" "another string";++// Check duplicate typedefs.+typedef long *long_ptr;+typedef long int *long_ptr;+typedef long_ptr long_ptr;++// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.+struct anonymous+{+ union {+ struct { int i; int j; };+ struct { int k; long int l; } w;+ };+ int m;+} v1;+'++# Test code for whether the C compiler supports C11 (body of main).+ac_c_conftest_c11_main='+ _Static_assert ((offsetof (struct anonymous, i)+ == offsetof (struct anonymous, w.k)),+ "Anonymous union alignment botch");+ v1.i = 2;+ v1.w.k = 5;+ ok |= v1.i != 5;+'++# Test code for whether the C compiler supports C11 (complete).+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}+${ac_c_conftest_c99_globals}+${ac_c_conftest_c11_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ ${ac_c_conftest_c99_main}+ ${ac_c_conftest_c11_main}+ return ok;+}+"++# Test code for whether the C compiler supports C99 (complete).+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}+${ac_c_conftest_c99_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ ${ac_c_conftest_c99_main}+ return ok;+}+"++# Test code for whether the C compiler supports C89 (complete).+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ return ok;+}+"++# Check that the precious variables saved in the cache have kept the same+# value.+ac_cache_corrupted=false+for ac_var in $ac_precious_vars; do+ eval ac_old_set=\$ac_cv_env_${ac_var}_set+ eval ac_new_set=\$ac_env_${ac_var}_set+ eval ac_old_val=\$ac_cv_env_${ac_var}_value+ eval ac_new_val=\$ac_env_${ac_var}_value+ case $ac_old_set,$ac_new_set in+ set,)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5+printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}+ ac_cache_corrupted=: ;;+ ,set)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5+printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}+ ac_cache_corrupted=: ;;+ ,);;+ *)+ if test "x$ac_old_val" != "x$ac_new_val"; then+ # differences in whitespace do not lead to failure.+ ac_old_val_w=`echo x $ac_old_val`+ ac_new_val_w=`echo x $ac_new_val`+ if test "$ac_old_val_w" != "$ac_new_val_w"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5+printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}+ ac_cache_corrupted=:+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5+printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}+ eval $ac_var=\$ac_old_val+ fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5+printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;}+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5+printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;}+ fi;;+ esac+ # Pass precious variables to config.status.+ if test "$ac_new_set" = set; then+ case $ac_new_val in+ *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;+ *) ac_arg=$ac_var=$ac_new_val ;;+ esac+ case " $ac_configure_args " in+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;+ esac+ fi+done+if $ac_cache_corrupted; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5+printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;}+ as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file'+ and start over" "$LINENO" 5+fi+## -------------------- ##+## Main body of script. ##+## -------------------- ##++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++++# To suppress "WARNING: unrecognized options: --with-compiler"++# Check whether --with-compiler was given.+if test ${with_compiler+y}+then :+ withval=$with_compiler;+fi+++# XXX Do this only for linux++++++++++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.+set dummy ${ac_tool_prefix}gcc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}gcc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_CC"; then+ ac_ct_CC=$CC+ # Extract the first word of "gcc", so it can be a program name with args.+set dummy gcc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="gcc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+else+ CC="$ac_cv_prog_CC"+fi++if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.+set dummy ${ac_tool_prefix}cc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}cc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ fi+fi+if test -z "$CC"; then+ # Extract the first word of "cc", so it can be a program name with args.+set dummy cc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+ ac_prog_rejected=no+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then+ ac_prog_rejected=yes+ continue+ fi+ ac_cv_prog_CC="cc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++if test $ac_prog_rejected = yes; then+ # We found a bogon in the path, so make sure we never use it.+ set dummy $ac_cv_prog_CC+ shift+ if test $# != 0; then+ # We chose a different compiler from the bogus one.+ # However, it has the same basename, so the bogon will be chosen+ # first if we set CC to just the basename; use the full file name.+ shift+ ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@"+ fi+fi+fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ for ac_prog in cl.exe+ do+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.+set dummy $ac_tool_prefix$ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$CC" && break+ done+fi+if test -z "$CC"; then+ ac_ct_CC=$CC+ for ac_prog in cl.exe+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$ac_ct_CC" && break+done++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+fi++fi+if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.+set dummy ${ac_tool_prefix}clang; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}clang"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_CC"; then+ ac_ct_CC=$CC+ # Extract the first word of "clang", so it can be a program name with args.+set dummy clang; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="clang"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+else+ CC="$ac_cv_prog_CC"+fi++fi+++test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "no acceptable C compiler found in \$PATH+See \`config.log' for more details" "$LINENO" 5; }++# Provide some information about the compiler.+printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5+set X $ac_compile+ac_compiler=$2+for ac_option in --version -v -V -qversion -version; do+ { { ac_try="$ac_compiler $ac_option >&5"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ sed '10a\+... rest of stderr output deleted ...+ 10q' conftest.err >conftest.er1+ cat conftest.er1 >&5+ fi+ rm -f conftest.er1 conftest.err+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+done++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"+# Try to create an executable without -o first, disregard a.out.+# It will help us diagnose broken compilers, and finding out an intuition+# of exeext.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5+printf %s "checking whether the C compiler works... " >&6; }+ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'`++# The possible output files:+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"++ac_rmfiles=+for ac_file in $ac_files+do+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;+ esac+done+rm -f $ac_rmfiles++if { { ac_try="$ac_link_default"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link_default") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'+# in a Makefile. We should not override ac_cv_exeext if it was cached,+# so that the user can short-circuit this test for compilers unknown to+# Autoconf.+for ac_file in $ac_files ''+do+ test -f "$ac_file" || continue+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )+ ;;+ [ab].out )+ # We found the default executable, but exeext='' is most+ # certainly right.+ break;;+ *.* )+ if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;+ then :; else+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`+ fi+ # We set ac_cv_exeext here because the later test for it is not+ # safe: cross compilers may not add the suffix if given an `-o'+ # argument, so we may need to know it at that point already.+ # Even if this section looks crufty: it has the advantage of+ # actually working.+ break;;+ * )+ break;;+ esac+done+test "$ac_cv_exeext" = no && ac_cv_exeext=++else $as_nop+ ac_file=''+fi+if test -z "$ac_file"+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error 77 "C compiler cannot create executables+See \`config.log' for more details" "$LINENO" 5; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5+printf %s "checking for C compiler default output file name... " >&6; }+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5+printf "%s\n" "$ac_file" >&6; }+ac_exeext=$ac_cv_exeext++rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out+ac_clean_files=$ac_clean_files_save+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5+printf %s "checking for suffix of executables... " >&6; }+if { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ # If both `conftest.exe' and `conftest' are `present' (well, observable)+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will+# work properly (i.e., refer to `conftest.exe'), while it won't with+# `rm'.+for ac_file in conftest.exe conftest conftest.*; do+ test -f "$ac_file" || continue+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`+ break;;+ * ) break;;+ esac+done+else $as_nop+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "cannot compute suffix of executables: cannot compile and link+See \`config.log' for more details" "$LINENO" 5; }+fi+rm -f conftest conftest$ac_cv_exeext+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5+printf "%s\n" "$ac_cv_exeext" >&6; }++rm -f conftest.$ac_ext+EXEEXT=$ac_cv_exeext+ac_exeext=$EXEEXT+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <stdio.h>+int+main (void)+{+FILE *f = fopen ("conftest.out", "w");+ return ferror (f) || fclose (f) != 0;++ ;+ return 0;+}+_ACEOF+ac_clean_files="$ac_clean_files conftest.out"+# Check that the compiler produces executables we can run. If not, either+# the compiler is broken, or we cross compile.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5+printf %s "checking whether we are cross compiling... " >&6; }+if test "$cross_compiling" != yes; then+ { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+ if { ac_try='./conftest$ac_cv_exeext'+ { { case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_try") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; }; then+ cross_compiling=no+ else+ if test "$cross_compiling" = maybe; then+ cross_compiling=yes+ else+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error 77 "cannot run C compiled programs.+If you meant to cross compile, use \`--host'.+See \`config.log' for more details" "$LINENO" 5; }+ fi+ fi+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5+printf "%s\n" "$cross_compiling" >&6; }++rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out+ac_clean_files=$ac_clean_files_save+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5+printf %s "checking for suffix of object files... " >&6; }+if test ${ac_cv_objext+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+rm -f conftest.o conftest.obj+if { { ac_try="$ac_compile"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compile") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ for ac_file in conftest.o conftest.obj conftest.*; do+ test -f "$ac_file" || continue;+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`+ break;;+ esac+done+else $as_nop+ printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "cannot compute suffix of object files: cannot compile+See \`config.log' for more details" "$LINENO" 5; }+fi+rm -f conftest.$ac_cv_objext conftest.$ac_ext+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5+printf "%s\n" "$ac_cv_objext" >&6; }+OBJEXT=$ac_cv_objext+ac_objext=$OBJEXT+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5+printf %s "checking whether the compiler supports GNU C... " >&6; }+if test ${ac_cv_c_compiler_gnu+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+#ifndef __GNUC__+ choke me+#endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_compiler_gnu=yes+else $as_nop+ ac_compiler_gnu=no+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ac_cv_c_compiler_gnu=$ac_compiler_gnu++fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5+printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; }+ac_compiler_gnu=$ac_cv_c_compiler_gnu++if test $ac_compiler_gnu = yes; then+ GCC=yes+else+ GCC=+fi+ac_test_CFLAGS=${CFLAGS+y}+ac_save_CFLAGS=$CFLAGS+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5+printf %s "checking whether $CC accepts -g... " >&6; }+if test ${ac_cv_prog_cc_g+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_save_c_werror_flag=$ac_c_werror_flag+ ac_c_werror_flag=yes+ ac_cv_prog_cc_g=no+ CFLAGS="-g"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_g=yes+else $as_nop+ CFLAGS=""+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else $as_nop+ ac_c_werror_flag=$ac_save_c_werror_flag+ CFLAGS="-g"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_g=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ac_c_werror_flag=$ac_save_c_werror_flag+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5+printf "%s\n" "$ac_cv_prog_cc_g" >&6; }+if test $ac_test_CFLAGS; then+ CFLAGS=$ac_save_CFLAGS+elif test $ac_cv_prog_cc_g = yes; then+ if test "$GCC" = yes; then+ CFLAGS="-g -O2"+ else+ CFLAGS="-g"+ fi+else+ if test "$GCC" = yes; then+ CFLAGS="-O2"+ else+ CFLAGS=+ fi+fi+ac_prog_cc_stdc=no+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5+printf %s "checking for $CC option to enable C11 features... " >&6; }+if test ${ac_cv_prog_cc_c11+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_prog_cc_c11=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c11_program+_ACEOF+for ac_arg in '' -std=gnu11+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c11=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c11" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC+fi++if test "x$ac_cv_prog_cc_c11" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else $as_nop+ if test "x$ac_cv_prog_cc_c11" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }+ CC="$CC $ac_cv_prog_cc_c11"+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11+ ac_prog_cc_stdc=c11+fi+fi+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5+printf %s "checking for $CC option to enable C99 features... " >&6; }+if test ${ac_cv_prog_cc_c99+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_prog_cc_c99=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c99_program+_ACEOF+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c99=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c99" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC+fi++if test "x$ac_cv_prog_cc_c99" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else $as_nop+ if test "x$ac_cv_prog_cc_c99" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }+ CC="$CC $ac_cv_prog_cc_c99"+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99+ ac_prog_cc_stdc=c99+fi+fi+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5+printf %s "checking for $CC option to enable C89 features... " >&6; }+if test ${ac_cv_prog_cc_c89+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_cv_prog_cc_c89=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c89_program+_ACEOF+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c89=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c89" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC+fi++if test "x$ac_cv_prog_cc_c89" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else $as_nop+ if test "x$ac_cv_prog_cc_c89" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else $as_nop+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }+ CC="$CC $ac_cv_prog_cc_c89"+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89+ ac_prog_cc_stdc=c89+fi+fi++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5+printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; }+if test ${ac_cv_c_undeclared_builtin_options+y}+then :+ printf %s "(cached) " >&6+else $as_nop+ ac_save_CFLAGS=$CFLAGS+ ac_cv_c_undeclared_builtin_options='cannot detect'+ for ac_arg in '' -fno-builtin; do+ CFLAGS="$ac_save_CFLAGS $ac_arg"+ # This test program should *not* compile successfully.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+(void) strchr;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else $as_nop+ # This test program should compile successfully.+ # No library function is consistently available on+ # freestanding implementations, so test against a dummy+ # declaration. Include always-available headers on the+ # off chance that they somehow elicit warnings.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <float.h>+#include <limits.h>+#include <stdarg.h>+#include <stddef.h>+extern void ac_decl (int, char *);++int+main (void)+{+(void) ac_decl (0, (char *) 0);+ (void) ac_decl;++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ if test x"$ac_arg" = x+then :+ ac_cv_c_undeclared_builtin_options='none needed'+else $as_nop+ ac_cv_c_undeclared_builtin_options=$ac_arg+fi+ break+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ done+ CFLAGS=$ac_save_CFLAGS++fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5+printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; }+ case $ac_cv_c_undeclared_builtin_options in #(+ 'cannot detect') :+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "cannot make $CC report undeclared builtins+See \`config.log' for more details" "$LINENO" 5; } ;; #(+ 'none needed') :+ ac_c_undeclared_builtin_options='' ;; #(+ *) :+ ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;;+esac++ac_fn_check_decl "$LINENO" "IN_MASK_CREATE" "ac_cv_have_decl_IN_MASK_CREATE" "#include <sys/inotify.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_IN_MASK_CREATE" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_IN_MASK_CREATE $ac_have_decl" >>confdefs.h++ac_fn_check_decl "$LINENO" "IN_EXCL_UNLINK" "ac_cv_have_decl_IN_EXCL_UNLINK" "#include <sys/inotify.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_IN_EXCL_UNLINK" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_IN_EXCL_UNLINK $ac_have_decl" >>confdefs.h+++# XXX Do this only for macOS+ac_fn_check_decl "$LINENO" "kFSEventStreamCreateFlagFileEvents" "ac_cv_have_decl_kFSEventStreamCreateFlagFileEvents" "#include <CoreServices/CoreServices.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_kFSEventStreamCreateFlagFileEvents" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS $ac_have_decl" >>confdefs.h++ac_fn_check_decl "$LINENO" "kFSEventStreamCreateFlagFullHistory" "ac_cv_have_decl_kFSEventStreamCreateFlagFullHistory" "#include <CoreServices/CoreServices.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_kFSEventStreamCreateFlagFullHistory" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY $ac_have_decl" >>confdefs.h++ac_fn_check_decl "$LINENO" "kFSEventStreamEventFlagItemCloned" "ac_cv_have_decl_kFSEventStreamEventFlagItemCloned" "#include <CoreServices/CoreServices.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_kFSEventStreamEventFlagItemCloned" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED $ac_have_decl" >>confdefs.h++ac_fn_check_decl "$LINENO" "kFSEventStreamEventFlagItemIsHardlink" "ac_cv_have_decl_kFSEventStreamEventFlagItemIsHardlink" "#include <CoreServices/CoreServices.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_kFSEventStreamEventFlagItemIsHardlink" = xyes+then :+ ac_have_decl=1+else $as_nop+ ac_have_decl=0+fi+printf "%s\n" "#define HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK $ac_have_decl" >>confdefs.h+++# Output+ac_config_headers="$ac_config_headers src/config.h"++cat >confcache <<\_ACEOF+# This file is a shell script that caches the results of configure+# tests run on this system so they can be shared between configure+# scripts and configure runs, see configure's option --config-cache.+# It is not useful on other systems. If it contains results you don't+# want to keep, you may remove or edit it.+#+# config.status only pays attention to the cache file if you give it+# the --recheck option to rerun configure.+#+# `ac_cv_env_foo' variables (set or unset) will be overridden when+# loading this file, other *unset* `ac_cv_foo' will be assigned the+# following values.++_ACEOF++# The following way of writing the cache mishandles newlines in values,+# but we know of no workaround that is simple, portable, and efficient.+# So, we kill variables containing newlines.+# Ultrix sh set writes to stderr and can't be redirected directly,+# and sets the high bit in the cache file unless we assign to the vars.+(+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do+ eval ac_val=\$$ac_var+ case $ac_val in #(+ *${as_nl}*)+ case $ac_var in #(+ *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+ esac+ case $ac_var in #(+ _ | IFS | as_nl) ;; #(+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+ *) { eval $ac_var=; unset $ac_var;} ;;+ esac ;;+ esac+ done++ (set) 2>&1 |+ case $as_nl`(ac_space=' '; set) 2>&1` in #(+ *${as_nl}ac_space=\ *)+ # `set' does not quote correctly, so add quotes: double-quote+ # substitution turns \\\\ into \\, and sed turns \\ into \.+ sed -n \+ "s/'/'\\\\''/g;+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"+ ;; #(+ *)+ # `set' quotes correctly as required by POSIX, so do not add quotes.+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+ ;;+ esac |+ sort+) |+ sed '+ /^ac_cv_env_/b end+ t clear+ :clear+ s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/+ t end+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/+ :end' >>confcache+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else+ if test -w "$cache_file"; then+ if test "x$cache_file" != "x/dev/null"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5+printf "%s\n" "$as_me: updating cache $cache_file" >&6;}+ if test ! -f "$cache_file" || test -h "$cache_file"; then+ cat confcache >"$cache_file"+ else+ case $cache_file in #(+ */* | ?:*)+ mv -f confcache "$cache_file"$$ &&+ mv -f "$cache_file"$$ "$cache_file" ;; #(+ *)+ mv -f confcache "$cache_file" ;;+ esac+ fi+ fi+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5+printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;}+ fi+fi+rm -f confcache++test "x$prefix" = xNONE && prefix=$ac_default_prefix+# Let make expand exec_prefix.+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'++DEFS=-DHAVE_CONFIG_H++ac_libobjs=+ac_ltlibobjs=+U=+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue+ # 1. Remove the extension, and $U if already installed.+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'+ ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"`+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR+ # will be set to the directory where LIBOBJS objects are built.+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'+done+LIBOBJS=$ac_libobjs++LTLIBOBJS=$ac_ltlibobjs++++: "${CONFIG_STATUS=./config.status}"+ac_write_fail=0+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files $CONFIG_STATUS"+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5+printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;}+as_write_fail=0+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1+#! $SHELL+# Generated by $as_me.+# Run this file to recreate the current configuration.+# Compiler output produced by configure, useful for debugging+# configure, is in config.log if it exists.++debug=false+ac_cs_recheck=false+ac_cs_silent=false++SHELL=\${CONFIG_SHELL-$SHELL}+export SHELL+_ASEOF+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1+## -------------------- ##+## M4sh Initialization. ##+## -------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+as_nop=:+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else $as_nop+ case `(set -o) 2>/dev/null` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac+fi++++# Reset variables that may have inherited troublesome values from+# the environment.++# IFS needs to be set, to space, tab, and newline, in precisely that order.+# (If _AS_PATH_WALK were called with IFS unset, it would have the+# side effect of setting IFS to empty, thus disabling word splitting.)+# Quoting is to prevent editors from complaining about space-tab.+as_nl='+'+export as_nl+IFS=" "" $as_nl"++PS1='$ '+PS2='> '+PS4='+ '++# Ensure predictable behavior from utilities with locale-dependent output.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# We cannot yet rely on "unset" to work, but we need these variables+# to be unset--not just set to an empty or harmless value--now, to+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct+# also avoids known problems related to "unset" and subshell syntax+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH+do eval test \${$as_var+y} \+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done++# Ensure that fds 0, 1, and 2 are open.+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi+if (exec 3>&2) ; then :; else exec 2>/dev/null; fi++# The user is always right.+if ${PATH_SEPARATOR+false} :; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# Find who we are. Look in the path if we contain no directory separator.+as_myself=+case $0 in #((+ *[\\/]* ) as_myself=$0 ;;+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ test -r "$as_dir$0" && as_myself=$as_dir$0 && break+ done+IFS=$as_save_IFS++ ;;+esac+# We did not find ourselves, most probably we were run as `sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+ as_myself=$0+fi+if test ! -f "$as_myself"; then+ printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+ exit 1+fi++++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+ as_status=$1; test $as_status -eq 0 && as_status=1+ if test "$4"; then+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+ fi+ printf "%s\n" "$as_me: error: $2" >&2+ as_fn_exit $as_status+} # as_fn_error++++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+ return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+ set +e+ as_fn_set_status $1+ exit $1+} # as_fn_exit++# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+ { eval $1=; unset $1;}+}+as_unset=as_fn_unset++# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null+then :+ eval 'as_fn_append ()+ {+ eval $1+=\$2+ }'+else $as_nop+ as_fn_append ()+ {+ eval $1=\$$1\$2+ }+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null+then :+ eval 'as_fn_arith ()+ {+ as_val=$(( $* ))+ }'+else $as_nop+ as_fn_arith ()+ {+ as_val=`expr "$@" || test $? -eq 1`+ }+fi # as_fn_arith+++if expr a : '\(a\)' >/dev/null 2>&1 &&+ test "X`expr 00001 : '.*\(...\)'`" = X001; then+ as_expr=expr+else+ as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+ as_basename=basename+else+ as_basename=false+fi++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+ as_dirname=dirname+else+ as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+ X"$0" : 'X\(//\)$' \| \+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$0" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`++# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits+++# Determine whether it's possible to make 'echo' print without a newline.+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed+# for compatibility with existing Makefiles.+ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+ case `echo 'xy\c'` in+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.+ xy) ECHO_C='\c';;+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null+ ECHO_T=' ';;+ esac;;+*)+ ECHO_N='-n';;+esac++# For backward compatibility with old third-party macros, we provide+# the shell variables $as_echo and $as_echo_n. New code should use+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.+as_echo='printf %s\n'+as_echo_n='printf %s'++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+ rm -f conf$$.dir/conf$$.file+else+ rm -f conf$$.dir+ mkdir conf$$.dir 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+ if ln -s conf$$.file conf$$ 2>/dev/null; then+ as_ln_s='ln -s'+ # ... but there are two gotchas:+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.+ # In both cases, we have to default to `cp -pR'.+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+ as_ln_s='cp -pR'+ elif ln conf$$.file conf$$ 2>/dev/null; then+ as_ln_s=ln+ else+ as_ln_s='cp -pR'+ fi+else+ as_ln_s='cp -pR'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null+++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++ case $as_dir in #(+ -*) as_dir=./$as_dir;;+ esac+ test -d "$as_dir" || eval $as_mkdir_p || {+ as_dirs=+ while :; do+ case $as_dir in #(+ *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(+ *) as_qdir=$as_dir;;+ esac+ as_dirs="'$as_qdir' $as_dirs"+ as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_dir" : 'X\(//\)[^/]' \| \+ X"$as_dir" : 'X\(//\)$' \| \+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_dir" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ test -d "$as_dir" && break+ done+ test -z "$as_dirs" || eval "mkdir $as_dirs"+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p+if mkdir -p . 2>/dev/null; then+ as_mkdir_p='mkdir -p "$as_dir"'+else+ test -d ./-p && rmdir ./-p+ as_mkdir_p=false+fi+++# as_fn_executable_p FILE+# -----------------------+# Test if FILE is an executable regular file.+as_fn_executable_p ()+{+ test -f "$1" && test -x "$1"+} # as_fn_executable_p+as_test_x='test -x'+as_executable_p=as_fn_executable_p++# Sed expression to map a string onto a valid CPP name.+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"++# Sed expression to map a string onto a valid variable name.+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"+++exec 6>&1+## ----------------------------------- ##+## Main body of $CONFIG_STATUS script. ##+## ----------------------------------- ##+_ASEOF+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# Save the log message, to keep $0 and so on meaningful, and to+# report actual input values of CONFIG_FILES etc. instead of their+# values after options handling.+ac_log="+This file was extended by streamly $as_me 0.11.0, which was+generated by GNU Autoconf 2.71. Invocation command line was++ CONFIG_FILES = $CONFIG_FILES+ CONFIG_HEADERS = $CONFIG_HEADERS+ CONFIG_LINKS = $CONFIG_LINKS+ CONFIG_COMMANDS = $CONFIG_COMMANDS+ $ $0 $@++on `(hostname || uname -n) 2>/dev/null | sed 1q`+"++_ACEOF+++case $ac_config_headers in *"+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;+esac+++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+# Files that config.status was made for.+config_headers="$ac_config_headers"++_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ac_cs_usage="\+\`$as_me' instantiates files and other configuration actions+from templates according to the current configuration. Unless the files+and actions are specified as TAGs, all are instantiated by default.++Usage: $0 [OPTION]... [TAG]...++ -h, --help print this help, then exit+ -V, --version print version number and configuration settings, then exit+ --config print configuration, then exit+ -q, --quiet, --silent+ do not print progress messages+ -d, --debug don't remove temporary files+ --recheck update $as_me by reconfiguring in the same conditions+ --header=FILE[:TEMPLATE]+ instantiate the configuration header FILE++Configuration headers:+$config_headers++Report bugs to <streamly@composewell.com>.+streamly home page: <https://streamly.composewell.com>."++_ACEOF+ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`+ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ac_cs_config='$ac_cs_config_escaped'+ac_cs_version="\\+streamly config.status 0.11.0+configured by $0, generated by GNU Autoconf 2.71,+ with options \\"\$ac_cs_config\\"++Copyright (C) 2021 Free Software Foundation, Inc.+This config.status script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it."++ac_pwd='$ac_pwd'+srcdir='$srcdir'+test -n "\$AWK" || AWK=awk+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# The default lists apply if the user does not specify any file.+ac_need_defaults=:+while test $# != 0+do+ case $1 in+ --*=?*)+ ac_option=`expr "X$1" : 'X\([^=]*\)='`+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`+ ac_shift=:+ ;;+ --*=)+ ac_option=`expr "X$1" : 'X\([^=]*\)='`+ ac_optarg=+ ac_shift=:+ ;;+ *)+ ac_option=$1+ ac_optarg=$2+ ac_shift=shift+ ;;+ esac++ case $ac_option in+ # Handling of the options.+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)+ ac_cs_recheck=: ;;+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )+ printf "%s\n" "$ac_cs_version"; exit ;;+ --config | --confi | --conf | --con | --co | --c )+ printf "%s\n" "$ac_cs_config"; exit ;;+ --debug | --debu | --deb | --de | --d | -d )+ debug=: ;;+ --header | --heade | --head | --hea )+ $ac_shift+ case $ac_optarg in+ *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"+ ac_need_defaults=false;;+ --he | --h)+ # Conflict between --help and --header+ as_fn_error $? "ambiguous option: \`$1'+Try \`$0 --help' for more information.";;+ --help | --hel | -h )+ printf "%s\n" "$ac_cs_usage"; exit ;;+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil | --si | --s)+ ac_cs_silent=: ;;++ # This is an error.+ -*) as_fn_error $? "unrecognized option: \`$1'+Try \`$0 --help' for more information." ;;++ *) as_fn_append ac_config_targets " $1"+ ac_need_defaults=false ;;++ esac+ shift+done++ac_configure_extra_args=++if $ac_cs_silent; then+ exec 6>/dev/null+ ac_configure_extra_args="$ac_configure_extra_args --silent"+fi++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+if \$ac_cs_recheck; then+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion+ shift+ \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6+ CONFIG_SHELL='$SHELL'+ export CONFIG_SHELL+ exec "\$@"+fi++_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+exec 5>>config.log+{+ echo+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX+## Running $as_me. ##+_ASBOX+ printf "%s\n" "$ac_log"+} >&5++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1++# Handling of arguments.+for ac_config_target in $ac_config_targets+do+ case $ac_config_target in+ "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;++ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;+ esac+done+++# If the user did not use the arguments to specify the items to instantiate,+# then the envvar interface is used. Set only those that are not.+# We use the long form for the default assignment because of an extremely+# bizarre bug on SunOS 4.1.3.+if $ac_need_defaults; then+ test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers+fi++# Have a temporary directory for convenience. Make it in the build tree+# simply because there is no reason against having it here, and in addition,+# creating and moving files from /tmp can sometimes cause problems.+# Hook for its removal unless debugging.+# Note that there is a small window in which the directory will not be cleaned:+# after its creation but before its name has been assigned to `$tmp'.+$debug ||+{+ tmp= ac_tmp=+ trap 'exit_status=$?+ : "${ac_tmp:=$tmp}"+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status+' 0+ trap 'as_fn_exit 1' 1 2 13 15+}+# Create a (secure) tmp directory for tmp files.++{+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&+ test -d "$tmp"+} ||+{+ tmp=./conf$$-$RANDOM+ (umask 077 && mkdir "$tmp")+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5+ac_tmp=$tmp++# Set up the scripts for CONFIG_HEADERS section.+# No need to generate them if there are no CONFIG_HEADERS.+# This happens for instance with `./config.status Makefile'.+if test -n "$CONFIG_HEADERS"; then+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||+BEGIN {+_ACEOF++# Transform confdefs.h into an awk script `defines.awk', embedded as+# here-document in config.status, that substitutes the proper values into+# config.h.in to produce config.h.++# Create a delimiter string that does not exist in confdefs.h, to ease+# handling of long lines.+ac_delim='%!_!# '+for ac_last_try in false false :; do+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`+ if test -z "$ac_tt"; then+ break+ elif $ac_last_try; then+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5+ else+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "+ fi+done++# For the awk script, D is an array of macro values keyed by name,+# likewise P contains macro parameters if any. Preserve backslash+# newline sequences.++ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*+sed -n '+s/.\{148\}/&'"$ac_delim"'/g+t rset+:rset+s/^[ ]*#[ ]*define[ ][ ]*/ /+t def+d+:def+s/\\$//+t bsnl+s/["\\]/\\&/g+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\+D["\1"]=" \3"/p+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p+d+:bsnl+s/["\\]/\\&/g+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\+D["\1"]=" \3\\\\\\n"\\/p+t cont+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p+t cont+d+:cont+n+s/.\{148\}/&'"$ac_delim"'/g+t clear+:clear+s/\\$//+t bsnlc+s/["\\]/\\&/g; s/^/"/; s/$/"/p+d+:bsnlc+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p+b cont+' <confdefs.h | sed '+s/'"$ac_delim"'/"\\\+"/g' >>$CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ for (key in D) D_is_set[key] = 1+ FS = ""+}+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {+ line = \$ 0+ split(line, arg, " ")+ if (arg[1] == "#") {+ defundef = arg[2]+ mac1 = arg[3]+ } else {+ defundef = substr(arg[1], 2)+ mac1 = arg[2]+ }+ split(mac1, mac2, "(") #)+ macro = mac2[1]+ prefix = substr(line, 1, index(line, defundef) - 1)+ if (D_is_set[macro]) {+ # Preserve the white space surrounding the "#".+ print prefix "define", macro P[macro] D[macro]+ next+ } else {+ # Replace #undef with comments. This is necessary, for example,+ # in the case of _POSIX_SOURCE, which is predefined and required+ # on some systems where configure will not decide to define it.+ if (defundef == "undef") {+ print "/*", prefix defundef, macro, "*/"+ next+ }+ }+}+{ print }+_ACAWK+_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5+fi # test -n "$CONFIG_HEADERS"+++eval set X " :H $CONFIG_HEADERS "+shift+for ac_tag+do+ case $ac_tag in+ :[FHLC]) ac_mode=$ac_tag; continue;;+ esac+ case $ac_mode$ac_tag in+ :[FHL]*:*);;+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;+ :[FH]-) ac_tag=-:-;;+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;+ esac+ ac_save_IFS=$IFS+ IFS=:+ set x $ac_tag+ IFS=$ac_save_IFS+ shift+ ac_file=$1+ shift++ case $ac_mode in+ :L) ac_source=$1;;+ :[FH])+ ac_file_inputs=+ for ac_f+ do+ case $ac_f in+ -) ac_f="$ac_tmp/stdin";;+ *) # Look for the file first in the build tree, then in the source tree+ # (if the path is not absolute). The absolute path cannot be DOS-style,+ # because $ac_f cannot contain `:'.+ test -f "$ac_f" ||+ case $ac_f in+ [\\/$]*) false;;+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;+ esac ||+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;+ esac+ case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac+ as_fn_append ac_file_inputs " '$ac_f'"+ done++ # Let's still pretend it is `configure' which instantiates (i.e., don't+ # use $as_me), people would be surprised to read:+ # /* config.h. Generated by config.status. */+ configure_input='Generated from '`+ printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'+ `' by configure.'+ if test x"$ac_file" != x-; then+ configure_input="$ac_file. $configure_input"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5+printf "%s\n" "$as_me: creating $ac_file" >&6;}+ fi+ # Neutralize special characters interpreted by sed in replacement strings.+ case $configure_input in #(+ *\&* | *\|* | *\\* )+ ac_sed_conf_input=`printf "%s\n" "$configure_input" |+ sed 's/[\\\\&|]/\\\\&/g'`;; #(+ *) ac_sed_conf_input=$configure_input;;+ esac++ case $ac_tag in+ *:-:* | *:-) cat >"$ac_tmp/stdin" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;+ esac+ ;;+ esac++ ac_dir=`$as_dirname -- "$ac_file" ||+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$ac_file" : 'X\(//\)[^/]' \| \+ X"$ac_file" : 'X\(//\)$' \| \+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$ac_file" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ as_dir="$ac_dir"; as_fn_mkdir_p+ ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+ ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`+ # A ".." for each directory in $ac_dir_suffix.+ ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`+ case $ac_top_builddir_sub in+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;+ esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+ .) # We are building in place.+ ac_srcdir=.+ ac_top_srcdir=$ac_top_builddir_sub+ ac_abs_top_srcdir=$ac_pwd ;;+ [\\/]* | ?:[\\/]* ) # Absolute name.+ ac_srcdir=$srcdir$ac_dir_suffix;+ ac_top_srcdir=$srcdir+ ac_abs_top_srcdir=$srcdir ;;+ *) # Relative name.+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+ ac_top_srcdir=$ac_top_build_prefix$srcdir+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix+++ case $ac_mode in++ :H)+ #+ # CONFIG_HEADER+ #+ if test x"$ac_file" != x-; then+ {+ printf "%s\n" "/* $configure_input */" >&1 \+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"+ } >"$ac_tmp/config.h" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5+printf "%s\n" "$as_me: $ac_file is unchanged" >&6;}+ else+ rm -f "$ac_file"+ mv "$ac_tmp/config.h" "$ac_file" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ fi+ else+ printf "%s\n" "/* $configure_input */" >&1 \+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \+ || as_fn_error $? "could not create -" "$LINENO" 5+ fi+ ;;+++ esac++done # for ac_tag+++as_fn_exit 0+_ACEOF+ac_clean_files=$ac_clean_files_save++test $ac_write_fail = 0 ||+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5+++# configure is writing to config.log, and then calls config.status.+# config.status does its own redirection, appending to config.log.+# Unfortunately, on DOS this fails, as config.log is still kept open+# by configure, so config.status won't be able to write to it; its+# output is simply discarded. So we exec the FD to /dev/null,+# effectively closing config.log, so it can be properly (re)opened and+# appended to by config.status. When coming back to configure, we+# need to make the FD available again.+if test "$no_create" != yes; then+ ac_cs_success=:+ ac_config_status_args=+ test "$silent" = yes &&+ ac_config_status_args="$ac_config_status_args --quiet"+ exec 5>/dev/null+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false+ exec 5>>config.log+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which+ # would make configure fail if this is the last instruction.+ $ac_cs_success || as_fn_exit 1+fi+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5+printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}+fi++
+ configure.ac view
@@ -0,0 +1,23 @@+# Input file for autoconf to generate the configure script.++# See https://www.gnu.org/software/autoconf/manual/autoconf.html for help on+# the macros used in this file.++AC_INIT([streamly], [0.11.0], [streamly@composewell.com], [streamly], [https://streamly.composewell.com])++# To suppress "WARNING: unrecognized options: --with-compiler"+AC_ARG_WITH([compiler], [GHC])++# XXX Do this only for linux+AC_CHECK_DECLS([IN_MASK_CREATE],[],[],[#include <sys/inotify.h>])+AC_CHECK_DECLS([IN_EXCL_UNLINK],[],[],[#include <sys/inotify.h>])++# XXX Do this only for macOS+AC_CHECK_DECLS([kFSEventStreamCreateFlagFileEvents],[],[],[#include <CoreServices/CoreServices.h>])+AC_CHECK_DECLS([kFSEventStreamCreateFlagFullHistory],[],[],[#include <CoreServices/CoreServices.h>])+AC_CHECK_DECLS([kFSEventStreamEventFlagItemCloned],[],[],[#include <CoreServices/CoreServices.h>])+AC_CHECK_DECLS([kFSEventStreamEventFlagItemIsHardlink],[],[],[#include <CoreServices/CoreServices.h>])++# Output+AC_CONFIG_HEADERS([src/config.h])+AC_OUTPUT
+ src/Streamly/FileSystem/Event.hs view
@@ -0,0 +1,45 @@+-- |+-- Module : Streamly.FileSystem.Event+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : pre-release+-- Portability : GHC+--+-- File system event notification API portable across Linux, macOS and Windows+-- platforms.+--+-- Note that recursive directory tree watch does not work reliably on Linux+-- (see notes in the Linux module), therefore, recursive watch API is not+-- provided in this module. However, you can use it from the platform specific+-- modules.+--+-- For platform specific APIs please see the following modules:+--+-- * "Streamly.Internal.FS.Event.Darwin"+-- * "Streamly.Internal.FS.Event.Linux"+-- * "Streamly.Internal.FS.Event.Windows"++module Streamly.FileSystem.Event+ (+ -- * Creating a Watch++ watch+ -- , watchRecursive++ -- * Handling Events+ , Event+ , getAbsPath++ -- ** Item CRUD events+ , isCreated+ , isDeleted+ , isMoved+ , isModified++ -- ** Exception Conditions+ , isEventsLost+ )+where++import Streamly.Internal.FS.Event
+ src/Streamly/Internal/FS/Event.hs view
@@ -0,0 +1,244 @@+-- |+-- Module : Streamly.Internal.FS.Event+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : pre-release+-- Portability : GHC+--+-- File system event notification API portable across Linux, macOS and Windows+-- platforms.+--+-- Note that recursive directory tree watch does not work reliably on Linux+-- (see notes in the Linux module), therefore, recursive watch API is not+-- provided in this module. However, you can use it from the platform specific+-- modules.+--+-- For platform specific APIs please see the following modules:+--+-- * "Streamly.Internal.FS.Event.Darwin"+-- * "Streamly.Internal.FS.Event.Linux"+-- * "Streamly.Internal.FS.Event.Windows"++-- XXX Need to ensure that the signatures of the exported APIs are same on all+-- platforms.++module Streamly.Internal.FS.Event+ (+ -- * Creating a Watch++ watch+ -- , watchRecursive++ -- * Handling Events+ , Event+ , getAbsPath++ -- ** Item CRUD events+ , isCreated+ , isDeleted+ , isMoved+ , isModified++ -- ** Exception Conditions+ , isEventsLost++ -- ** Debugging+ , showEvent+ )+where++import Data.List.NonEmpty (NonEmpty)+import Streamly.Data.Stream (Stream)+import Streamly.FileSystem.Path (Path)++#if defined(CABAL_OS_DARWIN)+import Streamly.Internal.FS.Event.Darwin (Event)+import qualified Streamly.Internal.FS.Event.Darwin as Event+#elif defined(CABAL_OS_LINUX)+import Streamly.Internal.FS.Event.Linux (Event)+import qualified Streamly.Internal.FS.Event.Linux as Event+#elif defined(CABAL_OS_WINDOWS)+import Streamly.Internal.FS.Event.Windows (Event)+import qualified Streamly.Internal.FS.Event.Windows as Event+#else+#error "FS Events not supported on this platform"+#endif++-- XXX Ensure that defaultConfig is the same for all platforms.+--+-- XXX Ensure that equivalent events are generated on all platforms when same+-- operations are done. Document any differences in behavior on different+-- platforms. Any events that are not common to all platforms should be+-- filtered out.+--+-- XXX Only need to set common event types for macOS/Linux/Windows+-- XXX write a test, that generates all types of events that can possibly+-- occur on each platform. Then create a common test that only checks+-- for the common subset of those.++-------------------------------------------------------------------------------+-- Creating a watch+-------------------------------------------------------------------------------++-- macOS and Windows seem to do a path level watch i.e. they watch the path+-- rather than the underlying inode, possibly they can map the inode back to a+-- path?. On Linux we cannot keep watching a watch root if the inode it is+-- pointing to has moved. However, the inode continues to be watched in this+-- case instead of the path, which is not the case for macOS.+--+-- To make the behavior same for all platforms, for the Linux case we will have+-- to stop watching the inode if it moves from under the path+-- (setUnwatchMoved). And on macOS we can stop watching a path if the inode+-- under it changes i.e. just filter out events for that path.+--+-- Also, to make the behavior of Linux same as macOS we need to set+-- setFollowSymLinks on Linux.++-- XXX Verify all the cases mentioned below using test cases.+-- XXX Make it fail if the watch root is a file. It works on macOS and Linux+-- but does not work on Windows.++-- | Start monitoring a list of directories or symbolic links to directories+-- for file system events. Monitoring starts from the current time onwards.+-- The paths are specified as UTF-8 encoded 'Array' of 'Word8'.+--+-- If a watch root is a symbolic link then the target of the link is watched.+-- Fails if the watched path does not exist. If the user does not have+-- permissions (read and execute?) on the watch root then no events are+-- generated. No events are generated if the watch root itself is renamed or+-- deleted.+--+-- This API watches for changes in the watch root directory only, any changes+-- in the subdirectories of the watch root are not watched. However, on macOS+-- the watch is always recursive, but do not rely on that behavior, it may+-- change without notice in future. If you want to use recursive watch please+-- use platform specific modules.+--+-- /Pre-release/+--+watch :: NonEmpty Path -> Stream IO Event+#if defined(CABAL_OS_DARWIN)+watch = Event.watchRecursive+#else+watch = Event.watch+#endif++-- | Like 'watch' except that if a watched path is a directory the whole+-- directory tree under it is watched recursively.+--+-- On Linux 'watchRecursive' may be more expensive than 'watch'.+--+-- /Pre-release/+--+_watchRecursive :: NonEmpty Path -> Stream IO Event+_watchRecursive = Event.watchRecursive++-------------------------------------------------------------------------------+-- Handling Events+-------------------------------------------------------------------------------++-- XXX Ensure that on all paltforms the path has same conventions. That is do+-- not have a trailing path separator on one platfrom and not on another.+--+-- XXX We should use getRelPath instead so that the behavior when the root is a+-- symlink becomes platform independent.+--+-- | Get the absolute path of the file system object for which the event is+-- generated. The path is a UTF-8 encoded array of bytes.+--+-- When the watch root is a symlink the behavior is different on different+-- platforms:+--+-- * On Linux and Windows, the absolute path returned is via the original+-- symlink.+--+-- * On macOS the absolute path returned is via the real path of the root after+-- resolving the symlink.+--+-- This API is subject to removal in future, to be replaced by a platform+-- independent @getRelPath@.+--+-- /Pre-release/+--+getAbsPath :: Event -> Path+getAbsPath = Event.getAbsPath++-- | Determine whether the event indicates creation of an object within the+-- monitored path. This event is generated when any file system object is+-- created.+--+-- For hard links the behavior is different on different operating systems. On+-- macOS hard linking does not generate a create event, it generates an+-- 'isInodeAttrsChanged' event on the directory instead (see the Darwin+-- module). On Linux and Windows hard linking generates a create event.+--+-- /Pre-release/+--+isCreated :: Event -> Bool+isCreated = Event.isCreated++-- XXX To make the behavior consistent, can we block the event on watch root on+-- macOS?+--+-- | Determine whether the event indicates deletion of an object within the+-- monitored path. On Linux and Windows hard link deletion generates a delete+-- event.+--+-- On Linux and Windows, this event does not occur when the watch root itself+-- is deleted. On macOS it occurs on deleting the watch root when it is not a+-- symbolic link.+--+-- See also 'isRootDeleted' event for Linux.+--+-- /Pre-release/+--+isDeleted :: Event -> Bool+isDeleted = Event.isDeleted++-- | Determine whether the event indicates rename of an object within the+-- monitored path. This event is generated when an object is renamed within the+-- watched directory or if it is moved out of or in the watched directory.+-- Moving hard links is no different than other types of objects.+--+-- /Pre-release/+--+isMoved :: Event -> Bool+isMoved = Event.isMoved++-- XXX Make the Windows behavior consistent with other platforms by removing+-- the event from directories.+--+-- | Determine whether the event indicates modification of an object within the+-- monitored path. This event is generated on file modification on all+-- platforms.+--+-- On Linux and macOS this event is never generated for directories. On+-- Windows (in recursive watch mode) this event is generated for directories as+-- well when an object is created in or deleted from the directory.+--+-- /Pre-release/+--+isModified :: Event -> Bool+isModified = Event.isModified++-- | An event that indicates that some events before this may have been lost,+-- therefore, we need to take some recovery action.+--+-- /Pre-release/+--+isEventsLost :: Event -> Bool+isEventsLost = Event.isEventsLost++-------------------------------------------------------------------------------+-- Debugging+-------------------------------------------------------------------------------++-- | Convert an 'Event' record to a String representation. Note that the output+-- of this function may be different on different platforms because it may+-- contain platform specific details.+--+-- /Internal/+--+showEvent :: Event -> String+showEvent = Event.showEvent
+ src/Streamly/Internal/FS/Event/Darwin.c view
@@ -0,0 +1,287 @@+/*+ * Code adapted from the Haskell "hfsevents" package.+ *+ * Copyright (c) 2012, Luite Stegeman+ *+ */++#include <config.h>++#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS++#include <CoreServices/CoreServices.h>+#include <pthread.h>+#include <unistd.h>+#include <FS/Event/Darwin.h>++/*+ * For reference documentaion see:+ * https://developer.apple.com/documentation/coreservices/file_system_events?language=objc+ * https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html+ *+ * An OS thread is started which runs the event loop. A pipe is created+ * and the events are sent to the pipes. The receiver can read the pipe+ * output end to get the events.+ */++/******************************************************************************+ * Create Flags+ *****************************************************************************/++UInt32 FSEventStreamCreateFlagNoDefer () {+ return kFSEventStreamCreateFlagNoDefer;+}+UInt32 FSEventStreamCreateFlagWatchRoot () {+ return kFSEventStreamCreateFlagWatchRoot;+}+UInt32 FSEventStreamCreateFlagFileEvents () {+ return kFSEventStreamCreateFlagFileEvents;+}+UInt32 FSEventStreamCreateFlagIgnoreSelf () {+ return kFSEventStreamCreateFlagIgnoreSelf;+}+#if 0+UInt32 FSEventStreamCreateFlagFullHistory = kFSEventStreamCreateFlagFullHistory;+#endif++/******************************************************************************+ * Event Flags+ *****************************************************************************/++UInt32 FSEventStreamEventFlagEventIdsWrapped () {+ return kFSEventStreamEventFlagEventIdsWrapped;+}+UInt32 FSEventStreamEventFlagMustScanSubDirs () {+ return kFSEventStreamEventFlagMustScanSubDirs;+}+UInt32 FSEventStreamEventFlagKernelDropped () {+ return kFSEventStreamEventFlagKernelDropped;+}+UInt32 FSEventStreamEventFlagUserDropped () {+ return kFSEventStreamEventFlagUserDropped;+}+UInt32 FSEventStreamEventFlagHistoryDone () {+ return kFSEventStreamEventFlagHistoryDone;+}+UInt32 FSEventStreamEventFlagRootChanged () {+ return kFSEventStreamEventFlagRootChanged;+}+UInt32 FSEventStreamEventFlagMount () {+ return kFSEventStreamEventFlagMount;+}+UInt32 FSEventStreamEventFlagUnmount () {+ return kFSEventStreamEventFlagUnmount;+}+UInt32 FSEventStreamEventFlagItemChangeOwner () {+ return kFSEventStreamEventFlagItemChangeOwner;+}+UInt32 FSEventStreamEventFlagItemInodeMetaMod () {+ return kFSEventStreamEventFlagItemInodeMetaMod;+}+UInt32 FSEventStreamEventFlagItemFinderInfoMod () {+ return kFSEventStreamEventFlagItemFinderInfoMod;+}+UInt32 FSEventStreamEventFlagItemXattrMod () {+ return kFSEventStreamEventFlagItemXattrMod;+}+UInt32 FSEventStreamEventFlagItemCreated () {+ return kFSEventStreamEventFlagItemCreated;+}+UInt32 FSEventStreamEventFlagItemRemoved () {+ return kFSEventStreamEventFlagItemRemoved;+}+UInt32 FSEventStreamEventFlagItemRenamed () {+ return kFSEventStreamEventFlagItemRenamed;+}+UInt32 FSEventStreamEventFlagItemModified () {+ return kFSEventStreamEventFlagItemModified;+}+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300+UInt32 FSEventStreamEventFlagItemCloned () {+ return kFSEventStreamEventFlagItemCloned;+}+#endif+UInt32 FSEventStreamEventFlagItemIsDir () {+ return kFSEventStreamEventFlagItemIsDir;+}+UInt32 FSEventStreamEventFlagItemIsFile () {+ return kFSEventStreamEventFlagItemIsFile;+}+UInt32 FSEventStreamEventFlagItemIsSymlink () {+ return kFSEventStreamEventFlagItemIsSymlink;+}+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000+UInt32 FSEventStreamEventFlagItemIsHardlink () {+ return kFSEventStreamEventFlagItemIsHardlink;+}+#endif+UInt32 FSEventStreamEventFlagItemIsLastHardlink () {+ return kFSEventStreamEventFlagItemIsLastHardlink;+}++/******************************************************************************+ * Event watch+ *****************************************************************************/++/* Write an event to the pipe input fd */+static void writeEvent(int fd, UInt64 eventId, UInt64 eventFlags, char* path)+{+ UInt64 buf[3];+ /* XXX Is the path string in UTF-8? */+ size_t len = strlen(path);++ buf[0] = eventId;+ buf[1] = eventFlags;+ buf[2] = (UInt64)len;+ write(fd, buf, 3 * sizeof(UInt64));+ write(fd, path, len);+}++struct watch+{+ FSEventStreamRef eventStream;+ dispatch_queue_t queue;+ int writefd;+};++/* Just writes the event to the pipe input fd */+static void watchCallback+ ( ConstFSEventStreamRef streamRef+ , void *clientCallBackInfo+ , size_t n+ , void *eventPaths+ , const FSEventStreamEventFlags eventFlags[]+ , const FSEventStreamEventId eventIds[]+ )+{+ int i;+ struct watch *w = clientCallBackInfo;+ char **paths = eventPaths;++ for (i = 0; i < n; i++) {+ writeEvent(w->writefd, eventIds[i], eventFlags[i], paths[i]);+ }+}++#define MAX_WATCH_PATHS 4096++static void free_cffolders(CFStringRef *cffolders, int n) {+ int i;+ for (i = 0; i < n; i++) {+ CFRelease (cffolders[i]);+ }+ free(cffolders);+}++int createWatch+ ( struct pathName* folders+ , int n /* number of entries in folders */+ , UInt32 createFlags+ , UInt64 since+ , double latency+ , int* fd+ , void** wp+ )+{+ if (n > MAX_WATCH_PATHS) {+ return -1;+ }++ int pfds[2];+ if (pipe (pfds)) {+ return -1;+ }++ /*+ * XXX We can possibly use since == 0 to get all events since+ * beginning of time+ */+ if (!since) {+ since = kFSEventStreamEventIdSinceNow;+ }++ struct watch *w = malloc(sizeof(struct watch));+ if (!w) {+ goto cleanup_pipe;+ }++ /* Setup paths array */+ CFStringRef *cffolders = malloc(n * sizeof(CFStringRef));+ if (!cffolders) {+ goto cleanup_watch;+ }++ /* Create event stream using paths and context*/+ int i;+ for(i = 0; i < n; i++) {+ cffolders[i] = CFStringCreateWithBytes+ ( NULL+ , folders[i].pathBytes+ , folders[i].pathLen+ , kCFStringEncodingUTF8+ , false+ );+ if (!cffolders[i]) {+ free_cffolders(cffolders, i);+ goto cleanup_watch;+ }+ }+ CFArrayRef paths = CFArrayCreate(NULL, (const void **)cffolders, n, NULL);+ if (!paths) {+ free_cffolders(cffolders, n);+ goto cleanup_watch;+ }++ FSEventStreamContext ctx;+ ctx.version = 0;+ ctx.info = (void*)w;+ ctx.retain = NULL;+ ctx.release = NULL;+ ctx.copyDescription = NULL;++ w->eventStream = FSEventStreamCreate+ (NULL, &watchCallback, &ctx, paths, since, latency, createFlags);+ free_cffolders(cffolders, n);+ CFRelease(paths);++ if(w->eventStream == NULL) {+ goto cleanup_watch;+ }++ w->queue = dispatch_queue_create("com.composewell.streamly", NULL);+ if (!w->queue) {+ goto cleanup_es;+ }++ w->writefd = pfds[1];+ *fd = pfds[0];+ *wp = w;+ FSEventStreamSetDispatchQueue(w->eventStream, w->queue);+ FSEventStreamStart(w->eventStream);+ return 0;++cleanup_es:+ FSEventStreamRelease(w->eventStream);+cleanup_watch:+ free(w);+cleanup_pipe:+ close(pfds[0]);+ close(pfds[1]);+ return -1;+}++/******************************************************************************+ * Stop a watch event loop+ *****************************************************************************/++void destroyWatch(struct watch* w) {+ /* Stop and invalidate the event stream */+ FSEventStreamFlushSync(w->eventStream);+ FSEventStreamStop(w->eventStream);+ FSEventStreamInvalidate(w->eventStream);+ dispatch_release(w->queue);+ FSEventStreamRelease(w->eventStream);+ close(w->writefd);+ free(w);+}+#endif
+ src/Streamly/Internal/FS/Event/Darwin.h view
@@ -0,0 +1,63 @@+#include <config.h>++struct watch;++struct pathName {+ const UInt8 *pathBytes;+ size_t pathLen;+};++int createWatch+ ( struct pathName* folders+ , int n /* number of entries in "folders" */+ , UInt32 createFlags+ , UInt64 since+ , double latency+ , int* fd+ , void** wp+ );++void destroyWatch(struct watch* w);++/******************************************************************************+ * Create Flags+ *****************************************************************************/++UInt32 FSEventStreamCreateFlagNoDefer ();+UInt32 FSEventStreamCreateFlagWatchRoot ();+UInt32 FSEventStreamCreateFlagFileEvents ();+UInt32 FSEventStreamCreateFlagIgnoreSelf ();+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY+UInt32 FSEventStreamCreateFlagFullHistory;+#endif++/******************************************************************************+ * Event Flags+ *****************************************************************************/++UInt32 FSEventStreamEventFlagEventIdsWrapped ();+UInt32 FSEventStreamEventFlagMustScanSubDirs ();+UInt32 FSEventStreamEventFlagKernelDropped ();+UInt32 FSEventStreamEventFlagUserDropped ();+UInt32 FSEventStreamEventFlagHistoryDone ();+UInt32 FSEventStreamEventFlagRootChanged ();+UInt32 FSEventStreamEventFlagMount ();+UInt32 FSEventStreamEventFlagUnmount ();+UInt32 FSEventStreamEventFlagItemChangeOwner ();+UInt32 FSEventStreamEventFlagItemInodeMetaMod ();+UInt32 FSEventStreamEventFlagItemFinderInfoMod ();+UInt32 FSEventStreamEventFlagItemXattrMod ();+UInt32 FSEventStreamEventFlagItemCreated ();+UInt32 FSEventStreamEventFlagItemRemoved ();+UInt32 FSEventStreamEventFlagItemRenamed ();+UInt32 FSEventStreamEventFlagItemModified ();+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED+UInt32 FSEventStreamEventFlagItemCloned ();+#endif+UInt32 FSEventStreamEventFlagItemIsDir ();+UInt32 FSEventStreamEventFlagItemIsFile ();+UInt32 FSEventStreamEventFlagItemIsSymlink ();+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK+UInt32 FSEventStreamEventFlagItemIsHardlink ();+#endif+UInt32 FSEventStreamEventFlagItemIsLastHardlink ();
+ src/Streamly/Internal/FS/Event/Darwin.hs view
@@ -0,0 +1,1111 @@+-- |+-- Module : Streamly.Internal.FS.Event.Darwin+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : pre-release+-- Portability : GHC+--+-- =Overview+--+-- Use 'watchRecursive' with a list of file system paths you want to watch as+-- argument. It returns a stream of 'Event' representing the file system events+-- occurring under the watched paths.+--+-- @+-- {-\# LANGUAGE MagicHash #-}+-- Stream.mapM_ (putStrLn . 'showEvent') $ 'watchRecursive' [Path.fromString "path"]+-- @+--+-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)+-- provided in this module are used to determine the attributes of the event.+--+-- =Design notes+--+-- For reference documentation see:+--+-- * "<https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/FSEvents_ProgGuide/UsingtheFSEventsFramework/UsingtheFSEventsFramework.html Apple FS Events Programming Guide>"+-- * "<https://developer.apple.com/documentation/coreservices/file_system_events?language=objc Apple FS Events Reference>"+--+-- We try to keep the macOS\/Linux/Windows event handling APIs and defaults+-- semantically and syntactically as close as possible.+--+-- =BUGS+--+-- XXX Check the behavior for Windows/Linux where applicable. Mention these in+-- the common module so that users are aware of the portability issues.+--+-- There may be some idiosyncrasies in event reporting.+--+-- 1. Multiple events may be coalesced into a single event having multiple+-- flags set. For example, on macOS 10.15.6, "touch x; rm x" or "touch x; mv x+-- y" produces an event with both "Created" and "Deleted/Moved" flags set.+--+-- 2. The same event can occur multiple times. For example, "touch x; sleep 1;+-- rm x" generates a "Created" event followed by an event with both "Created"+-- and "Deleted" flags set. Similarly, a cloned event can also occur multiple+-- times.+--+-- 3. Some events can go missing and only the latest one is reported. See+-- 'isCreated' for one such case.+--+-- XXX write a test case for this, and check on all platforms.+--+-- 4. When @rm -rf@ is used on the watched root directory, only one 'isDeleted'+-- event occurs and that is for the root. However, @rm -rf@ on a directory+-- inside the watch root produces 'isDeleted' events for all files.+--+-- XXX write a test case for this, and check on all platforms.+--+-- 5. When a file is moved, a move event occurs for both the source and the+-- destination files. There seems to be no way to distinguish the source and+-- the destination. Perhaps the lower eventId can be considered as source.+--+-- XXX cloned event is specific to macOS. Translate it to the same events as+-- on copying.+--+-- 6. When a file is cloned both source and destination generate a cloned+-- event, however the source has lower eventId and destination may have+-- OwnerGroupModeChanged, InodeAttrsChanged, Created flags as well.+--+-- You may have to stat the path of the event to know more information about+-- what might have happened. It may be a good idea to watch the behavior of+-- events you are handling before you can rely on it. See the individual event+-- APIs for some of the known issues marked with `BUGS`. Also see the "Handling+-- Events" section in the "Apple FS Events Programming Guide".+--+-- * "<https://stackoverflow.com/questions/18415285/osx-fseventstreameventflags-not-working-correctly Stack overflow question on event coalescing>"+--+-- =TODO+--+-- APIs for persistent event-id related functionality, to get events from+-- specific event-id etc are not implemented.++#include <config.h>++-- macOS 10.7++#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS++module Streamly.Internal.FS.Event.Darwin+ (+ -- * Creating a Watch++ -- ** Default configuration+ Config (..)+ , defaultConfig++ -- ** Watch Behavior+ , BatchInfo (..)+ , setEventBatching++ -- ** Events of Interest+ , setRootPathEvents+ , setFileEvents+ , setIgnoreSelf+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY+ , setFullHistory+#endif+ , setAllEvents++ -- ** Watch APIs+ , watch+ , watchRecursive+ , watchWith++ -- * Handling Events+ , Event+ , getEventId+ , getAbsPath++ -- ** Root Level Events+ -- | Events that belong to the root path as a whole and not to specific+ -- items contained in it.+ , isMounted+ , isUnmounted+ , isHistoryDone+ , isRootPathEvent++ -- ** Item Level Metadata change+ , isAttrsModified+ , isSecurityModified+ , isXAttrsModified+ , isFinderInfoModified++ -- ** Item Level CRUD events+ , isCreated+ , isDeleted+ , isMoved+ , isModified+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED+ , isCloned+#endif++ -- ** Item Path info+ , isDir+ , isFile+ , isSymLink+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK+ , isHardLink+ , isLastHardLink+#endif++ -- ** Exception Conditions+ , isEventIdWrapped+ , isEventsLost+ , isKernelDropped+ , isUserDropped++ -- * Debugging+ , showEvent+ )+where++import Control.Concurrent (MVar, newMVar, takeMVar, putMVar)+import Control.Monad (when)+import Control.Monad.Cont (runCont, cont)+import Data.Bits ((.|.), (.&.), complement)+import Data.List.NonEmpty (NonEmpty)+import Data.Word (Word8, Word32, Word64)+import Foreign.C.Types (CInt(..), CDouble(..), CSize(..), CUChar(..))+import Foreign.Marshal.Alloc (alloca)+import Foreign.Marshal.Array (withArray)+import Foreign.Ptr (Ptr, castPtr)+import Foreign.Storable (Storable(..))+import GHC.IO.Handle.FD (fdToHandle)+import Streamly.Internal.Data.Stream (Stream)+import Streamly.Internal.Data.Parser (Parser)+import Streamly.Internal.Data.Array (Array(..))+import Streamly.Internal.FileSystem.Path (Path)+import System.IO (Handle, hClose)++import qualified Data.List.NonEmpty as NonEmpty+import qualified Streamly.Internal.Data.Parser as PR+import qualified Streamly.Internal.Data.Stream as S+import qualified Streamly.Internal.FileSystem.Handle as FH+import qualified Streamly.Internal.Data.Array as A+import qualified Streamly.Internal.FileSystem.Path as Path++-------------------------------------------------------------------------------+-- Utils+-------------------------------------------------------------------------------++-- NOTE: "contListMap" is part of the unexposed module:+-- Streamly.Internal.Data.Cont++-- | Given a continuation based transformation from @a@ to @b@ and a+-- continuation based transformation from @[b]@ to @c@, make continuation based+-- transformation from @[a]@ to @c@.+--+-- /Pre-release/++-- You can read the definition as:+--+-- > contListMap f g = \xs final ->+--+contListMap ::+ (a -> (b -> r) -> r) -- transform a -> b+ -> ([b] -> (c -> r) -> r) -- transform [b] -> c+ -> ([a] -> (c -> r) -> r) -- transform [a] -> c+contListMap f g xs final =+ let bconts = fmap (cont . f) xs -- [Cont b]+ blistCont = sequence bconts -- Cont [b]+ k ys = g ys final -- [b] -> r+ in runCont blistCont k -- r++-------------------------------------------------------------------------------+-- Subscription to events+-------------------------------------------------------------------------------++-- XXX Add a recursive option to Config+-- Keep setRecursiveMode False as undefined for now until we implement it.+--+-- | Watch configuration, used to specify the events of interest and the+-- behavior of the watch.+--+-- /Pre-release/+--+data Config = Config+ { latency :: Double+ , createFlags :: Word32+ }++-------------------------------------------------------------------------------+-- Batching Events+-------------------------------------------------------------------------------++foreign import ccall safe+ "FS/Event/Darwin.h FSEventStreamCreateFlagNoDefer"+ kFSEventStreamCreateFlagNoDefer :: Word32++-- | Determines how multiple events are batched or throttled.+data BatchInfo =+ Throttle Double -- ^ Deliver an event immediately but suppress the+ -- following events upto the specified time.+ | Batch Double -- ^ Collapse all events that occurred in the specified+ -- time window (in seconds) and deliver them as a single+ -- batch.++-- | Set how the events should be batched. See 'BatchInfo' for details. A+-- negative value for time is treated as 0.+--+-- /default: Batch 0.0/+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+setEventBatching :: BatchInfo -> Config -> Config+setEventBatching batchInfo cfg =+ let (t, status) =+ case batchInfo of+ Throttle sec | sec < 0 -> (0, True)+ Throttle sec -> (sec, True)+ Batch sec | sec < 0 -> (0, False)+ Batch sec -> (sec, False)+ in setFlag kFSEventStreamCreateFlagNoDefer status $ cfg {latency = t}++-------------------------------------------------------------------------------+-- Boolean settings+-------------------------------------------------------------------------------++setFlag :: Word32 -> Bool -> Config -> Config+setFlag mask status cfg@Config{..} =+ let flags =+ if status+ then createFlags .|. mask+ else createFlags .&. complement mask+ in cfg {createFlags = flags}++foreign import ccall safe+ "FSEventStreamCreateFlagWatchRoot"+ kFSEventStreamCreateFlagWatchRoot :: Word32++-- XXX write a test case for this, and check on all platforms. The behavior on+-- macOS is slightly different as a create event is also generated.+--+-- | Any changes to the path (delete, rename, or create) of an object are+-- reported as events for its parent directory. Such events are not reported+-- for the watch root itself because its parent is not being watched. When+-- 'setRootPathEvents' is 'True', an 'isRootPathEvent' event is generated with an+-- eventId 0 if the watch root is deleted, renamed or created.+--+-- Note: We have observed that an 'isDeleted' event occurs for the root path+-- (when it is a regular dir and not symlink) even when this option is off.+--+-- /default: False/+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+setRootPathEvents :: Bool -> Config -> Config+setRootPathEvents = setFlag kFSEventStreamCreateFlagWatchRoot++foreign import ccall safe+ "FSEventStreamCreateFlagFileEvents"+ kFSEventStreamCreateFlagFileEvents :: Word32++-- | When this is 'False' only events for the watched directories are reported.+-- For example, when a file is created inside a directory it is reported as an+-- event, the path name in the event is the path of the directory being watched+-- and not of the specific item for which the event occurred. Events cannot be+-- distinguished based on the type of event. For example, we cannot determine+-- if an event is a "create" or "delete", we only know that some event ocurred+-- under the watched directory hierarchy.+--+-- When it is 'True' the path reported in the event is the path of the item and+-- not the of the directory in which it is contained. We can use the event+-- accessor functions to determine the event type and the path type etc.+--+-- /default: True/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+setFileEvents :: Bool -> Config -> Config+setFileEvents = setFlag kFSEventStreamCreateFlagFileEvents++foreign import ccall safe+ "FSEventStreamCreateFlagIgnoreSelf"+ kFSEventStreamCreateFlagIgnoreSelf :: Word32++-- | When this is 'True' events generated by the current process are not+-- reported.+--+-- /default: False/+--+-- /macOS 10.6+/+--+-- /Pre-release/+--+setIgnoreSelf :: Bool -> Config -> Config+setIgnoreSelf = setFlag kFSEventStreamCreateFlagIgnoreSelf++#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY+foreign import ccall safe+ "FSEventStreamCreateFlagFullHistory"+ kFSEventStreamCreateFlagFullHistory :: Word32++-- | When this is 'True' all events since the beginning of time are reported.+--+-- /default: False/+--+-- /macOS 10.15+/+--+-- /Pre-release/+--+setFullHistory :: Bool -> Config -> Config+setFullHistory = setFlag kFSEventStreamCreateFlagFullHistory+#endif++-- | Set all tunable events 'True' or 'False'. Equivalent to setting:+--+-- * setRootPathEvents+-- * setFileEvents+--+-- /Pre-release/+--+setAllEvents :: Bool -> Config -> Config+setAllEvents s =+ setRootPathEvents s+ . setFileEvents s++-------------------------------------------------------------------------------+-- Default config+-------------------------------------------------------------------------------++-- | The default settings are:+--+-- * 'setEventBatching' ('Batch' 0.0)+-- * 'setFileEvents' 'True'+-- * 'setRootPathEvents' 'False'+-- * 'setIgnoreSelf' 'False'+#if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY+-- * 'setFullHistory' 'False'+#endif+--+-- /Pre-release/+--+defaultConfig :: Config+defaultConfig = setFileEvents True $ Config+ { latency = 0.0+ , createFlags = 0+ }++-------------------------------------------------------------------------------+-- Open an event stream (C FFI)+-------------------------------------------------------------------------------++-- See FS/Event/Darwin.h++data CWatch++-- Representation of "struct pathName" in "FS/Event/Darwin.h"+data PathName = PathName+ { pathBytes :: Ptr CUChar+ , pathLen :: CSize+ }++instance Storable PathName where+ alignment _ = sizeOf (undefined :: Ptr a)+ sizeOf _ = sizeOf (undefined :: Ptr CUChar) + sizeOf (undefined :: CSize)+ peek ptr = do+ bptr <- peekByteOff ptr 0+ len <- peekByteOff ptr (sizeOf (undefined :: Ptr CUChar))+ return $ PathName bptr len+ poke ptr PathName{..} = do+ pokeByteOff ptr 0 pathBytes+ pokeByteOff ptr (sizeOf (undefined :: Ptr CUChar)) pathLen++foreign import ccall safe "FS/Event/Darwin.h createWatch" createWatch+ :: Ptr PathName+ -> CInt+ -> Word32+ -> Word64+ -> CDouble+ -> Ptr CInt+ -> Ptr (Ptr CWatch)+ -> IO CInt++foreign import ccall safe "FS/Event/Darwin.h destroyWatch" destroyWatch+ :: Ptr CWatch -> IO ()++-------------------------------------------------------------------------------+-- Open an event stream+-------------------------------------------------------------------------------++-- | A handle for a watch.+data Watch = Watch Handle (Ptr CWatch) (MVar Bool)++-- | Given a 'Config' and @paths@ start monitoring the paths for file system+-- events. Returns a 'Watch' handle which can then be used to read the event+-- stream or to close the watch.+--+-- Implementation Note: This API creates an OS level thread where an event loop+-- runs and writes the events to the write side fd of a POSIX pipe. Event+-- stream APIs read the events from the read end of this pipe. Since an OS+-- level thread is forked, creating a new watch stream is expensive. It is+-- advised to minimize the number of watches.+--+-- /Pre-release/+--+openWatch :: Config -> NonEmpty Path -> IO Watch+openWatch Config{..} paths = do+ -- XXX write a test case when path does not exist+ -- XXX write a test case when there are no permissions+ -- XXX check whether the path exists. If the path does not exist and+ -- is created later it cannot be properly monitored. Also a user may+ -- inadvertently provide a path for which the user may not have permission+ -- and then later wonder why events are not being reported.+ withPathNames (NonEmpty.toList paths) $ \arraysPtr ->+ alloca $ \fdPtr -> do+ alloca $ \watchPPtr -> do+ let nArrays = fromIntegral (NonEmpty.length paths)+ seconds = realToFrac latency+ r <- createWatch+ arraysPtr nArrays createFlags 0 seconds fdPtr watchPPtr+ when (r /= 0) $+ ioError (userError "openWatch: failed to create watch.")+ fd <- peek fdPtr+ h <- fdToHandle fd+ watchPtr <- peek watchPPtr+ closeLock <- newMVar False+ return $ Watch h watchPtr closeLock++ where++ withPathName :: Path -> (PathName -> IO a) -> IO a+ withPathName path act = do+ A.unsafePinnedAsPtr (Path.toArray path) $ \ptr byteLen ->+ let pname = PathName (castPtr ptr) (fromIntegral byteLen)+ in act pname++ withPathNames = contListMap withPathName withArray++-- | Close a 'Watch' handle.+--+-- /Pre-release/+--+closeWatch :: Watch -> IO ()+closeWatch (Watch h watchPtr mvar) = do+ hClose h+ closed <- takeMVar mvar+ when (not closed) $ destroyWatch watchPtr+ putMVar mvar True++-------------------------------------------------------------------------------+-- Raw events read from the watch file handle+-------------------------------------------------------------------------------++-- | An Event generated by the file system. Use the accessor functions to+-- examine the event.+--+-- /Pre-release/+--+data Event = Event+ { eventId :: Word64+ , eventFlags :: Word32+ , eventAbsPath :: Path+ }++-- XXX We can perhaps use parseD monad instance for fusing with parseMany? Need+-- to measure the perf.+--+-- XXX should we use a magic in the header to avoid any issues due to+-- misalignment of records? Can that ever happen?+--+readOneEvent :: Parser Word8 IO Event+readOneEvent = do+ arr <- PR.takeEQ 24 (A.createOf 24)+ let arr1 = A.unsafeCast arr :: Array Word64+ eid = A.unsafeGetIndex 0 arr1+ eflags = A.unsafeGetIndex 1 arr1+ pathLen = fromIntegral $ A.unsafeGetIndex 2 arr1+ path <- PR.takeEQ pathLen (A.createOf pathLen)+ return $ Event+ { eventId = eid+ , eventFlags = fromIntegral eflags+ , eventAbsPath = Path.unsafeFromArray path+ }++watchToStream :: Watch -> Stream IO Event+watchToStream (Watch handle _ _) =+ S.catRights $ S.parseMany readOneEvent $ S.unfold FH.reader handle++-- XXX Write tests for all the points in macOS specific behavior.+--+-- | Start monitoring a list of file system paths for file system events with+-- the supplied configuration operation over the 'defaultConfig'. The paths+-- could be files or directories. When the path is a directory and recursive+-- mode is set, the whole directory tree under it is watched recursively.+-- Monitoring starts from the current time onwards.+--+-- Important notes for macOS specific behavior:+--+-- From the observed behavior it seems macOS watches the paths, whatever they+-- are pointing to at any given point of time:+--+-- /Watch root deletion:/ If the the watch root is deleted and then recreated,+-- the newly created file or directory is automatically watched.+--+-- /Watch root moved:/ If the watch root is moved to a new path, the object+-- will no longer be watched unless the new path is also being watched and was+-- pointing to an existing file at the time of starting the watch (see notes+-- about non-existing paths below).+--+-- /Symbolic link watch root:/ If the path name to be watched is a symbolic+-- link then the target of the link is watched instead of the symbolic link+-- itself. It is equivalent to as if the target of the symbolic link itself was+-- directly added to the watch API. That is, the symbolic link is resolved at+-- the time of adding the watch.+--+-- Note that if a watched path is deleted and recreated as a symbolic link+-- pointing to another path then the symbolic link file itself is watched, it+-- won't be resolved. The symbolic link resolution happens only at the time of+-- adding the watch.+--+-- /Non-existing Paths:/ If a watch is started on a non-existing path then the+-- path is not watched even if it is created later. The macOS API does not+-- fail for a non-existing path.+--+-- If a non-existing path is watched with 'setRootPathEvents' then an+-- 'isRootPathEvent' event is reported if the path is created later and the+-- "path" field in the event is set to the dirname of the path rather than the+-- full absolute path. This is the observed behavior on macOS 10.15.1.+--+-- @+-- {-\# LANGUAGE MagicHash #-}+-- watchWith+-- ('setIgnoreSelf' 'True' . 'setRootPathEvents' 'True')+-- [Path.fromString "path"]+-- @+--+-- /Pre-release/+--+watchWith ::+ (Config -> Config) -> NonEmpty Path -> Stream IO Event+watchWith f paths = S.bracketIO before after watchToStream++ where++ before = openWatch (f defaultConfig) paths+ after = closeWatch++-- | Same as 'watchWith' using 'defaultConfig' and recursive mode.+--+-- >>> watchRecursive = watchWith id+--+watchRecursive :: NonEmpty Path -> Stream IO Event+watchRecursive = watchWith id++-- | Same as 'watchWith' using defaultConfig and non-recursive mode.+--+-- /Unimplemented/+--+watch :: NonEmpty Path -> Stream IO Event+watch _paths = undefined++-------------------------------------------------------------------------------+-- Examine the event stream+-------------------------------------------------------------------------------++-- | Get the event id of an 'Event'. Event-id is a monotonically increasing+-- 64-bit integer identifying an event uniquely.+--+-- /Pre-release/+--+getEventId :: Event -> Word64+getEventId Event{..} = eventId++foreign import ccall safe+ "FSEventStreamEventFlagEventIdsWrapped"+ kFSEventStreamEventFlagEventIdsWrapped :: Word32++-- | Determine whether the event id has wrapped. This is impossible on any+-- traditional hardware in any reasonable amount of time unless the event-id+-- starts from a very high value, because the event-id is a 64-bit integer.+-- However, apple still recommends to check and handle this flag.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isEventIdWrapped :: Event -> Bool+isEventIdWrapped = getFlag kFSEventStreamEventFlagEventIdsWrapped++-- | Get the absolute path of the file system object for which the event is+-- generated. The path is a UTF-8 encoded array of bytes.+--+-- When the watch root is a symlink, the absolute path returned is via the real+-- path of the root after resolving the symlink.+--+-- /Pre-release/+--+getAbsPath :: Event -> Path+getAbsPath Event{..} = eventAbsPath++-------------------------------------------------------------------------------+-- Event types+-------------------------------------------------------------------------------++getFlag :: Word32 -> Event -> Bool+getFlag mask Event{..} = eventFlags .&. mask /= 0++-------------------------------------------------------------------------------+-- Error events+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagMustScanSubDirs"+ kFSEventStreamEventFlagMustScanSubDirs :: Word32++-- | Apple documentation says that "If an event in a directory occurs at about+-- the same time as one or more events in a subdirectory of that directory, the+-- events may be coalesced into a single event." In that case you will recieve+-- 'isEventsLost' event. In that case the path listed in the event is+-- invalidated and you must rescan it to know the current state.+--+-- This event can also occur if a communication error (overflow) occurs in+-- sending the event and the event gets dropped. In that case 'isKernelDropped'+-- and/or 'isUserDropped' attributes will also be set.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isEventsLost :: Event -> Bool+isEventsLost = getFlag kFSEventStreamEventFlagMustScanSubDirs++foreign import ccall safe+ "FSEventStreamEventFlagKernelDropped"+ kFSEventStreamEventFlagKernelDropped :: Word32++-- | Did an event get dropped due to a kernel processing issue? Set only when+-- 'isEventsLost' is also true.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isKernelDropped :: Event -> Bool+isKernelDropped = getFlag kFSEventStreamEventFlagKernelDropped++foreign import ccall safe+ "FSEventStreamEventFlagUserDropped"+ kFSEventStreamEventFlagUserDropped :: Word32++-- | Did an event get dropped due to a user process issue? Set only when+-- 'isEventsLost' is also true.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isUserDropped :: Event -> Bool+isUserDropped = getFlag kFSEventStreamEventFlagUserDropped++-------------------------------------------------------------------------------+-- Global Sentinel Events+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagHistoryDone"+ kFSEventStreamEventFlagHistoryDone :: Word32++-- | Determine whether the event is a history done marker event. A history done+-- event is generated when the historical events from before the current time+-- are done. Historical events are generated when the "since" parameter in the+-- watch config is set to before the current time.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isHistoryDone :: Event -> Bool+isHistoryDone = getFlag kFSEventStreamEventFlagHistoryDone++-------------------------------------------------------------------------------+-- Events affecting the watched path only+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagRootChanged"+ kFSEventStreamEventFlagRootChanged :: Word32++-- | Determine whether the event indicates a change of path of the monitored+-- object itself. Note that the object may become unreachable or deleted after+-- a change of path.+--+-- /Applicable only when 'setRootPathEvents' is 'True'/+--+-- /Occurs only for the watched path/+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isRootPathEvent :: Event -> Bool+isRootPathEvent = getFlag kFSEventStreamEventFlagRootChanged++-------------------------------------------------------------------------------+-- Global events under the watched path+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagMount"+ kFSEventStreamEventFlagMount :: Word32++-- | Determine whether the event is a mount event. A mount event is generated+-- if a volume is mounted under the path being watched.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isMounted :: Event -> Bool+isMounted = getFlag kFSEventStreamEventFlagMount++foreign import ccall safe+ "FSEventStreamEventFlagUnmount"+ kFSEventStreamEventFlagUnmount :: Word32++-- | Determine whether the event is an unmount event. An unmount event is+-- generated if a volume mounted under the path being watched is unmounted.+--+-- /macOS 10.5+/+--+-- /Pre-release/+--+isUnmounted :: Event -> Bool+isUnmounted = getFlag kFSEventStreamEventFlagUnmount++-------------------------------------------------------------------------------+-- Metadata change Events (applicable only when 'setFileEvents' is 'True')+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagItemChangeOwner"+ kFSEventStreamEventFlagItemChangeOwner :: Word32++-- | Determine whether the event is ownership, group, permissions or ACL change+-- event of an object contained within the monitored path.+--+-- Note that this event may be generated even if the metadata is changed to the+-- same value again.+--+-- /Applicable only when 'setFileEvents' is 'True'/+--+-- /Can occur for watched path or a file inside it/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isSecurityModified :: Event -> Bool+isSecurityModified = getFlag kFSEventStreamEventFlagItemChangeOwner++foreign import ccall safe+ "FSEventStreamEventFlagItemInodeMetaMod"+ kFSEventStreamEventFlagItemInodeMetaMod :: Word32++-- | Determine whether the event indicates inode metadata change for an object+-- contained within the monitored path. This event is generated when inode+-- attributes other than the owner, group or permissions are changed e.g. file+-- modification time. It does not occur when the link count of a file changes+-- (as of macOS 10.15.1).+--+-- /Applicable only when 'setFileEvents' is 'True'/+--+-- /Can occur for watched path or a file inside it/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isAttrsModified :: Event -> Bool+isAttrsModified = getFlag kFSEventStreamEventFlagItemInodeMetaMod++foreign import ccall safe+ "FSEventStreamEventFlagItemFinderInfoMod"+ kFSEventStreamEventFlagItemFinderInfoMod :: Word32++-- | Determine whether the event indicates finder information metadata change+-- for an object contained within the monitored path.+--+-- /Applicable only when 'setFileEvents' is 'True'/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isFinderInfoModified :: Event -> Bool+isFinderInfoModified = getFlag kFSEventStreamEventFlagItemFinderInfoMod++foreign import ccall safe+ "FSEventStreamEventFlagItemXattrMod"+ kFSEventStreamEventFlagItemXattrMod :: Word32++-- | Determine whether the event indicates extended attributes metadata change+-- for an object contained within the monitored path.+--+-- /Applicable only when 'setFileEvents' is 'True'/+--+-- /Can occur for watched path or a file inside it/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isXAttrsModified :: Event -> Bool+isXAttrsModified = getFlag kFSEventStreamEventFlagItemXattrMod++-------------------------------------------------------------------------------+-- CRUD Events (applicable only when 'setFileEvents' is 'True')+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagItemCreated"+ kFSEventStreamEventFlagItemCreated :: Word32++-- | Determine whether the event indicates creation of an object within the+-- monitored path. This event is generated when any file system object other+-- than a hard link is created. On hard linking only an 'isAttrsModified'+-- event on the directory is generated, it is not a create event. However, when+-- a hard link is deleted 'isDeleted' and 'isHardLink' both are true.+--+-- This event can occur for the watched path if the path was deleted/moved and+-- created again (tested on macOS 10.15.1). However, if a watch is started on a+-- non-existing path and the path is created later, then this event is not+-- generated, the path is not watched.+--+-- BUGS: On 10.15.1 when we use a "touch x" to create a file for the first time+-- only an 'isAttrsModified' event occurs and there is no 'isCreated'+-- event. However, this seems to have been fixed on 10.15.6.+--+-- /Applicable only when 'setFileEvents' is 'True'/+--+-- /Can occur for watched path or a file inside it/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isCreated :: Event -> Bool+isCreated = getFlag kFSEventStreamEventFlagItemCreated++foreign import ccall safe+ "FSEventStreamEventFlagItemRemoved"+ kFSEventStreamEventFlagItemRemoved :: Word32++-- | Determine whether the event indicates deletion of an object within the+-- monitored path. This is true when a file or a hardlink is deleted.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /Can occur for watched path or a file inside it/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isDeleted :: Event -> Bool+isDeleted = getFlag kFSEventStreamEventFlagItemRemoved++foreign import ccall safe+ "FSEventStreamEventFlagItemRenamed"+ kFSEventStreamEventFlagItemRenamed :: Word32++-- | Determine whether the event indicates rename of an object within the+-- monitored path. This event is generated when a file is renamed within the+-- watched directory or if it is moved out of or in the watched directory.+--+-- /Applicable only when 'setFileEvents' is 'True'/+--+-- /Can occur for watched path or a file inside it/+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isMoved :: Event -> Bool+isMoved = getFlag kFSEventStreamEventFlagItemRenamed++foreign import ccall safe+ "FSEventStreamEventFlagItemModified"+ kFSEventStreamEventFlagItemModified :: Word32++-- | Determine whether the event indicates modification of an object within the+-- monitored path. This event is generated only for files and not directories.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isModified :: Event -> Bool+isModified = getFlag kFSEventStreamEventFlagItemModified++#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED+foreign import ccall safe+ "FSEventStreamEventFlagItemCloned"+ kFSEventStreamEventFlagItemCloned :: Word32++-- | Determine whether the event indicates cloning of an object within the+-- monitored path. The "Duplicate" command in the "File" menu of the "Finder"+-- application generates a "clone" event.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.13+/+--+-- /Pre-release/+--+isCloned :: Event -> Bool+isCloned = getFlag kFSEventStreamEventFlagItemCloned+#endif++-------------------------------------------------------------------------------+-- Information about path type (applicable only when 'setFileEvents' is 'True')+-------------------------------------------------------------------------------++foreign import ccall safe+ "FSEventStreamEventFlagItemIsDir"+ kFSEventStreamEventFlagItemIsDir :: Word32++-- | Determine whether the event is for a directory path.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isDir :: Event -> Bool+isDir = getFlag kFSEventStreamEventFlagItemIsDir++foreign import ccall safe+ "FSEventStreamEventFlagItemIsFile"+ kFSEventStreamEventFlagItemIsFile :: Word32++-- | Determine whether the event is for a file path.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isFile :: Event -> Bool+isFile = getFlag kFSEventStreamEventFlagItemIsFile++foreign import ccall safe+ "FSEventStreamEventFlagItemIsSymlink"+ kFSEventStreamEventFlagItemIsSymlink :: Word32++-- | Determine whether the event is for a symbolic link path.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.7+/+--+-- /Pre-release/+--+isSymLink :: Event -> Bool+isSymLink = getFlag kFSEventStreamEventFlagItemIsSymlink++#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK+foreign import ccall safe+ "FSEventStreamEventFlagItemIsHardlink"+ kFSEventStreamEventFlagItemIsHardlink :: Word32++-- | Determine whether the event is for a file with more than one hard link.+-- When 'isFile' is true we can check for 'isHardLink'. Note that 'isHardLink'+-- is not true when a hard link is created, however, it is true when a file+-- which has or had more than one link in the past is removed. This is not true+-- if a file never had more than one link.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.10+/+--+-- /Pre-release/+--+isHardLink :: Event -> Bool+isHardLink = getFlag kFSEventStreamEventFlagItemIsHardlink++foreign import ccall safe+ "FSEventStreamEventFlagItemIsLastHardlink"+ kFSEventStreamEventFlagItemIsLastHardlink :: Word32++-- | Determine whether the event is for a hard link path with only one hard+-- link. If 'isHardLink' is true then we can check for 'isLastHardLink'. This+-- is true when a file has had more than one link and now the last link is+-- removed. In that case both 'isHardLink' and 'isLastHardLink" would be true.+--+-- Applicable only when 'setFileEvents' is 'True'.+--+-- /macOS 10.10+/+--+-- /Pre-release/+--+isLastHardLink :: Event -> Bool+isLastHardLink = getFlag kFSEventStreamEventFlagItemIsLastHardlink+#endif++-------------------------------------------------------------------------------+-- Debugging+-------------------------------------------------------------------------------++-- | Convert an 'Event' record to a String representation.+showEvent :: Event -> String+showEvent ev@Event{..} =+ let path = Path.toString eventAbsPath+ in "--------------------------"+ ++ "\nId = " ++ show eventId+ ++ "\nPath = " ++ show path+ ++ "\nFlags " ++ show eventFlags++ ++ showev isEventsLost "MustScanSubdirs"+ ++ showev isKernelDropped "KernelDropped"+ ++ showev isUserDropped "UserDropped"++ ++ showev isRootPathEvent "RootPathEvent"+ ++ showev isMounted "Mounted"+ ++ showev isUnmounted "Unmounted"+ ++ showev isHistoryDone "HistoryDone"++ ++ showev isSecurityModified "SecurityModified"+ ++ showev isAttrsModified "AttrsModified"+ ++ showev isFinderInfoModified "FinderInfoChanged"+ ++ showev isXAttrsModified "XAttrsModified"++ ++ showev isCreated "Created"+ ++ showev isDeleted "Deleted"+ ++ showev isModified "Modified"+ ++ showev isMoved "Moved"+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED+ ++ showev isCloned "Cloned"+#endif++ ++ showev isDir "Dir"+ ++ showev isFile "File"+ ++ showev isSymLink "SymLink"+#if HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK+ ++ showev isHardLink "HardLink"+ ++ showev isLastHardLink "LastHardLink"+#endif+ ++ "\n"++ where showev f str = if f ev then "\n" ++ str else ""+#else+module Streamly.Internal.FS.Event.Darwin () where+#warning "Autoconf did not find the definition \+kFSEventStreamCreateFlagFileEvents in Darwin header files.\+Do you have Cocoa framework header files installed?\+Not compiling the Streamly.Internal.FS.Event.Darwin module. \+Programs depending on this module may not compile. \+Check if HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS is defined in config.h \+generated from src/config.h.in"+#endif
+ src/Streamly/Internal/FS/Event/Linux.hs view
@@ -0,0 +1,1278 @@+-- |+-- Module : Streamly.Internal.FS.Event.Linux+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : experimental+-- Portability : GHC+--+-- =Overview+--+-- Use 'watchPaths' with a list of file system paths you want to watch as+-- argument. It returns a stream of 'Event' representing the file system events+-- occurring under the watched paths.+--+-- @+-- Stream.mapM_ (putStrLn . 'showEvent') $ 'watchPaths' [Path.fromString "dir"]+-- @+--+-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)+-- provided in this module are used to determine the attributes of the event.+--+-- Identical successive events may be coalesced into a single event.+--+-- =Design notes+--+-- For reference documentation see:+--+-- * <https://man7.org/linux/man-pages/man7/inotify.7.html inotify man page>+--+-- We try to keep the macOS\/Linux/Windows event handling APIs and defaults+-- semantically and syntactically as close as possible.+--+-- =BUGs+--+-- When testing on Linux Kernel version @5.3.0-53-generic #47-Ubuntu@, the last+-- event for the root path seems to be delayed until one more event occurs.+--+-- = Differences between macOS and Linux APIs:+--+-- 1. macOS watch is based on the path provided to it, if the path is+-- deleted and recreated it will still be watched, if the path moves to another+-- path it won't be watched anymore. Whereas Linux watch is based on a handle+-- to the path, if the path is deleted and recreated it won't be watched, if+-- the path moves to another it can still be watched (though this is+-- configurable).+--+-- 2. macOS watches the directory hierarchy recursively, Linux watches only one+-- level of dir, recursive watch has to be built in user space by watching for+-- create events and adding the new directories to the watch. Not sure how this+-- will scale for too many paths.+--+-- 3. In macOS the path of the subject of the event is absolute, in Linux the+-- path is the name of the object inside the dir being watched.+--+-- 4. On Linux 'watchPaths' fails if a path does not exist, on macOS it does+-- not fail.++#include "config.h"++#if HAVE_DECL_IN_EXCL_UNLINK+module Streamly.Internal.FS.Event.Linux+ (+ -- * Subscribing to events++ -- ** Default configuration+ Config (..)+ , defaultConfig++ -- ** Watch Behavior+ , setRecursiveMode+ , setFollowSymLinks+ , setUnwatchMoved+ , setOneShot+ , setOnlyDir+ , WhenExists (..)+ , setWhenExists++ -- ** Events of Interest+ -- *** Root Path Events+ , setRootDeleted+ , setRootMoved+ , setRootPathEvents++ -- *** Item Level Metadata change+ , setAttrsModified++ -- *** Item Level Access+ , setAccessed+ , setOpened+ , setWriteClosed+ , setNonWriteClosed++ -- *** Item CRUD events+ , setCreated+ , setDeleted+ , setMovedFrom+ , setMovedTo+ , setModified++ , setAllEvents++ -- ** Watch APIs+ , watch+ , watchRecursive+ , watchWith++ -- Low level watch APIs+ , addToWatch+ , removeFromWatch++ -- * Handling Events+ , Event(..)+ , getRoot+ , getRelPath+ , getAbsPath+ , getCookie++ -- ** Root Level Events+ , isRootPathEvent+ , isRootUnwatched+ , isRootDeleted+ , isRootMoved+ , isRootUnmounted++ -- ** Item Level Metadata change+ , isAttrsModified++ -- ** Item Level Access+ , isAccessed+ , isOpened+ , isWriteClosed+ , isNonWriteClosed++ -- ** Item Level CRUD events+ , isCreated+ , isDeleted+ , isMovedFrom+ , isMovedTo+ , isMoved+ , isModified++ -- ** Item Path info+ , isDir++ -- ** Exception Conditions+ , isEventsLost++ -- * Debugging+ , showEvent+ )+where++import Control.Monad (void, when)+import Data.Bits ((.|.), (.&.), complement)+import Data.Foldable (foldlM)+import Data.IntMap.Lazy (IntMap)+import Data.IORef (IORef, newIORef, readIORef, writeIORef, modifyIORef)+import Data.List.NonEmpty (NonEmpty)+#if !(MIN_VERSION_base(4,13,0))+import Data.Semigroup (Semigroup(..))+#endif+import Data.Word (Word8, Word32)+import Foreign.C.Error (throwErrnoIfMinus1)+import Foreign.C.String (CString)+import Foreign.C.Types (CInt(..), CUInt(..))+import Foreign.Ptr (Ptr)+import Foreign.Storable (peek, peekByteOff, sizeOf)+import GHC.IO.Device (IODeviceType(Stream))+import GHC.IO.FD (fdFD, FD(..))+import GHC.IO.Handle.FD (mkHandleFromFD)+import Streamly.Data.Stream (Stream)+import Streamly.Data.Parser (Parser)+import System.Directory (doesDirectoryExist)+import System.IO (Handle, hClose, IOMode(ReadMode))+import GHC.IO.Handle.FD (handleToFd)++import Streamly.Internal.Data.Array (byteLength)+import Streamly.Internal.FileSystem.Path (Path)++import qualified Data.IntMap.Lazy as Map+import qualified Data.List.NonEmpty as NonEmpty+import qualified Streamly.Data.Fold as FL+import qualified Streamly.Data.Array as A (createOf)+import qualified Streamly.Data.Stream as S+import qualified Streamly.FileSystem.Handle as FH+import qualified Streamly.Internal.FileSystem.Path as Path++import qualified Streamly.Internal.Data.Array as A+ ( asCStringUnsafe, unsafePinnedAsPtr+ )+import qualified Streamly.Internal.FileSystem.DirIO as Dir (readDirs)+import qualified Streamly.Internal.Data.Parser as PR+ (takeEQ, fromEffect, fromFold)++-------------------------------------------------------------------------------+-- Subscription to events+-------------------------------------------------------------------------------++-- | Watch configuration, used to specify the events of interest and the+-- behavior of the watch.+--+-- /Pre-release/+--+data Config = Config+ { watchRec :: Bool+ , createFlags :: Word32+ }++-------------------------------------------------------------------------------+-- Boolean settings+-------------------------------------------------------------------------------++setFlag :: Word32 -> Bool -> Config -> Config+setFlag mask status cfg@Config{..} =+ let flags =+ if status+ then createFlags .|. mask+ else createFlags .&. complement mask+ in cfg {createFlags = flags}++-------------------------------------------------------------------------------+-- Settings+-------------------------------------------------------------------------------++-- | Watch the whole directory tree recursively instead of watching just one+-- level of directory.+--+-- /default: False/+--+-- /Pre-release/+--+setRecursiveMode :: Bool -> Config -> Config+setRecursiveMode recursive cfg@Config{} = cfg {watchRec = recursive}++foreign import capi+ "sys/inotify.h value IN_DONT_FOLLOW" iN_DONT_FOLLOW :: Word32++-- | If the pathname to be watched is a symbolic link then watch the target of+-- the symbolic link instead of the symbolic link itself.+--+-- Note that the path location in the events is through the original symbolic+-- link path rather than the resolved path.+--+-- /default: True/+--+-- /Pre-release/+--+setFollowSymLinks :: Bool -> Config -> Config+setFollowSymLinks s = setFlag iN_DONT_FOLLOW (not s)++foreign import capi+ "sys/inotify.h value IN_EXCL_UNLINK" iN_EXCL_UNLINK :: Word32++-- | If an object moves out of the directory being watched then stop watching+-- it.+--+-- /default: True/+--+-- /Pre-release/+--+setUnwatchMoved :: Bool -> Config -> Config+setUnwatchMoved = setFlag iN_EXCL_UNLINK++#if HAVE_DECL_IN_MASK_CREATE+foreign import capi+ "sys/inotify.h value IN_MASK_CREATE" iN_MASK_CREATE :: Word32+#endif++foreign import capi+ "sys/inotify.h value IN_MASK_ADD" iN_MASK_ADD :: Word32++-- | What to do if a watch already exists when 'openWatch' or 'addToWatch' is+-- called for a path.+--+-- /Pre-release/+--+data WhenExists =+ AddIfExists -- ^ Do not set an existing setting to 'False' only set to 'True'+ | ReplaceIfExists -- ^ Replace the existing settings with new settings+#if HAVE_DECL_IN_MASK_CREATE+ | FailIfExists -- ^ Fail the API+#endif++-- | When adding a new path to the watch, specify what to do if a watch already+-- exists on that path.+--+-- /default: FailIfExists/+--+-- /Pre-release/+--+setWhenExists :: WhenExists -> Config -> Config+setWhenExists val cfg =+ case val of+ AddIfExists -> setFlag iN_MASK_ADD True cfg+ ReplaceIfExists -> setFlag iN_MASK_ADD False cfg+#if HAVE_DECL_IN_MASK_CREATE+ FailIfExists -> setFlag iN_MASK_CREATE True cfg+#endif++foreign import capi+ "sys/inotify.h value IN_ONESHOT" iN_ONESHOT :: Word32++-- | Watch the object only for one event and then remove it from the watch.+--+-- /default: False/+--+-- /Pre-release/+--+setOneShot :: Bool -> Config -> Config+setOneShot = setFlag iN_ONESHOT++foreign import capi+ "sys/inotify.h value IN_ONLYDIR" iN_ONLYDIR :: Word32++-- | Watch the object only if it is a directory. This provides a race-free way+-- to ensure that the watched object is a directory.+--+-- /default: False/+--+-- /Pre-release/+--+setOnlyDir :: Bool -> Config -> Config+setOnlyDir = setFlag iN_ONLYDIR++-------------------------------------------------------------------------------+-- Event types that can occur+-------------------------------------------------------------------------------++foreign import capi+ "sys/inotify.h value IN_DELETE_SELF" iN_DELETE_SELF :: Word32++-- | Report when the watched path itself gets deleted.+--+-- /default: True/+--+-- /Pre-release/+--+setRootDeleted :: Bool -> Config -> Config+setRootDeleted = setFlag iN_DELETE_SELF++foreign import capi+ "sys/inotify.h value IN_MOVE_SELF" iN_MOVE_SELF :: Word32++-- | Report when the watched root path itself gets renamed.+--+-- /default: True/+--+-- /Pre-release/+--+setRootMoved :: Bool -> Config -> Config+setRootMoved = setFlag iN_MOVE_SELF++-- | Report when the watched root path itself gets deleted or renamed.+--+-- /default: True/+--+-- /Pre-release/+--+setRootPathEvents :: Bool -> Config -> Config+setRootPathEvents = setFlag (iN_DELETE_SELF .|. iN_MOVE_SELF)++foreign import capi+ "sys/inotify.h value IN_ATTRIB" iN_ATTRIB :: Word32++-- | Report when the metadata e.g. owner, permission modes, modifications times+-- of an object changes.+--+-- /default: True/+--+-- /Pre-release/+--+setAttrsModified :: Bool -> Config -> Config+setAttrsModified = setFlag iN_ATTRIB++foreign import capi+ "sys/inotify.h value IN_ACCESS" iN_ACCESS :: Word32++-- | Report when a file is accessed.+--+-- /default: True/+--+-- /Pre-release/+--+setAccessed :: Bool -> Config -> Config+setAccessed = setFlag iN_ACCESS++foreign import capi+ "sys/inotify.h value IN_OPEN" iN_OPEN :: Word32++-- | Report when a file is opened.+--+-- /default: True/+--+-- /Pre-release/+--+setOpened :: Bool -> Config -> Config+setOpened = setFlag iN_OPEN++foreign import capi+ "sys/inotify.h value IN_CLOSE_WRITE" iN_CLOSE_WRITE :: Word32++-- | Report when a file that was opened for writes is closed.+--+-- /default: True/+--+-- /Pre-release/+--+setWriteClosed :: Bool -> Config -> Config+setWriteClosed = setFlag iN_CLOSE_WRITE++foreign import capi+ "sys/inotify.h value IN_CLOSE_NOWRITE" iN_CLOSE_NOWRITE :: Word32++-- | Report when a file that was opened for not writing is closed.+--+-- /default: True/+--+-- /Pre-release/+--+setNonWriteClosed :: Bool -> Config -> Config+setNonWriteClosed = setFlag iN_CLOSE_NOWRITE++foreign import capi+ "sys/inotify.h value IN_CREATE" iN_CREATE :: Word32++-- | Report when a file is created.+--+-- /default: True/+--+-- /Pre-release/+--+setCreated :: Bool -> Config -> Config+setCreated = setFlag iN_CREATE++foreign import capi+ "sys/inotify.h value IN_DELETE" iN_DELETE :: Word32++-- | Report when a file is deleted.+--+-- /default: True/+--+-- /Pre-release/+--+setDeleted :: Bool -> Config -> Config+setDeleted = setFlag iN_DELETE++foreign import capi+ "sys/inotify.h value IN_MOVED_FROM" iN_MOVED_FROM :: Word32++-- | Report the source of a move.+--+-- /default: True/+--+-- /Pre-release/+--+setMovedFrom :: Bool -> Config -> Config+setMovedFrom = setFlag iN_MOVED_FROM++foreign import capi+ "sys/inotify.h value IN_MOVED_TO" iN_MOVED_TO :: Word32++-- | Report the target of a move.+--+-- /default: True/+--+-- /Pre-release/+--+setMovedTo :: Bool -> Config -> Config+setMovedTo = setFlag iN_MOVED_TO++foreign import capi+ "sys/inotify.h value IN_MODIFY" iN_MODIFY :: Word32++-- | Report when a file is modified.+--+-- /default: True/+--+-- /Pre-release/+--+setModified :: Bool -> Config -> Config+setModified = setFlag iN_MODIFY++-- | Set all tunable events 'True' or 'False'. Equivalent to setting:+--+-- * setRootDeleted+-- * setRootMoved+-- * setAttrsModified+-- * setAccessed+-- * setOpened+-- * setWriteClosed+-- * setNonWriteClosed+-- * setCreated+-- * setDeleted+-- * setMovedFrom+-- * setMovedTo+-- * setModified+--+-- /Pre-release/+--+setAllEvents :: Bool -> Config -> Config+setAllEvents s =+ setRootDeleted s+ . setRootMoved s+ . setAttrsModified s+ . setAccessed s+ . setOpened s+ . setWriteClosed s+ . setNonWriteClosed s+ . setCreated s+ . setDeleted s+ . setMovedFrom s+ . setMovedTo s+ . setModified s++-------------------------------------------------------------------------------+-- Default config+-------------------------------------------------------------------------------++-- The defaults are set in such a way that the behavior on macOS and Linux is+-- as much compatible as possible.+--+-- | The default configuration settings are:+--+-- * 'setFollowSymLinks' 'True'+-- * 'setUnwatchMoved' 'True'+-- * 'setOneShot' 'False'+-- * 'setOnlyDir' 'False'+-- * 'setWhenExists' 'AddIfExists'+--+-- The tunable events enabled by default are:+--+-- * setCreated True+-- * setDeleted True+-- * setMovedFrom True+-- * setMovedTo True+-- * setModified True+--+-- /Pre-release/+--+defaultConfig :: Config+defaultConfig =+ setWhenExists AddIfExists+ $ setCreated True+ $ setDeleted True+ $ setMovedFrom True+ $ setMovedTo True+ $ setModified True+ $ Config+ { watchRec = False+ , createFlags = 0+ }++-------------------------------------------------------------------------------+-- Path representation for events+-------------------------------------------------------------------------------++type PathRep =+ ( Path -- Absolute path of the watch root+ , Maybe Path -- Path of subdir relative to watch root+ )++{-# INLINE combinePathRep #-}+combinePathRep :: PathRep -> Path+combinePathRep (root, Nothing) = root+combinePathRep (root, Just sub) = Path.join root sub++{-# INLINE addSub #-}+addSub :: PathRep -> Path -> PathRep+addSub (root, Nothing) sub = (root, Just sub)+addSub (root, Just sub0) sub1 = (root, Just (Path.join sub0 sub1))++{-# INLINE getRepRoot #-}+getRepRoot :: PathRep -> Path+getRepRoot = fst++{-# INLINE getRepSub #-}+getRepSub :: PathRep -> Maybe Path+getRepSub = snd++-------------------------------------------------------------------------------+-- Open an event stream+-------------------------------------------------------------------------------++-- | A handle for a watch.+data Watch =+ Watch+ Handle -- File handle for the watch+ (IORef+ (IntMap -- Key is the watch descriptor+ PathRep+ )+ )++-- Instead of using the watch descriptor we can provide APIs that use the path+-- itself to identify the watch. That will require us to maintain a map from wd+-- to path in the Watch handle.++newtype WD = WD CInt deriving Show++-- XXX Use inotify_init1? and IN_NONBLOCK?+foreign import ccall unsafe+ "sys/inotify.h inotify_init" c_inotify_init :: IO CInt++-- | Create a 'Watch' handle. 'addToWatch' can be used to add paths being+-- monitored by this watch.+--+-- /Pre-release/+--+createWatch :: IO Watch+createWatch = do+ rawfd <- throwErrnoIfMinus1 "createWatch" c_inotify_init+ -- We could use fdToHandle but it cannot determine the fd type+ -- automatically for the inotify fd because fdStat fails for Stream type+ -- fd.+ --+ -- Do not use mkFD as it locks a regular file causing "resource busy" error+ -- in some test cases.+ let fd =+ FD+ { fdFD = rawfd+#if !defined(mingw32_HOST_OS)+ , fdIsNonBlocking = 0+#else+ , fdIsSocket_ = 0+#endif+ }++ -- XXX Do we need non-blocking IO?+ -- With non-blocking IO it fails because GHC-9.10 uses fdStat in+ -- FD.setNonBlockingMode to determine the fd type which fails for Stream+ -- type fd. However, without non-blocking IO "select" has a limitation on+ -- the number of FDs being watched (1024).+ h <-+ mkHandleFromFD+ fd+ Stream+ ("<createWatch fd: " ++ show fd ++ ">")+ ReadMode+ False -- use non-blocking IO+ Nothing -- TextEncoding (binary)+ emptyMapRef <- newIORef Map.empty+ return $ Watch h emptyMapRef++foreign import ccall unsafe+ "sys/inotify.h inotify_add_watch" c_inotify_add_watch+ :: CInt -> CString -> CUInt -> IO CInt++-- | @addToWatch cfg watch root subpath@ adds @subpath@ to the list of paths+-- being monitored under @root@ via the watch handle @watch@. @root@ must be+-- an absolute path and @subpath@ must be relative to @root@.+--+-- /Pre-release/+--+addToWatch :: Config -> Watch -> PathRep -> IO ()+addToWatch cfg@Config{..} watch0@(Watch handle wdMap) prep = do+ -- XXX do not add if the path is already added+ -- XXX if the watch is added by the scan and not via an event we can+ -- generate a create event assuming that the create may have been lost. We+ -- can also mark in the map that this entry was added by the scan. So if an+ -- actual create event later comes and tries to add this again then we can+ -- ignore that and drop the create event to avoid duplicate create, because+ -- we have already emitted it.+ --+ -- When a directory is added by the scan we should also emit create events+ -- for files that may have got added to the dir. However, such create+ -- events may get duplicated because of a race between the scan generated+ -- versus real events.+ --+ -- Or we may distinguish between scan generated events and real events so+ -- that the application can assume that other events may been lost and+ -- handle it. For example, if it is a dir create the application can read+ -- the dir to scan the files in it.+ --+ let absPath = combinePathRep prep+ -- showPathRep (root, Nothing) = "root = " ++ Path.toString root+ -- showPathRep (root, Just sub) =+ -- "root = " ++ Path.toString root ++ " sub = " ++ Path.toString sub+ -- putStrLn $ showPathRep prep ++ " absPath = " ++ Path.toString absPath++ fd <- handleToFd handle++ -- XXX we need to tolerate an error where we are adding a watch for a+ -- non-existing file because the file may have got deleted by the time we+ -- added the watch. Perhaps we can have a flag in config for this and keep+ -- the default value to tolerate the error.+ --+ -- XXX The file may have even got deleted and then recreated which we will+ -- never get to know, document this.+ wd <- A.asCStringUnsafe (Path.toArray absPath) $ \pathPtr ->+ throwErrnoIfMinus1 ("addToWatch: " ++ Path.toString absPath) $+ c_inotify_add_watch (fdFD fd) pathPtr (CUInt createFlags)++ -- We add the parent first so that we start getting events for any new+ -- creates and add the new subdirectories on creates while we are adding+ -- the children.+ modifyIORef wdMap (Map.insert (fromIntegral wd) prep)++ -- Now add the children. If we missed any creates while we were adding the+ -- parent, this will make sure they are added too.+ --+ -- XXX Ensure that we generate events that we may have missed while we were+ -- adding the dirs. That may generate spurious events though.+ --+ -- XXX Are the following comments obselete?+ -- XXX readDirs currently uses paths as String, we need to convert it+ -- to "/" separated by byte arrays.+ -- XXX Need a FileSystem.Stat module to remove this+ pathIsDir <- doesDirectoryExist (Path.toString absPath)+ when (watchRec && pathIsDir) $ do+ let f = addToWatch cfg watch0 . addSub prep+ in S.fold (FL.drainMapM f) $ Dir.readDirs id absPath++foreign import ccall unsafe+ "sys/inotify.h inotify_rm_watch" c_inotify_rm_watch+ :: CInt -> CInt -> IO CInt++-- | Remove an absolute root path from a 'Watch', if a path was moved after+-- adding you need to provide the original path which was used to add the+-- Watch.+--+-- /Pre-release/+--+removeFromWatch :: Watch -> Path -> IO ()+removeFromWatch (Watch handle wdMap) root = do+ fd <- handleToFd handle+ km <- readIORef wdMap+ wdMap1 <- foldlM (step fd) Map.empty (Map.toList km)+ writeIORef wdMap wdMap1++ where++ step fd newMap (wd, v) = do+ -- XXX Path is currently not guaranteed to be normalized.+ -- See: https://github.com/composewell/streamly/issues/2888+ if Path.toArray (getRepRoot v) == Path.toArray root+ then do+ let err = "removeFromWatch: " ++ show (Path.toString root)+ rm = c_inotify_rm_watch (fdFD fd) (fromIntegral wd)+ void $ throwErrnoIfMinus1 err rm+ return newMap+ else return $ Map.insert wd v newMap++-- | Given a 'Config' and list of @paths@ ("/" separated byte arrays) start+-- monitoring the paths for file system events. Returns a 'Watch' handle which+-- can then be used to read the event stream or to close the watch.+--+-- /Pre-release/+--+openWatch :: Config -> NonEmpty Path -> IO Watch+openWatch cfg paths = do+ w <- createWatch+ mapM_ (\root -> addToWatch cfg w (root, Nothing)) $ NonEmpty.toList paths+ return w++-- | Close a 'Watch' handle.+--+-- /Pre-release/+--+closeWatch :: Watch -> IO ()+closeWatch (Watch h _) = hClose h++-------------------------------------------------------------------------------+-- Raw events read from the watch file handle+-------------------------------------------------------------------------------++newtype Cookie = Cookie Word32 deriving (Show, Eq)++-- | An Event generated by the file system. Use the accessor functions to+-- examine the event.+--+-- /Pre-release/+--+data Event = Event+ { eventWd :: CInt+ , eventFlags :: Word32+ , eventCookie :: Word32+ , eventRelPath :: Maybe Path+ , eventMap :: IntMap PathRep+ }++-- The inotify event struct from the man page/header file:+--+-- struct inotify_event {+-- int wd; /* Watch descriptor */+-- uint32_t mask; /* Mask describing event */+-- uint32_t cookie; /* Unique cookie associating related+-- events (for rename(2)) */+-- uint32_t len; /* Size of name field */+-- char name[]; /* Optional null-terminated name */+-- };+--+-- XXX We can perhaps use parseD monad instance for fusing with parseMany? Need+-- to measure the perf.+--+readOneEvent :: Config -> Watch -> Parser Word8 IO Event+readOneEvent cfg wt@(Watch _ wdMap) = do+ let headerLen = sizeOf (undefined :: CInt) + 12+ arr <- PR.takeEQ headerLen (A.createOf headerLen)+ (ewd, eflags, cookie, pathLen) <- PR.fromEffect $ A.unsafePinnedAsPtr arr readHeader+ -- XXX need the "initial" in parsers to return a step type so that "take 0"+ -- can return without an input. otherwise if pathLen is 0 we will keep+ -- waiting to read one more char before we return this event.+ wdm <- PR.fromEffect $ readIORef wdMap+ let prep =+ case Map.lookup (fromIntegral ewd) wdm of+ Just prep0 -> prep0+ Nothing ->+ error $ "readOneEvent: "+ <> "Unknown watch descriptor: "+ <> show ewd+ prep1 <-+ if pathLen /= 0+ then do+ -- XXX takeEndBy_ drops the separator so assumes a null+ -- terminated path, we should use a takeWhile nested inside a+ -- takeP+ pth <-+ PR.fromFold+ $ FL.takeEndBy_ (== 0)+ $ FL.take pathLen (A.createOf pathLen)+ let remaining = pathLen - byteLength pth - 1+ when (remaining /= 0) $ PR.takeEQ remaining FL.drain+ return $ addSub prep (Path.unsafeFromArray pth)+ else return $ prep+ -- Check for "ISDIR" first because it is less likely+ let isDirCreate = eflags .&. iN_ISDIR /= 0 && eflags .&. iN_CREATE /= 0+ when (watchRec cfg && isDirCreate)+ $ PR.fromEffect $ addToWatch cfg wt prep1+ -- XXX Handle IN_DELETE, IN_DELETE_SELF, IN_MOVE_SELF, IN_MOVED_FROM,+ -- IN_MOVED_TO+ -- What if a large dir tree gets moved in to our hierarchy? Do we get a+ -- single event for the top level dir in this case?+ return $ Event+ { eventWd = fromIntegral ewd+ , eventFlags = eflags+ , eventCookie = cookie+ , eventRelPath = getRepSub prep1+ , eventMap = wdm+ }++ where++ readHeader (ptr :: Ptr Word8) _ = do+ let len = sizeOf (undefined :: CInt)+ ewd <- peek ptr+ eflags <- peekByteOff ptr len+ cookie <- peekByteOff ptr (len + 4)+ pathLen :: Word32 <- peekByteOff ptr (len + 8)+ return (ewd, eflags, cookie, fromIntegral pathLen)++watchToStream :: Config -> Watch -> Stream IO Event+watchToStream cfg wt@(Watch handle _) = do+ -- Do not use too small a buffer. As per inotify man page:+ --+ -- The behavior when the buffer given to read(2) is too small to return+ -- information about the next event depends on the kernel version: in+ -- kernels before 2.6.21, read(2) returns 0; since kernel 2.6.21, read(2)+ -- fails with the error EINVAL. Specifying a buffer of size+ --+ -- sizeof(struct inotify_event) + NAME_MAX + 1+ --+ -- will be sufficient to read at least one event.+ S.catRights $ S.parseMany (readOneEvent cfg wt) $ S.unfold FH.reader handle++-- XXX We should not go across the mount points of network file systems or file+-- systems that are known to not generate any events.+--+-- | Start monitoring a list of file system paths for file system events with+-- the supplied configuration operation over the 'defaultConfig'. The+-- paths could be files or directories. When recursive mode is set and the+-- path is a directory, the whole directory tree under it is watched+-- recursively. Monitoring starts from the current time onwards.+--+-- /Non-existing Paths:/ the API fails if a watch is started on a non-exsting+-- path.+--+-- /Performance:/ Note that recursive watch on a large directory tree could be+-- expensive. When starting a watch, the whole tree must be read and watches+-- are started on each directory in the tree. The initial time to start the+-- watch as well as the memory required is proportional to the number of+-- directories in the tree.+--+-- /Bugs:/ When new directories are created under the tree they are added to+-- the watch on receiving the directory create event. However, the creation of+-- a dir and adding a watch for it is not atomic. The implementation takes+-- care of this and makes sure that watches are added for all directories.+-- However, In the mean time, the directory may have received more events which+-- may get lost. Handling of any such lost events is yet to be implemented.+--+-- See the Linux __inotify__ man page for more details.+--+-- @+-- watchwith+-- ('setFollowSymLinks' True . 'setUnwatchMoved' False)+-- [Path.fromString "dir"]+-- @+--+-- /Pre-release/+--+watchWith :: (Config -> Config) -> NonEmpty Path -> Stream IO Event+watchWith f paths = S.bracketIO before after (watchToStream cfg)++ where++ cfg = f defaultConfig+ before = openWatch cfg paths+ after = closeWatch++-- | Same as 'watchWith' using 'defaultConfig' and recursive mode.+--+-- >>> watchRecursive = watchWith (setRecursiveMode True)+--+-- See 'watchWith' for pitfalls and bugs when using recursive watch on Linux.+--+-- /Pre-release/+--+watchRecursive :: NonEmpty Path -> Stream IO Event+watchRecursive = watchWith (setRecursiveMode True)++-- | Same as 'watchWith' using defaultConfig and non-recursive mode.+--+-- >>> watch = watchWith id+--+-- /Pre-release/+--+watch :: NonEmpty Path -> Stream IO Event+watch = watchWith id++-------------------------------------------------------------------------------+-- Examine event stream+-------------------------------------------------------------------------------++-- XXX Should we return a Maybe here instead of erroring out?+-- | Get the watch root corresponding to the 'Event'.+--+-- Note that if a path was moved after adding to the watch, this will give the+-- original path and not the new path after moving.+--+-- TBD: we can possibly update the watch root on a move self event.+--+-- /Pre-release/+--+getRoot :: Event -> Path+getRoot Event{..} =+ if eventWd >= 1+ then+ case Map.lookup (fromIntegral eventWd) eventMap of+ Just prep -> getRepRoot prep+ Nothing ->+ error $ "Bug: getRoot: No path found corresponding to the "+ ++ "watch descriptor " ++ show eventWd+ else error $ "getRoot: ewd = " ++ show eventWd++-- XXX should we use a Maybe here?+-- | Get the file system object path for which the event is generated, relative+-- to the watched root. The path is a "/" separated array of bytes.+--+-- /Pre-release/+--+getRelPath :: Event -> Maybe Path+getRelPath Event{..} = eventRelPath++-- | Get the absolute file system object path for which the event is generated.+--+-- When the watch root is a symlink, the absolute path returned is via the+-- original symlink and not through the resolved path.+--+-- /Pre-release/+--+getAbsPath :: Event -> Path+getAbsPath ev =+ case getRelPath ev of+ Just relPath -> Path.join (getRoot ev) relPath+ Nothing -> getRoot ev++-- XXX should we use a Maybe?+-- | Cookie is set when a rename occurs. The cookie value can be used to+-- connect the 'isMovedFrom' and 'isMovedTo' events, if both the events belong+-- to the same move operation then they will have the same cookie value.+--+-- /Pre-release/+--+getCookie :: Event -> Cookie+getCookie Event{..} = Cookie eventCookie++-------------------------------------------------------------------------------+-- Event types+-------------------------------------------------------------------------------++getFlag :: Word32 -> Event -> Bool+getFlag mask Event{..} = eventFlags .&. mask /= 0++-------------------------------------------------------------------------------+-- Error events+-------------------------------------------------------------------------------++foreign import capi+ "sys/inotify.h value IN_Q_OVERFLOW" iN_Q_OVERFLOW :: Word32++-- XXX rename to isQOverflowed or hasOverflowed?+--+-- macOS overflow API is more specific, it tells which paths have lost the+-- events due to overflow.+--+-- | Event queue overflowed (WD is invalid for this event) and we may have lost+-- some events.. The user application must scan everything under the watched+-- paths to know the current state.+--+-- /Pre-release/+--+isEventsLost :: Event -> Bool+isEventsLost = getFlag iN_Q_OVERFLOW++-------------------------------------------------------------------------------+-- Events affecting the watched path only+-------------------------------------------------------------------------------++foreign import capi+ "sys/inotify.h value IN_IGNORED" iN_IGNORED :: Word32++-- Compare with isRootChanged on macOS. isRootChanged includes all these cases.+--+-- | A path was removed from the watch explicitly using 'removeFromWatch' or+-- automatically (file was deleted, or filesystem was unmounted).+--+-- Note that in recursive watch mode all the subdirectories are watch roots,+-- therefore, they will all generate this event.+--+-- /Occurs only for a watched path/+--+-- /Pre-release/+--+isRootUnwatched :: Event -> Bool+isRootUnwatched = getFlag iN_IGNORED++-- | Watched file/directory was itself deleted. (This event also occurs if an+-- object is moved to another filesystem, since mv(1) in effect copies the file+-- to the other filesystem and then deletes it from the original filesystem.)+-- In addition, an 'isRootUnwatched' event will subsequently be generated+-- for the watch descriptor.+--+-- Note that in recursive watch mode all the subdirectories are watch roots,+-- therefore, they will all generate this event.+--+-- /Occurs only for a watched path/+--+-- /Pre-release/+--+isRootDeleted :: Event -> Bool+isRootDeleted = getFlag iN_DELETE_SELF++-- | Watched file/directory was itself moved within the file system.+--+-- Note that in recursive watch mode all the subdirectories are watch roots,+-- therefore, they will all generate this event.+--+-- /Occurs only for a watched path/+--+-- /Pre-release/+--+isRootMoved :: Event -> Bool+isRootMoved = getFlag iN_MOVE_SELF++foreign import capi+ "sys/inotify.h value IN_UNMOUNT" iN_UNMOUNT :: Word32++-- | Filesystem containing watched object was unmounted. In addition, an+-- 'isRootUnwatched' event will subsequently be generated for the watch+-- descriptor.+--+-- /Occurs only for a watched path/+--+-- /Pre-release/+--+isRootUnmounted :: Event -> Bool+isRootUnmounted = getFlag iN_UNMOUNT++-- | Determine whether the event indicates a change of path of the monitored+-- object itself. Note that the object may become unreachable or deleted after+-- a change of path.+--+-- /Occurs only for a watched path/+--+-- /Pre-release/+--+isRootPathEvent :: Event -> Bool+isRootPathEvent = getFlag (iN_DELETE_SELF .|. iN_MOVE_SELF .|. iN_UNMOUNT)++-------------------------------------------------------------------------------+-- Metadata change Events+-------------------------------------------------------------------------------++-- macOS has multiple APIs for metadata change for different metadata.+--+-- | Determine whether the event indicates inode metadata change for an object+-- contained within the monitored path.+--+-- Metadata change may include, permissions (e.g., chmod(2)), timestamps+-- (e.g., utimensat(2)), extended attributes (setxattr(2)), link count (since+-- Linux 2.6.25; e.g., for the target of link(2) and for unlink(2)), and+-- user/group ID (e.g., chown(2)).+--+-- /Can occur for watched path or a file inside it/+--+-- /Pre-release/+--+isAttrsModified :: Event -> Bool+isAttrsModified = getFlag iN_ATTRIB++-------------------------------------------------------------------------------+-- Access+-------------------------------------------------------------------------------++-- | File was accessed (e.g. read, execve).+--+-- /Occurs only for a file inside the watched directory/+--+-- /Pre-release/+--+isAccessed :: Event -> Bool+isAccessed = getFlag iN_ACCESS++-- | File or directory was opened.+--+-- /Occurs only for a file inside the watched directory/+--+-- /Pre-release/+--+isOpened :: Event -> Bool+isOpened = getFlag iN_OPEN++-- | File opened for writing was closed.+--+-- /Occurs only for a file inside the watched directory/+--+-- /Pre-release/+--+isWriteClosed :: Event -> Bool+isWriteClosed = getFlag iN_CLOSE_WRITE++-- XXX what if it was opened for append? Does NOWRITE mean all cases where the+-- mode was not write? A dir open comes in this category?+--+-- | File or directory opened for read but not write was closed.+--+-- /Can occur for watched path or a file inside it/+--+-- /Pre-release/+--+isNonWriteClosed :: Event -> Bool+isNonWriteClosed = getFlag iN_CLOSE_NOWRITE++-------------------------------------------------------------------------------+-- CRUD Events+-------------------------------------------------------------------------------++-- On macOS this is not generated on hard linking but on Linux it is.+--+-- | File/directory created in watched directory (e.g., open(2) O_CREAT,+-- mkdir(2), link(2), symlink(2), bind(2) on a UNIX domain socket).+--+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isCreated :: Event -> Bool+isCreated = getFlag iN_CREATE++-- | File/directory deleted from watched directory.+--+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isDeleted :: Event -> Bool+isDeleted = getFlag iN_DELETE++-- XXX what if an object is moved in from outside or moved out of the monitored+-- dir?+--+-- | Generated for the original path when an object is moved from under a+-- monitored directory.+--+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isMovedFrom :: Event -> Bool+isMovedFrom = getFlag iN_MOVED_FROM++-- | Generated for the new path when an object is moved under a monitored+-- directory.+--+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isMovedTo :: Event -> Bool+isMovedTo = getFlag iN_MOVED_TO++-- | Generated for a path that is moved from or moved to the monitored+-- directory.+--+-- >>> isMoved ev = isMovedFrom ev || isMovedTo ev+--+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isMoved :: Event -> Bool+isMoved ev = isMovedFrom ev || isMovedTo ev++-- | Determine whether the event indicates modification of an object within the+-- monitored path. This event is generated only for files and not directories.+--+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isModified :: Event -> Bool+isModified = getFlag iN_MODIFY++-------------------------------------------------------------------------------+-- Information about path type (applicable only when 'setFileEvents' is 'True')+-------------------------------------------------------------------------------++foreign import capi+ "sys/inotify.h value IN_ISDIR" iN_ISDIR :: Word32++-- | Determine whether the event is for a directory path.+--+-- /Pre-release/+--+isDir :: Event -> Bool+isDir = getFlag iN_ISDIR++-------------------------------------------------------------------------------+-- Debugging+-------------------------------------------------------------------------------++-- | Convert an 'Event' record to a String representation.+showEvent :: Event -> String+showEvent ev@Event{..} =+ "--------------------------"+ ++ "\nWd = " ++ show eventWd+ ++ "\nRoot = " ++ show (Path.toString $ getRoot ev)+ ++ "\nPath = " ++ maybe "" (show . Path.toString) (getRelPath ev)+ ++ "\nCookie = " ++ show (getCookie ev)+ ++ "\nFlags " ++ show eventFlags++ ++ showev isEventsLost "Overflow"++ ++ showev isRootUnwatched "RootUnwatched"+ ++ showev isRootDeleted "RootDeleted"+ ++ showev isRootMoved "RootMoved"+ ++ showev isRootUnmounted "RootUnmounted"++ ++ showev isAttrsModified "AttrsModified"++ ++ showev isAccessed "Accessed"+ ++ showev isOpened "Opened"+ ++ showev isWriteClosed "WriteClosed"+ ++ showev isNonWriteClosed "NonWriteClosed"++ ++ showev isCreated "Created"+ ++ showev isDeleted "Deleted"+ ++ showev isModified "Modified"+ ++ showev isMovedFrom "MovedFrom"+ ++ showev isMovedTo "MovedTo"++ ++ showev isDir "Dir"+ ++ "\n"++ where showev f str = if f ev then "\n" ++ str else ""+#else+#warning "Disabling module Streamly.Internal.FS.Event.Linux. Does not support kernels older than 2.6.36."+module Streamly.Internal.FS.Event.Linux () where+#endif
+ src/Streamly/Internal/FS/Event/Windows.hs view
@@ -0,0 +1,618 @@+-- Some code snippets are adapted from the fsnotify package.+-- http://hackage.haskell.org/package/fsnotify-0.3.0.1/+--+-- |+-- Module : Streamly.Internal.FS.Event.Windows+-- Copyright : (c) 2020 Composewell Technologies+-- (c) 2012, Mark Dittmer+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : pre-release+-- Portability : GHC+--+-- =Overview+--+-- Use 'watchRecursive'or 'watch' with a list of file system dir paths you+-- want to watch as argument. It returns a stream of 'Event' representing the+-- file system events occurring under the watched paths.+--+-- @+-- {-\# LANGUAGE MagicHash #-}+-- Stream.mapM_ (putStrLn . 'showEvent') $ 'watchRecursive' [Path.fromString "path"]+-- @+--+-- 'Event' is an opaque type. Accessor functions (e.g. 'showEvent' above)+-- provided in this module are used to determine the attributes of the event.+--+-- =Design notes+--+-- For Windows reference documentation see:+--+-- * <https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-file_notify_information file notify information>+-- * <https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readdirectorychangesw read directory changes>+--+-- We try to keep the macOS\/Linux/Windows event handling APIs and defaults+-- semantically and syntactically as close as possible.+--+-- =Availability+--+-- As per the Windows reference docs, the fs event notification API is+-- available in:+--+-- * Minimum supported client: Windows XP [desktop apps | UWP apps]+-- * Minimum supported server: Windows Server 2003 [desktop apps | UWP apps++module Streamly.Internal.FS.Event.Windows+ (+ -- * Subscribing to events++ -- ** Default configuration+ Config+ , defaultConfig++ -- ** Watch Behavior+ , setRecursiveMode++ -- ** Events of Interest+ , setFileNameEvents+ , setDirNameEvents+ , setAttrsModified+ , setSecurityModified+ , setSizeModified+ , setLastWriteTimeModified+ , setAllEvents++ -- ** Watch APIs+ , watch+ , watchRecursive+ , watchWith++ -- * Handling Events+ , Event(..)+ , getRoot+ , getRelPath+ , getAbsPath++ -- ** Item CRUD events+ , isCreated+ , isDeleted+ , isModified+ , isMoved+ , isMovedFrom+ , isMovedTo++ -- ** Exception Conditions+ , isEventsLost++ -- * Debugging+ , showEvent+ )+where++import Data.Bits ((.|.), (.&.), complement)+import Data.List.NonEmpty (NonEmpty)+import Foreign.Marshal.Alloc (alloca, allocaBytes)+import Foreign.Storable (peekByteOff)+import Foreign.Ptr (Ptr, FunPtr, castPtr, nullPtr, nullFunPtr, plusPtr)+import System.Win32.File+ ( FileNotificationFlag+ , LPOVERLAPPED+ , closeHandle+ , createFile+ , fILE_FLAG_BACKUP_SEMANTICS+ , fILE_LIST_DIRECTORY+ , fILE_NOTIFY_CHANGE_FILE_NAME+ , fILE_NOTIFY_CHANGE_DIR_NAME+ , fILE_NOTIFY_CHANGE_ATTRIBUTES+ , fILE_NOTIFY_CHANGE_SIZE+ , fILE_NOTIFY_CHANGE_LAST_WRITE+ , fILE_NOTIFY_CHANGE_SECURITY+ , fILE_SHARE_READ+ , fILE_SHARE_WRITE+ , oPEN_EXISTING+ )+import System.Win32.Types (BOOL, DWORD, HANDLE, LPVOID, LPDWORD, failIfFalse_)++import Streamly.Data.Stream (Stream)+import Streamly.Data.Stream.Prelude (eager)+import Streamly.Internal.FileSystem.Path (Path)++import qualified Data.List.NonEmpty as NonEmpty+import qualified Streamly.Data.Fold as Fold+import qualified Streamly.Data.Stream as S+import qualified Streamly.Data.Stream.Prelude as S+import qualified Streamly.Internal.Data.Array as Array+import qualified Streamly.Internal.FileSystem.Path as Path++-- | Watch configuration, used to specify the events of interest and the+-- behavior of the watch.+--+-- /Pre-release/+--+data Config = Config+ { watchRec :: BOOL+ , createFlags :: DWORD+ }++-------------------------------------------------------------------------------+-- Boolean settings+-------------------------------------------------------------------------------++setFlag :: DWORD -> Bool -> Config -> Config+setFlag mask status cfg@Config{..} =+ let flags =+ if status+ then createFlags .|. mask+ else createFlags .&. complement mask+ in cfg {createFlags = flags}++-- | Set watch event on directory recursively.+--+-- /default: False/+--+-- /Pre-release/+--+setRecursiveMode :: Bool -> Config -> Config+setRecursiveMode recursive cfg@Config{} = cfg {watchRec = recursive}++-- | Generate notify events on file create, rename or delete.+--+-- From Windows API documentation: Any file name change in the watched+-- directory or subtree causes a change notification wait operation to return.+-- Changes include renaming, creating, or deleting a file.+--+-- /default: True/+--+-- /Pre-release/+--+setFileNameEvents :: Bool -> Config -> Config+setFileNameEvents = setFlag fILE_NOTIFY_CHANGE_FILE_NAME++-- | Generate notify events on directory create, rename or delete.+--+-- From Windows API documentaiton: Any directory-name change in the watched+-- directory or subtree causes a change notification wait operation to return.+-- Changes include creating or deleting a directory.+--+-- /default: True/+--+-- /Pre-release/+--+setDirNameEvents :: Bool -> Config -> Config+setDirNameEvents = setFlag fILE_NOTIFY_CHANGE_DIR_NAME++-- | Generate an 'isModified' event on any attribute change in the watched+-- directory or subtree.+--+-- /default: False/+--+-- /Pre-release/+--+setAttrsModified :: Bool -> Config -> Config+setAttrsModified = setFlag fILE_NOTIFY_CHANGE_ATTRIBUTES++-- | Generate an 'isModified' event when the file size is changed.+--+-- From Windows API documentation: Any file-size change in the watched+-- directory or subtree causes a change notification wait operation to return.+-- The operating system detects a change in file size only when the file is+-- written to the disk. For operating systems that use extensive caching,+-- detection occurs only when the cache is sufficiently flushed.+--+-- /default: False/+--+-- /Pre-release/+--+setSizeModified :: Bool -> Config -> Config+setSizeModified = setFlag fILE_NOTIFY_CHANGE_SIZE++-- | Generate an 'isModified' event when the last write timestamp of the file+-- inode is changed.+--+-- From Windows API documentation: Any change to the last write-time of files+-- in the watched directory or subtree causes a change notification wait+-- operation to return. The operating system detects a change to the last+-- write-time only when the file is written to the disk. For operating systems+-- that use extensive caching, detection occurs only when the cache is+-- sufficiently flushed.+--+-- /default: False/+--+-- /Pre-release/+--+setLastWriteTimeModified :: Bool -> Config -> Config+setLastWriteTimeModified = setFlag fILE_NOTIFY_CHANGE_LAST_WRITE++-- | Generate an 'isModified' event when any security-descriptor change occurs+-- in the watched directory or subtree.+--+-- /default: False/+--+-- /Pre-release/+--+setSecurityModified :: Bool -> Config -> Config+setSecurityModified = setFlag fILE_NOTIFY_CHANGE_SECURITY++-- | Set all tunable events 'True' or 'False'. Equivalent to setting:+--+-- * setFileNameEvents+-- * setDirNameEvents+-- * setAttrsModified+-- * setSizeModified+-- * setLastWriteTimeModified+-- * setSecurityModified+--+-- /Pre-release/+--+setAllEvents :: Bool -> Config -> Config+setAllEvents s =+ setFileNameEvents s+ . setDirNameEvents s+ . setAttrsModified s+ . setSizeModified s+ . setLastWriteTimeModified s+ . setSecurityModified s++-- | The tunable events that are enabled by default are:+--+-- * setFileNameEvents True+-- * setDirNameEvents True+-- * setSizeModified True+-- * setLastWriteTimeModified True+--+-- /Pre-release/+--+defaultConfig :: Config+defaultConfig =+ setFileNameEvents True+ $ setDirNameEvents True+ $ setSizeModified True+ $ setLastWriteTimeModified True+ $ Config {watchRec = False, createFlags = 0}++getConfigFlag :: Config -> DWORD+getConfigFlag Config{..} = createFlags++getConfigRecMode :: Config -> BOOL+getConfigRecMode Config{..} = watchRec++data Event = Event+ { eventFlags :: DWORD+ , eventRelPath :: Path+ , eventRootPath :: Path+ , totalBytes :: DWORD+ }++-- For reference documentation see:+--+-- See https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-file_notify_information+data FILE_NOTIFY_INFORMATION = FILE_NOTIFY_INFORMATION+ { fniNextEntryOffset :: DWORD+ , fniAction :: DWORD+ , fniFileName :: Path+ }++type LPOVERLAPPED_COMPLETION_ROUTINE =+ FunPtr ((DWORD, DWORD, LPOVERLAPPED) -> IO ())++-- | A handle for a watch.+getWatchHandle :: Path -> IO (HANDLE, Path)+getWatchHandle dir = do+ let dirStr = Path.toString dir+ h <- createFile dirStr+ -- Access mode+ fILE_LIST_DIRECTORY+ -- Share mode+ (fILE_SHARE_READ .|. fILE_SHARE_WRITE)+ -- Security attributes+ Nothing+ -- Create mode, we want to look at an existing directory+ oPEN_EXISTING+ -- File attribute, NOT using OVERLAPPED since we work synchronously+ fILE_FLAG_BACKUP_SEMANTICS+ -- No template file+ Nothing+ return (h, dir)++-- For reference documentation see:+--+-- See https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-readdirectorychangesw+-- Note that this API uses UTF-16 for file system paths:+-- 1. https://docs.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api+-- 2. https://docs.microsoft.com/en-us/windows/win32/intl/unicode+foreign import ccall safe+ "windows.h ReadDirectoryChangesW" c_ReadDirectoryChangesW ::+ HANDLE+ -> LPVOID+ -> DWORD+ -> BOOL+ -> DWORD+ -> LPDWORD+ -> LPOVERLAPPED+ -> LPOVERLAPPED_COMPLETION_ROUTINE+ -> IO BOOL++readDirectoryChangesW ::+ HANDLE+ -> Ptr FILE_NOTIFY_INFORMATION+ -> DWORD+ -> BOOL+ -> FileNotificationFlag+ -> LPDWORD+ -> IO ()+readDirectoryChangesW h buf bufSize wst f br =+ let res = c_ReadDirectoryChangesW+ h (castPtr buf) bufSize wst f br nullPtr nullFunPtr+ in failIfFalse_ "ReadDirectoryChangesW" res++peekFNI :: Ptr FILE_NOTIFY_INFORMATION -> IO FILE_NOTIFY_INFORMATION+peekFNI buf = do+ neof <- peekByteOff buf 0+ acti <- peekByteOff buf 4+ (fnle :: DWORD) <- peekByteOff buf 8+ fnam0 <- Array.fromPtrN (fromIntegral fnle) (buf `plusPtr` 12)+ fnam <- Path.fromArray (Array.unsafeCast fnam0)+ return $ FILE_NOTIFY_INFORMATION neof acti fnam++readChangeEvents ::+ Ptr FILE_NOTIFY_INFORMATION -> Path -> DWORD -> IO [Event]+readChangeEvents pfni root bytesRet = do+ fni <- peekFNI pfni+ let entry = Event+ { eventFlags = fniAction fni+ , eventRelPath = fniFileName fni+ , eventRootPath = root+ , totalBytes = bytesRet+ }+ nioff = fromEnum $ fniNextEntryOffset fni+ entries <-+ if nioff == 0+ then return []+ else readChangeEvents (pfni `plusPtr` nioff) root bytesRet+ return $ entry : entries++readDirectoryChanges ::+ Path -> HANDLE -> Bool -> FileNotificationFlag -> IO [Event]+readDirectoryChanges root h wst mask = do+ let maxBuf = 63 * 1024+ allocaBytes maxBuf $ \buffer -> do+ alloca $ \bret -> do+ readDirectoryChangesW h buffer (toEnum maxBuf) wst mask bret+ bytesRet <- peekByteOff bret 0+ readChangeEvents buffer root bytesRet++-- XXX Try to get these from windows header files+type FileAction = DWORD++fILE_ACTION_ADDED :: FileAction+fILE_ACTION_ADDED = 1++fILE_ACTION_REMOVED :: FileAction+fILE_ACTION_REMOVED = 2++fILE_ACTION_MODIFIED :: FileAction+fILE_ACTION_MODIFIED = 3++fILE_ACTION_RENAMED_OLD_NAME :: FileAction+fILE_ACTION_RENAMED_OLD_NAME = 4++fILE_ACTION_RENAMED_NEW_NAME :: FileAction+fILE_ACTION_RENAMED_NEW_NAME = 5++eventStreamAggr :: (HANDLE, Path, Config) -> Stream IO Event+eventStreamAggr (handle, rootPath, cfg) = do+ let recMode = getConfigRecMode cfg+ flagMasks = getConfigFlag cfg+ repeatM = S.sequence . S.repeat+ S.concatMap S.fromList $ repeatM+ $ readDirectoryChanges rootPath handle recMode flagMasks++pathsToHandles ::+ NonEmpty Path -> Config -> Stream IO (HANDLE, Path, Config)+pathsToHandles paths cfg = do+ let pathStream = S.fromList (NonEmpty.toList paths)+ st2 = S.mapM getWatchHandle pathStream+ fmap (\(h, f) -> (h, f, cfg)) st2++-------------------------------------------------------------------------------+-- Utilities+-------------------------------------------------------------------------------++-- | Close a Directory handle.+--+closePathHandleStream :: Stream IO (HANDLE, Path, Config) -> IO ()+closePathHandleStream =+ let f (h, _, _) = closeHandle h+ in S.fold (Fold.drainMapM f)++-- XXX+-- Remove the encoding requirement of paths? It can be encoding agnostic+-- "\" separated bytes, the application can decide what encoding to use.+-- Instead of always using widechar (-W) APIs can we call the underlying APIs+-- based on the configured code page?+-- https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page+--+-- | Start monitoring a list of directory paths for file system events with the+-- supplied configuration modifier operation over the' defaultConfig'. The+-- paths could be directories or symbolic links to directories.+--+-- When recursive mode is True, the whole directory tree under the path is+-- watched recursively. When recursive mode is False, only the files and+-- directories directly under the watched directory are monitored, contents of+-- subdirectories are not monitored. Monitoring starts from the current time+-- onwards.+--+-- /Symbolic Links:/ If the pathname to be watched is a symbolic link then+-- watch the target of the symbolic link instead of the symbolic link itself.+-- Note that the path location in the events is through the original symbolic+-- link path rather than the resolved path.+--+-- @+-- watchWith+-- ('setAttrsModified' True . 'setLastWriteTimeModified' False)+-- [Path.fromString "dir"]+-- @+--+-- /Pre-release/+--+watchWith :: (Config -> Config) -> NonEmpty Path -> Stream IO Event+watchWith f paths =+ S.bracketIO before after (S.parConcatMap (eager True) eventStreamAggr)++ where++ before = return $ pathsToHandles paths $ f defaultConfig+ after = closePathHandleStream++-- | Same as 'watchWith' using 'defaultConfig' and recursive mode.+--+-- >>> watchRecursive = watchWith (setRecursiveMode True)+--+-- /Pre-release/+--+watchRecursive :: NonEmpty Path -> Stream IO Event+watchRecursive = watchWith (setRecursiveMode True)++-- | Same as 'watchWith' using defaultConfig and non-recursive mode.+--+-- >>> watch = watchWith id+--+-- /Pre-release/+--+watch :: NonEmpty Path -> Stream IO Event+watch = watchWith id++getFlag :: DWORD -> Event -> Bool+getFlag mask Event{..} = eventFlags == mask++-- | Get the file system object path for which the event is generated, relative+-- to the watched root.+--+-- /Pre-release/+--+getRelPath :: Event -> Path+getRelPath Event{..} = eventRelPath++-- | Get the watch root directory to which this event belongs.+--+-- /Pre-release/+--+getRoot :: Event -> Path+getRoot Event{..} = eventRootPath++-- | Get the absolute file system object path for which the event is generated.+--+-- When the watch root is a symlink, the absolute path returned is via the+-- original symlink and not through the resolved path.+--+-- /Pre-release/+--+getAbsPath :: Event -> Path+getAbsPath ev = Path.join (getRoot ev) (getRelPath ev)++-- XXX need to document the exact semantics of these.+--+-- | This event is generated when a file or directory is created in a watched+-- directory or directory tree when in recursive watch mode. Creating a hard+-- link also generates this event.+--+-- /Occurs when either 'setFileNameEvents' or 'setDirNameEvents' is enabled/+--+-- /Pre-release/+--+isCreated :: Event -> Bool+isCreated = getFlag fILE_ACTION_ADDED++-- | This event is generated when a file or directory is deleted from the+-- watched directory or directory tree when in recursive mode. This event is+-- generated even when a hard link is deleted.+--+-- /Occurs when either 'setFileNameEvents' or 'setDirNameEvents' is enabled/+--+-- /Pre-release/+--+isDeleted :: Event -> Bool+isDeleted = getFlag fILE_ACTION_REMOVED++-- | Generated for the original path when an object is moved from under a+-- monitored directory.+--+-- /Occurs when either 'setFileNameEvents' or 'setDirNameEvents' is enabled/+--+-- /Pre-release/+--+isMovedFrom :: Event -> Bool+isMovedFrom = getFlag fILE_ACTION_RENAMED_OLD_NAME++-- | Generated for the new path when an object is moved under a monitored+-- directory.+--+-- /Occurs when either 'setFileNameEvents' or 'setDirNameEvents' is enabled/+--+-- /Pre-release/+--+isMovedTo :: Event -> Bool+isMovedTo = getFlag fILE_ACTION_RENAMED_NEW_NAME++-- | Generated for a path that is moved from or moved to the monitored+-- directory.+--+-- >>> isMoved ev = isMovedFrom ev || isMovedTo ev+--+-- /Occurs when either 'setFileNameEvents' or 'setDirNameEvents' is enabled/+-- /Occurs only for an object inside the watched directory/+--+-- /Pre-release/+--+isMoved :: Event -> Bool+isMoved ev = isMovedFrom ev || isMovedTo ev++-- XXX This event is generated only for files and not directories?+--+-- | This event occurs when a file or directory contents, timestamps or+-- attributes are modified. Since it can occur on multiple changes, you may+-- have to check the attributes to know what exactly changed when multiple type+-- of modified events are enabled.+--+-- In non-recursive mode this event does not occur for directories. In+-- recursive mode this event occurs for the parent directory if a file or+-- directory inside it is created or renamed.+--+-- /Occurs when one of the @set*Modified@ events is enabled/+--+-- /Pre-release/+--+isModified :: Event -> Bool+isModified = getFlag fILE_ACTION_MODIFIED++-- | If the kernel event buffer overflows, entire contents of the buffer are+-- discarded, therefore, events are lost. The user application must scan+-- everything under the watched paths to know the current state of the file+-- system tree.+--+-- /Pre-release/+--+isEventsLost :: Event -> Bool+isEventsLost Event{..} = totalBytes == 0++-------------------------------------------------------------------------------+-- Debugging+-------------------------------------------------------------------------------++-- | Convert an 'Event' record to a String representation.+showEvent :: Event -> String+showEvent ev@Event{..} =+ "--------------------------"+ ++ "\nRoot = " ++ Path.toString (getRoot ev)+ ++ "\nPath = " ++ Path.toString (getRelPath ev)+ ++ "\ngetAbsPath = " ++ Path.toString (getAbsPath ev)+ ++ "\nFlags " ++ show eventFlags+ ++ showev isEventsLost "Overflow"+ ++ showev isCreated "Created"+ ++ showev isDeleted "Deleted"+ ++ showev isModified "Modified"+ ++ showev isMovedFrom "MovedFrom"+ ++ showev isMovedTo "MovedTo"+ ++ "\n"++ where showev f str = if f ev then "\n" ++ str else ""
+ src/config.h.in view
@@ -0,0 +1,43 @@+/* src/config.h.in. Generated from configure.ac by autoheader. */++/* Define to 1 if you have the declaration of `IN_EXCL_UNLINK', and to 0 if+ you don't. */+#undef HAVE_DECL_IN_EXCL_UNLINK++/* Define to 1 if you have the declaration of `IN_MASK_CREATE', and to 0 if+ you don't. */+#undef HAVE_DECL_IN_MASK_CREATE++/* Define to 1 if you have the declaration of+ `kFSEventStreamCreateFlagFileEvents', and to 0 if you don't. */+#undef HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFILEEVENTS++/* Define to 1 if you have the declaration of+ `kFSEventStreamCreateFlagFullHistory', and to 0 if you don't. */+#undef HAVE_DECL_KFSEVENTSTREAMCREATEFLAGFULLHISTORY++/* Define to 1 if you have the declaration of+ `kFSEventStreamEventFlagItemCloned', and to 0 if you don't. */+#undef HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMCLONED++/* Define to 1 if you have the declaration of+ `kFSEventStreamEventFlagItemIsHardlink', and to 0 if you don't. */+#undef HAVE_DECL_KFSEVENTSTREAMEVENTFLAGITEMISHARDLINK++/* Define to the address where bug reports for this package should be sent. */+#undef PACKAGE_BUGREPORT++/* Define to the full name of this package. */+#undef PACKAGE_NAME++/* Define to the full name and version of this package. */+#undef PACKAGE_STRING++/* Define to the one symbol short name of this package. */+#undef PACKAGE_TARNAME++/* Define to the home page for this package. */+#undef PACKAGE_URL++/* Define to the version of this package. */+#undef PACKAGE_VERSION
+ streamly-fsevents.cabal view
@@ -0,0 +1,288 @@+cabal-version: 2.2+name: streamly-fsevents+version: 0.1.0+synopsis: File system event notification API+description: File system event notification API++homepage: https://streamly.composewell.com+bug-reports: https://github.com/composewell/streamly/issues+license: BSD-3-Clause+license-file: LICENSE+tested-with: GHC==8.6.5+ , GHC==8.8.4+ , GHC==8.10.7+ , GHC==9.0.2+ , GHC==9.2.8+ , GHC==9.4.7+ , GHC==9.6.3+ , GHC==9.8.1+author: Composewell Technologies+maintainer: streamly@composewell.com+copyright: 2017 Composewell Technologies+category:+ Streamly, Concurrency, Streaming, Dataflow, Pipes, Reactivity, List,+ Logic, Non-determinism, Parsing, Array, Time, Unicode, Filesystem,+ Network+stability: Stable+build-type: Configure++extra-source-files:+ README.md+ configure+ configure.ac+ src/Streamly/Internal/FS/Event/Darwin.h+ src/config.h.in++extra-doc-files:+ Changelog.md++extra-tmp-files:+ config.log+ config.status+ autom4te.cache+ src/config.h++source-repository head+ type: git+ location: https://github.com/composewell/streamly++flag fusion-plugin+ description: Enable fusion plugin+ manual: True+ default: False++flag internal-dev+ description: Development build+ manual: True+ default: False++flag opt+ description: off=GHC default, on=-O2+ manual: True+ default: True++flag limit-build-mem+ description: Limits memory when building+ manual: True+ default: False++-------------------------------------------------------------------------------+-- Common stanzas+-------------------------------------------------------------------------------++common compile-options+ default-language: Haskell2010++ if os(darwin)+ cpp-options: -DCABAL_OS_DARWIN++ if os(linux)+ cpp-options: -DCABAL_OS_LINUX++ if os(windows)+ cpp-options: -DCABAL_OS_WINDOWS++ if flag(internal-dev)+ cpp-options: -DDEVBUILD++ ghc-options: -Weverything+ -Wno-implicit-prelude+ -Wno-missing-deriving-strategies+ -Wno-missing-exported-signatures+ -Wno-missing-import-lists+ -Wno-missing-local-signatures+ -Wno-missing-safe-haskell-mode+ -Wno-missed-specialisations+ -Wno-all-missed-specialisations+ -Wno-monomorphism-restriction+ -Wno-prepositive-qualified-module+ -Wno-unsafe+ -Rghc-timing++ if impl(ghc >= 9.2)+ ghc-options:+ -Wno-missing-kind-signatures+ -Wno-redundant-bang-patterns+ -Wno-operator-whitespace++ if impl(ghc >= 9.8)+ ghc-options:+ -Wno-missing-role-annotations++ if flag(internal-dev)+ ghc-options: -Wmissed-specialisations+ -Wall-missed-specialisations++ if flag(limit-build-mem)+ ghc-options: +RTS -M1000M -RTS++common default-extensions+ default-extensions:+ BangPatterns+ ConstraintKinds+ DeriveDataTypeable+ DeriveGeneric+ DeriveTraversable+ ExistentialQuantification+ FlexibleContexts+ FlexibleInstances+ GeneralizedNewtypeDeriving+ InstanceSigs+ KindSignatures+ MultiParamTypeClasses+ RankNTypes+ ScopedTypeVariables+ TupleSections+ TypeApplications+ TypeOperators++ -- Not GHC2021+ CApiFFI+ CPP+ LambdaCase+ MagicHash+ RecordWildCards++ -- TypeFamilies -- required by IsHashMap type class+ -- MonoLocalBinds, enabled by TypeFamilies, causes performance+ -- regressions. Disable it. This must come after TypeFamilies,+ -- otherwise TypeFamilies will enable it again.+ -- NoMonoLocalBinds++ -- UndecidableInstances -- Does not show any perf impact+ -- UnboxedTuples -- interferes with (#.)++common optimization-options+ if flag(opt)+ ghc-options: -O2+ -fdicts-strict+ -fspec-constr-recursive=16+ -fmax-worker-args=16++ -- For this to be effective it must come after the -O2 option+ if flag(internal-dev) || !flag(opt)+ ghc-options: -fno-ignore-asserts++ if flag(fusion-plugin)+ ghc-options: -fplugin Fusion.Plugin+++common threading-options+ ghc-options: -threaded+ -with-rtsopts=-N++-- We need optimization options here to optimize internal (non-inlined)+-- versions of functions. Also, we have some benchmarking inspection tests+-- part of the library when built with --benchmarks flag. Thos tests fail+-- if we do not use optimization options here. It was observed that due to+-- -O2 here some concurrent/nested benchmarks improved and others regressed.+-- We can investigate a bit more here why the regression occurred.+common lib-options+ import: compile-options, optimization-options, default-extensions++common test-options+ import: lib-options+ , threading-options+ ghc-options: -rtsopts -fno-ignore-asserts+ hs-source-dirs: test+ build-depends: streamly-core+ , streamly+ , streamly-fsevents+ , base+ , hspec+ , directory+ , filepath+ , temporary+ if flag(fusion-plugin)+ build-depends:+ fusion-plugin >= 0.2 && < 0.3++-------------------------------------------------------------------------------+-- Library+-------------------------------------------------------------------------------++library+ import: lib-options++ if impl(ghc >= 8.6)+ default-extensions: QuantifiedConstraints++ include-dirs: src++ hs-source-dirs: src++ if os(windows)+ exposed-modules: Streamly.Internal.FS.Event.Windows++ if os(darwin)+ include-dirs: src/Streamly/Internal+ c-sources: src/Streamly/Internal/FS/Event/Darwin.c+ exposed-modules: Streamly.Internal.FS.Event.Darwin++ if os(linux)+ exposed-modules: Streamly.Internal.FS.Event.Linux++ if os(linux) || os(darwin) || os(windows)+ exposed-modules: Streamly.FileSystem.Event+ Streamly.Internal.FS.Event++ build-depends:+ base >= 4.12 && < 4.22+ , streamly-core == 0.3.0++ if flag(fusion-plugin)+ build-depends:+ fusion-plugin >= 0.2 && < 0.3++ -- For FS.Event module+ if os(linux)+ build-depends: directory >= 1.2.2 && < 1.4+ , containers >= 0.6.0 && < 0.8++ if os(windows)+ build-depends: Win32 >= 2.6 && < 2.15+ , streamly == 0.11.0++ if os(darwin)+ build-depends: mtl >= 2.2.2 && < 2.4+ frameworks: Cocoa+++test-suite FileSystem.Event+ import: test-options+ type: exitcode-stdio-1.0+ ghc-options: -main-is Streamly.Test.FileSystem.Event+ main-is: Streamly/Test/FileSystem/Event.hs+ other-modules: Streamly.Test.FileSystem.Event.Common+ if !((os(linux) && impl(ghc >= 9.4)) || os(darwin) || os(windows))+ buildable: False++test-suite FileSystem.Event.Darwin+ import: test-options+ type: exitcode-stdio-1.0+ main-is: Streamly/Test/FileSystem/Event/Darwin.hs+ other-modules: Streamly.Test.FileSystem.Event.Common+ cpp-options: -DFILESYSTEM_EVENT_DARWIN+ ghc-options: -main-is Streamly.Test.FileSystem.Event.Darwin+ if !os(darwin)+ buildable: False++test-suite FileSystem.Event.Linux+ import: test-options+ type: exitcode-stdio-1.0+ main-is: Streamly/Test/FileSystem/Event/Linux.hs+ other-modules: Streamly.Test.FileSystem.Event.Common+ cpp-options: -DFILESYSTEM_EVENT_LINUX+ ghc-options: -main-is Streamly.Test.FileSystem.Event.Linux+ if impl(ghc < 9.4) || !os(linux)+ buildable: False++test-suite FileSystem.Event.Windows+ import: test-options+ type: exitcode-stdio-1.0+ main-is: Streamly/Test/FileSystem/Event/Windows.hs+ other-modules: Streamly.Test.FileSystem.Event.Common+ cpp-options: -DFILESYSTEM_EVENT_WINDOWS+ ghc-options: -main-is Streamly.Test.FileSystem.Event.Windows+ if !os(windows)+ buildable: False
+ test/Streamly/Test/FileSystem/Event.hs view
@@ -0,0 +1,28 @@+-- |+-- Module : Streamly.Test.FileSystem.Event+-- Copyright : (c) 2021 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : experimental+-- Portability : GHC+--++module Streamly.Test.FileSystem.Event (main) where++import qualified Streamly.Internal.FS.Event as Event+import Streamly.Test.FileSystem.Event.Common++moduleName :: String+moduleName = "FS.Event"++main :: IO ()+main = do+ let run = runTests moduleName "non-recursive" Event.watch+ run DirType commonTests+ run+#if defined(CABAL_OS_DARWIN)+ SymLinkResolvedPath+#else+ SymLinkOrigPath+#endif+ commonTests
+ test/Streamly/Test/FileSystem/Event/Common.hs view
@@ -0,0 +1,437 @@+{-# OPTIONS_GHC -Wno-deprecations #-}++-- |+-- Module : Streamly.Test.FileSystem.Event.Common+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : experimental+-- Portability : GHC+--+module Streamly.Test.FileSystem.Event.Common+ ( TestDesc++ -- * Running tests+ , runTests+ , WatchRootType (..)++ -- * Event predicates+ , dirEvent+ , fileEvent++ -- * Tests+ , dirCreate+ , dirCreateWithParent+ , dirDelete+ , dirMove+ , rootDirMove++ , fileCreate+ , fileCreateWithParent+ , fileDelete+ , fileModify+ , fileMove+ , rootFileMove++ , commonTests+ , commonRecTests+ )++where++import Debug.Trace (trace)+import Control.Concurrent (MVar, newEmptyMVar, putMVar, takeMVar, threadDelay)+import Control.Monad (when)+import Data.Bifunctor (first)+import Data.Function ((&))+import Data.List.NonEmpty (NonEmpty)+import System.Directory+ ( createDirectory+ , createDirectoryIfMissing+ , createDirectoryLink+ , doesDirectoryExist+ , doesFileExist+ , removeFile+ , removePathForcibly+ , renameDirectory+ , renamePath+ )+import System.FilePath ((</>), takeDirectory)+import System.IO+ ( BufferMode(..), hSetBuffering, stdout, IOMode (WriteMode), openFile+ , hClose)+import System.IO.Temp (withSystemTempDirectory)+import Streamly.Internal.FileSystem.Path (Path)++import qualified Data.List.NonEmpty as NonEmpty+import qualified Streamly.Internal.Data.Stream as Stream+import qualified Streamly.Internal.Data.Stream.Prelude as Stream+import qualified Streamly.Internal.FileSystem.Path as Path++#if defined(FILESYSTEM_EVENT_LINUX)+import Streamly.Internal.FS.Event.Linux (Event)+import qualified Streamly.Internal.FS.Event.Linux as Event+#elif defined(FILESYSTEM_EVENT_DARWIN)+import Streamly.Internal.FS.Event.Darwin (Event)+import qualified Streamly.Internal.FS.Event.Darwin as Event+#elif defined(FILESYSTEM_EVENT_WINDOWS)+import Streamly.Internal.FS.Event.Windows (Event)+import qualified Streamly.Internal.FS.Event.Windows as Event+#else+import Streamly.Internal.FS.Event (Event)+import qualified Streamly.Internal.FS.Event as Event+#endif++import Test.Hspec++-------------------------------------------------------------------------------+-- Check generated events+-------------------------------------------------------------------------------++type EventChecker =+ FilePath -- watch root+ -> FilePath -- watch target, target dir if root is a symlink+ -> MVar () -- mvar to sync file system ops and the watch+ -> [(String, Event -> Bool)] -- expected events+ -> IO ()+type EventWatcher = NonEmpty Path -> Stream.Stream IO Event.Event++eventMatches :: Event -> (String, Event -> Bool) -> Bool+eventMatches ev (expectedPath, f) =+ trace ("paths: " ++ show evPath ++ " " ++ show expectedPath)+ (evPath == expectedPath && f ev)++ where++ evPath = Path.toString (Event.getAbsPath ev)++checkEvents :: EventWatcher -> EventChecker+checkEvents watcher rootPath targetPath mvar matchList = do+ putStrLn ("Watching on root [" <> rootPath+ <> "] for [" <> targetPath <> "]")++ let matchList1 = fmap (first (targetPath </>)) matchList+ finder xs ev = filter (not . eventMatches ev) xs++ paths <- mapM Path.fromString [rootPath]+ watcher (NonEmpty.fromList paths)+ & Stream.before (putMVar mvar ())+ & Stream.trace (putStrLn . Event.showEvent)+ & Stream.scanl' finder matchList1+ & Stream.takeWhile (not . null)+ & Stream.drain++-------------------------------------------------------------------------------+-- Run tests+-------------------------------------------------------------------------------++type TestDesc =+ ( String -- test description+ , FilePath -> IO () -- pre test operation, arg is path of the watch root.+ , FilePath -> IO () -- file system action, arg is path of the watch root.+ , [(String, Event -> Bool)] -- expected events (Absolute Path, predicate)+ )++-- | Whether watch root is a symlink and if so then what's the behavior+data WatchRootType =+ DirType -- watch root is a directory+ | FileType -- watch root is a file+ | SymLinkResolvedPath -- symlink to a directory,+ -- Event contains path via the resolved dir+ | SymLinkOrigPath -- symlink to a directory,+ -- Event contains path via the original symlink+ deriving Show++driver :: EventChecker -> WatchRootType -> TestDesc -> SpecWith ()+driver checker symlinkStyle (desc, pre, ops, expected) =+ it desc $ runOneTest `shouldReturn` ()++ where++ fseventDir :: String+ fseventDir = "fsevent_dir"++ runOneTest = do+ sync <- newEmptyMVar+ withSystemTempDirectory fseventDir $ \fp -> do+ let root = fp </> "watch-root"+ target <-+ case symlinkStyle of+ DirType -> do+ createDirectory root+ return root+ FileType -> do+ openFile root WriteMode >>= hClose+ return root+ SymLinkResolvedPath -> do+ -- root -> target+ let tgt = fp </> "watch-root-real"+ createDirectory tgt+ createDirectoryLink tgt root+ return tgt+ SymLinkOrigPath -> do+ -- root -> target+ let tgt = fp </> "watch-root-real"+ createDirectory tgt+ createDirectoryLink tgt root+ return root++ -- XXX On macOS we seem to get the watch root create events+ -- even though they occur before the watch is started. Even if+ -- we add a delay here.+ startWatchAndCheck root target sync++ startWatchAndCheck root target sync = do+ putStrLn ("Before pre op: root [" <> root+ <> "] target [" <> target <> "]")+ pre root+ putStrLn ("After pre op: root [" <> root+ <> "] target [" <> target <> "]")+ -- XXX On macOS the events from pre ops also seem to be bundled+ -- with the events occurred after the watch is started.+ let check = checker root target sync expected+ fsOps = Stream.fromEffect $ runFSOps root sync+ Stream.drain+ $ Stream.parListEagerFst [Stream.fromEffect check, fsOps]++ runFSOps fp sync = do+ -- We put the MVar before the event watcher starts to run but that does+ -- not ensure that the event watcher has actually started. So we need a+ -- delay as well. Do we?+ takeMVar sync >> threadDelay 200000+ putStrLn ("Before fs ops: root [" <> fp)+ ops fp+ putStrLn ("After fs ops: root [" <> fp)+ threadDelay 10000000+ error $ fp <> ": Time out occurred before event watcher could terminate"++-------------------------------------------------------------------------------+-- Test descriptions+-------------------------------------------------------------------------------++dirEvent, fileEvent :: (Event -> Bool) -> Event -> Bool++#if defined(FILESYSTEM_EVENT_DARWIN)+dirEvent f ev = Event.isDir ev && f ev+fileEvent f ev = Event.isFile ev && f ev+#elif defined(FILESYSTEM_EVENT_LINUX)+dirEvent f ev = Event.isDir ev && f ev+fileEvent f ev = not (Event.isDir ev) && f ev+#else+dirEvent = id+fileEvent = id+#endif++-- XXX Tests for root as a regular file instead of dir?+-- XXX Add symlink and hardlink tests+-- XXX Add exception condition tests++-------------------------------------------------------------------------------+-- Dir tests+-------------------------------------------------------------------------------++createParent :: FilePath -> FilePath -> IO ()+createParent file parent = do+ createDirectoryIfMissing True (takeDirectory (parent </> file))++createDirWithParent :: FilePath -> FilePath -> IO ()+createDirWithParent dir parent =+ when (not (null dir)) $ createDirectoryIfMissing True (parent </> dir)++createDir :: FilePath -> FilePath -> IO ()+createDir dir parent =+ when (not (null dir)) $ createDirectory (parent </> dir)++-- | Create the dir along with its parent dir during the test. This is+-- especially useful to detect a race in Linux case where the watch for a+-- directory is added in event processing, so if the the child directory is+-- created before the watch was installed then we may miss some events.+dirCreateWithParent ::+ String -> (String -> [([Char], Event -> Bool)]) -> TestDesc+dirCreateWithParent dir events =+ ( "dir created (" ++ dir ++ ")"+ , const (return ())+ , createDirWithParent dir+ , events dir+ )++dirCreate :: String -> (String -> [([Char], Event -> Bool)]) -> TestDesc+dirCreate dir events =+ ( "dir created (" ++ dir ++ ")"+ , createParent dir+ , createDir dir+ , events dir+ )++dirDelete :: String -> (String -> [([Char], Event -> Bool)]) -> TestDesc+dirDelete dir events =+ ( "dir deleted (" ++ dir ++ ")"+ , createDirWithParent dir+ , \fp -> removePathForcibly (fp </> dir)+ , events dir+ )++dirMove ::+ String+ -> String+ -> (String -> String -> [(String, Event -> Bool)])+ -> TestDesc+dirMove dir1 dir2 events =+ ( "dir moved (" ++ dir1 ++ " " ++ dir2 ++ ")"+ , createDirWithParent dir1+ , \fp -> renameDirectory (fp </> dir1) (fp </> dir2)+ , events dir1 dir2+ )++rootDirMove ::+ String+ -> (String -> [(String, Event -> Bool)])+ -> TestDesc+rootDirMove suffix events =+ ( "root dir moved" ++ "(" ++ suffix ++ ")"+ , const (return ())+ , \fp -> renameDirectory fp (fp <> suffix)+ , events ""+ )++-------------------------------------------------------------------------------+-- File tests+-------------------------------------------------------------------------------++createFileWithParent :: FilePath -> FilePath -> IO ()+createFileWithParent file parent = do+ let filepath = parent </> file+ let dir = takeDirectory filepath+ putStrLn $ "createFileWithParent: file ["+ ++ file ++ "] dir [" ++ dir ++ "]"+ putStrLn $ "Ensuring dir: " ++ dir+ createDirectoryIfMissing True dir+ r <- doesDirectoryExist dir+ if r+ then do+ putStrLn $ "Ensured dir: " ++ dir+ when (not (null file)) $ do+ exists <- doesFileExist filepath+ if not exists+ then do+ putStrLn $ "Creating file: " ++ (parent </> file)+ openFile (parent </> file) WriteMode >>= hClose+ putStrLn $ "Created file: " ++ (parent </> file)+ else error $ "File exists: " ++ filepath+ else error $ "Could not create dir: " ++ dir++createFile :: FilePath -> FilePath -> IO ()+createFile file parent =+ openFile (parent </> file) WriteMode >>= hClose++fileCreate :: String -> (String -> [(String, Event -> Bool)]) -> TestDesc+fileCreate file1 events =+ ( "File created (" ++ file1 ++ ")"+ , createParent file1+ , createFile file1+ , (file1, fileEvent Event.isCreated) : events file1+ )++-- | See comments in dirCreateWithParent+fileCreateWithParent ::+ String -> (String -> [(String, Event -> Bool)]) -> TestDesc+fileCreateWithParent file1 events =+ ( "File created (" ++ file1 ++ ")"+ , const (return ())+ , createFileWithParent file1+ , (file1, fileEvent Event.isCreated) : events file1+ )++fileDelete :: String -> (String -> [(String, Event -> Bool)]) -> TestDesc+fileDelete file1 events =+ ( "File deleted (" ++ file1 ++ ")"+ , createFileWithParent file1+ , \fp -> removeFile (fp </> file1)+ , events file1+ )++fileModify :: String -> (String -> [(String, Event -> Bool)]) -> TestDesc+fileModify file1 events =+ ( "File modified (" ++ file1 ++ ")"+ , createFileWithParent file1+ , \fp -> writeFile (fp </> file1) "Test Data"+ , (file1, fileEvent Event.isModified) : events file1+ )++fileMove ::+ String+ -> String+ -> (String -> String -> [(String, Event -> Bool)])+ -> TestDesc+fileMove file1 file2 events =+ ( "File moved (" ++ file1 ++ " " ++ file2 ++ ")"+ , createFileWithParent file1+ , \fp -> renamePath (fp </> file1) (fp </> file2)+ , (file1, fileEvent Event.isMoved)+ : (file2, fileEvent Event.isMoved)+ : events file1 file2+ )++rootFileMove :: String -> (String -> [(String, Event -> Bool)]) -> TestDesc+rootFileMove suffix events =+ ( "File moved (" ++ suffix ++ ")"+ , const (return ())+ , \fp -> renamePath fp (fp <> suffix)+ , events ""+ )++-------------------------------------------------------------------------------+-- Common test bundles+-------------------------------------------------------------------------------++withParent :: [Char] -> [Char] -> [Char]+withParent parent file = if null parent then file else parent </> file++testsWithParent :: String -> [TestDesc]+testsWithParent p =+ [ dirCreate+ (withParent p "dir") (\dir -> [(dir, dirEvent Event.isCreated)])+ , dirDelete+ (withParent p "dir") (\dir -> [(dir, dirEvent Event.isDeleted)])+ , dirMove+ (withParent p "dir1")+ (withParent p "dir2")+ (\dir1 dir2 ->+ [ (dir1, dirEvent Event.isMoved)+ , (dir2, dirEvent Event.isMoved)+ ]+ )+ , fileCreate (withParent p "file1") (const [])+ , fileDelete+ (withParent p "file1")+ (\file -> [(file, fileEvent Event.isDeleted)])+ , fileModify (withParent p "file1") (const [])+ , fileMove (withParent p "file1") (withParent p "file2") (\_ _ -> [])+ ]++commonTests :: [TestDesc]+commonTests = testsWithParent ""++commonRecTests :: [TestDesc]+commonRecTests = testsWithParent "subdir"++-------------------------------------------------------------------------------+-- Running tests+-------------------------------------------------------------------------------++runTests ::+ String+ -> String+ -> EventWatcher+ -> WatchRootType+ -> [TestDesc]+ -> IO ()+runTests modName watchType watcher rootType tests = do+ hSetBuffering stdout NoBuffering+ hspec+ $ describe modName+ $ describe watchType+ $ do+ let checker = checkEvents watcher+ describe ("Root type " ++ show rootType)+ $ mapM_ (driver checker rootType) tests
+ test/Streamly/Test/FileSystem/Event/Darwin.hs view
@@ -0,0 +1,86 @@+-- |+-- Module : Streamly.Test.FileSystem.Event.Darwin+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : experimental+-- Portability : GHC+--+module Streamly.Test.FileSystem.Event.Darwin (main) where++import qualified Streamly.Internal.FS.Event.Darwin as Event++import Streamly.Test.FileSystem.Event.Common++moduleName :: String+moduleName = "FS.Event.Darwin"++-- TODO:+-- Creation/deletion/move of hard links+-- Deletion of last hard link+-- If a directory is a symlink is it followed in recursive mode?++main :: IO ()+main = do+ let symLinkRootTests =+ dirCreateWithParent "subdir/dir"+ (\dir -> [(dir, dirEvent Event.isCreated)])+ : fileCreateWithParent "subdir/file"+ (\file ->+ [ (file, fileEvent Event.isCreated)+ , (file, fileEvent Event.isAttrsModified)+ ]+ )+ : fileCreate "file-create-attrs"+ (\file ->+ [ (file, fileEvent Event.isCreated)+ , (file, fileEvent Event.isAttrsModified)+ ]+ )+ : fileModify+ "file-mod-attrs"+ (\file -> [(file, fileEvent Event.isAttrsModified)])+ : dirDelete "dir-sec" (\dir ->+ [ (dir, dirEvent Event.isDeleted)+ , (dir, dirEvent Event.isSecurityModified)+ ]+ )+ : commonTests+ ++ commonRecTests+ let regularRootTests =+ dirDelete "" (\dir ->+ [ (dir, dirEvent Event.isDeleted)+ , (dir, dirEvent Event.isSecurityModified)+ , (dir, Event.isRootPathEvent)+ ]+ )+ -- The watch root create event always seems to come even though the+ -- root is created before the watch is started. That may be because+ -- of batching?+ -- XXX Need to create watch root after adding the watch, otherwise+ -- it fails intermittently.+ -- : dirCreate "" (\dir -> [(dir, dirEvent Event.isCreated)])+ : rootDirMove "moved" (\src ->+ [ (src, Event.isRootPathEvent)+ , (src, Event.isMoved)+ ])+ : symLinkRootTests++ let fileRootTests =+ [ fileDelete "" (\path ->+ [ (path, Event.isRootPathEvent)+ , (path, Event.isDeleted)+ ])+ , rootFileMove "moved" (\path ->+ [(path, Event.isRootPathEvent)+ , (path, Event.isMoved)+ ])+ , fileModify "" (const [])+ ]++ let w = Event.watchWith (Event.setAllEvents True)+ run = runTests moduleName "recursive" w++ run DirType regularRootTests+ run SymLinkResolvedPath symLinkRootTests+ run FileType fileRootTests
+ test/Streamly/Test/FileSystem/Event/Linux.hs view
@@ -0,0 +1,208 @@+-- |+-- Module : Streamly.Test.FileSystem.Event.Linux+-- Copyright : (c) 2020 Composewell Technologies+-- License : BSD-3-Clause+-- Maintainer : streamly@composewell.com+-- Stability : experimental+-- Portability : GHC+--+module Streamly.Test.FileSystem.Event.Linux (main) where++import Streamly.Internal.FS.Event.Linux (Event)+-- #if __GLASGOW_HASKELL__ == 902+#if 0+import qualified Data.List as List+#endif+import qualified Streamly.Internal.FS.Event.Linux as Event++import Streamly.Test.FileSystem.Event.Common++#define DEVBUILD++moduleName :: String+moduleName = "FS.Event.Linux"++dirTouchEvents :: String -> [([Char], Event -> Bool)]+dirTouchEvents dir =+ [ (dir, dirEvent Event.isOpened)+ , (dir, dirEvent Event.isAccessed)+ , (dir, dirEvent Event.isNonWriteClosed)+ ]++dirDelEvents :: String -> [([Char], Event -> Bool)]+dirDelEvents dir =+ (dir, dirEvent Event.isDeleted)+ : (dir, dirEvent Event.isAttrsModified)+ : dirTouchEvents dir++rootDirDelEvents :: String -> [([Char], Event -> Bool)]+rootDirDelEvents root =+ (root, Event.isRootUnwatched)+ : (root, Event.isRootDeleted)+ : (root, dirEvent Event.isAttrsModified)+ : dirTouchEvents root++dirMoveEvents :: [Char] -> [Char] -> [([Char], Event -> Bool)]+dirMoveEvents src dst =+ [ (src, dirEvent Event.isMoved)+ , (src, dirEvent Event.isMovedFrom)+ , (dst, dirEvent Event.isMoved)+ , (dst, dirEvent Event.isMovedTo)+ ]++#ifdef DEVBUILD+-- In recursive mode all subdirectories are roots therefore they will generate+-- isRootMoved.+rootDirMoveEvents :: [Char] -> [Char] -> [([Char], Event -> Bool)]+rootDirMoveEvents root _ =+ (root, Event.isRootMoved)+ : dirTouchEvents root++recDirMoveEvents :: [Char] -> [Char] -> [([Char], Event -> Bool)]+recDirMoveEvents src dst = dirMoveEvents src dst ++ rootDirMoveEvents src dst+#endif++fileTouchEvents :: String -> [([Char], Event -> Bool)]+fileTouchEvents file =+ [ (file, fileEvent Event.isOpened)+ , (file, fileEvent Event.isModified)+ , (file, fileEvent Event.isWriteClosed)+ ]++fileMoveEvents :: [Char] -> [Char] -> [([Char], Event -> Bool)]+fileMoveEvents src dst =+ [ (src, fileEvent Event.isMoved)+ , (src, fileEvent Event.isMovedFrom)+ , (dst, fileEvent Event.isMoved)+ , (dst, fileEvent Event.isMovedTo)+ ]++-- TODO: add fileRoot tests from macOS test suite++main :: IO ()+main = do+ -- We ignore the events on root/parent dir during regular non-root dir/file+ -- tests.++ -- Tests common to regular root and symlink root cases+ let regSymTests =+ fileCreate "file" fileTouchEvents+ : fileMove "file1" "file2" fileMoveEvents+ : dirMove "dir1" "dir2" dirMoveEvents+ : dirDelete "dir" dirDelEvents+ : commonTests++ let regTests =+ dirDelete "" rootDirDelEvents+ : rootDirMove "moved" (\src -> [(src, Event.isRootMoved)])+ : regSymTests++ let symTests =+#if 0+ -- No events occur when a symlink root is moved. when root is a+ -- symlinked dir, it does not recv touch, isDeleted or+ -- rootDeleted, rootUnwatched events. We are not seeing+ -- isAttrModified event as well, so disabling this altogether.+ dirDelete "" (\dir -> [(dir, dirEvent Event.isAttrsModified)])+ :+#endif+ regSymTests++ let w = Event.watchWith (Event.setAllEvents True)+ run = runTests moduleName "non-recursive" w++#if 0+ let failingTests =+ [ "File deleted (file1)"+ , "File modified (file1)"+ , "File moved (file1 file2)"+ ]+#endif++ run DirType+#if 0+ $ filter (\(desc, _, _, _) -> desc `List.notElem` failingTests)+#endif+ regTests++ run SymLinkOrigPath+#if 0+ $ filter (\(desc, _, _, _) -> desc `List.notElem` failingTests)+#endif+ symTests++ let fileRootTests =+ [ fileDelete "" (\path ->+ [ (path, Event.isAttrsModified)+ , (path, Event.isRootDeleted)+ , (path, Event.isRootUnwatched)+ ])+ , rootFileMove "moved" (\path -> [(path, Event.isRootMoved)])+ , fileModify "" (\path -> [(path, Event.isOpened)])+ ]++ run FileType fileRootTests++ let recw = Event.watchWith+ (Event.setAllEvents True . Event.setRecursiveMode True)+ runRec = runTests moduleName "recursive" recw++#ifdef DEVBUILD+ -- In recursive mode all subdirectories are roots therefore they will+ -- generate isRootDeleted/isRootUnwatched. Also, for subdirectories+ -- multiple events are generated, once in the parent watch and once in the+ -- self watch as a root of the watch. Therefore, additional touchEvents are+ -- generated in this case.+ --+ -- XXX We can possibly filter out the duplicate events either from the+ -- parent or self.+ let regSymRecTests =+ -- XXX Nested file create misses the create event due to a race+ -- : fileCreateWithParent "subdir/file" fileTouchEvents+ fileCreate "subdir/file" fileTouchEvents+ : fileMove "subdir/file1" "subdir/file2" fileMoveEvents+ : dirMove "dir1" "dir2" recDirMoveEvents+ : dirMove "subdir/dir1" "subdir/dir2" recDirMoveEvents+ : dirDelete "dir" (\d -> rootDirDelEvents d ++ dirDelEvents d)+ : dirDelete "subdir/dir" (\d -> rootDirDelEvents d ++ dirDelEvents d)+ -- XXX Nested dir create misses the create event due to a race+ -- : dirCreateWithParent "subdir/dir" dirTouchEvents+ : dirCreate "subdir/dir"+ (\dir -> (dir, dirEvent Event.isCreated) : dirTouchEvents dir)+ : dirCreate "dir"+ (\dir -> (dir, dirEvent Event.isCreated) : dirTouchEvents dir)+ : commonRecTests+ recRegTests = regTests ++ regSymRecTests+ recSymTests = symTests ++ regSymRecTests++ -- XXX these tests fails intermittently for recursive case+ -- FS.Event.Linux.recursive, Root type SymLinkOrigPath, File deleted (subdir/file1)+ -- FS.Event.Linux.recursive, Root type SymLinkOrigPath, File modified (subdir/file1)+ -- FS.Event.Linux.recursive, Root type SymLinkOrigPath, File moved (subdir/file1 subdir/file2)+ -- FS.Event.Linux.recursive, Root type DirType, File moved (file1 file2)+ -- FS.Event.Linux.recursive, Root type DirType, File created (file)+ -- uncaught exception: IOException of type ResourceBusy+ -- /tmp/fsevent_dir-a5bd0df64c44ab27/watch-root/file: openFile: resource busy (file is locked)++#if 0+ let failingRecTests = failingTests +++ [ "File created (subdir/file)"+ , "File deleted (subdir/file1)"+ , "File modified (subdir/file1)"+ , "File moved (subdir/file1 subdir/file2)"+ ]+#endif++ runRec DirType+#if 0+ $ filter (\(desc, _, _, _) -> desc `List.notElem` failingRecTests)+#endif+ recRegTests++ runRec SymLinkOrigPath+#if 0+ $ filter (\(desc, _, _, _) -> desc `List.notElem` failingRecTests)+#endif+ recSymTests+#endif+ runRec FileType fileRootTests
+ test/Streamly/Test/FileSystem/Event/Windows.hs view
@@ -0,0 +1,51 @@+-- | +-- Module : Streamly.Test.FileSystem.Event.Windows +-- Copyright : (c) 2020 Composewell Technologies +-- License : BSD-3-Clause +-- Maintainer : streamly@composewell.com +-- Stability : experimental +-- Portability : GHC +-- +module Streamly.Test.FileSystem.Event.Windows (main) where + +import qualified Streamly.Internal.FS.Event.Windows as Event +import Streamly.Test.FileSystem.Event.Common + +moduleName :: String +moduleName = "FS.Event.Windows" + +-- TODO Test isModified event for parent directories when a file is created or +-- deleted. + +main :: IO () +main = do + let regularRootTests = + commonTests + -- The following watch-root deletion test results in: + -- C:\tmp\fsevent_dir-e061f0b0a00e1696\watch-root: + -- removePathForcibly:RemoveDirectory + -- "\\\\?\\C:\\tmp\\fsevent_dir-e061f0b0a00e1696\\watch-root": + -- permission denied (The process cannot access the file because it is + -- being used by another process.) + -- + -- ++ dirDelete "" (\dir -> [(dir, Event.isDeleted)]) + + let w = Event.watchWith (Event.setAllEvents True) + run = runTests moduleName "non-recursive" w + + run DirType regularRootTests + run SymLinkOrigPath commonTests + + let recTests = + [ dirCreateWithParent "subdir\\dir" + (\dir -> [(dir, dirEvent Event.isCreated)]) + , fileCreateWithParent "subdir\\file" + (\file -> [(file, fileEvent Event.isCreated)]) + ] ++ commonRecTests + + let recw = Event.watchWith + (Event.setAllEvents True . Event.setRecursiveMode True) + runRec = runTests moduleName "recursive" recw + + runRec DirType (regularRootTests ++ recTests) + runRec SymLinkOrigPath (commonTests ++ recTests)