Language-Haskell
view release on metacpan or search on metacpan
hugs98-Nov2003/fptools/libraries/unix/System/Posix/Files.hsc view on Meta::CPAN
withCString name1 $ \s1 ->
withCString name2 $ \s2 ->
throwErrnoIfMinus1_ "rename" (c_rename s1 s2)
-- -----------------------------------------------------------------------------
-- chmod()
setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()
setOwnerAndGroup name uid gid = do
withCString name $ \s ->
throwErrnoIfMinus1_ "setOwnerAndGroup" (c_chown s uid gid)
foreign import ccall unsafe "chown"
c_chown :: CString -> CUid -> CGid -> IO CInt
setFdOwnerAndGroup :: Fd -> UserID -> GroupID -> IO ()
setFdOwnerAndGroup (Fd fd) uid gid =
throwErrnoIfMinus1_ "setFdOwnerAndGroup" (c_fchown fd uid gid)
foreign import ccall unsafe "fchown"
c_fchown :: CInt -> CUid -> CGid -> IO CInt
#if HAVE_LCHOWN
setSymbolicLinkOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()
setSymbolicLinkOwnerAndGroup name uid gid = do
withCString name $ \s ->
throwErrnoIfMinus1_ "setSymbolicLinkOwnerAndGroup" (c_lchown s uid gid)
foreign import ccall unsafe "lchown"
c_lchown :: CString -> CUid -> CGid -> IO CInt
#endif
-- -----------------------------------------------------------------------------
-- utime()
setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
setFileTimes name atime mtime = do
withCString name $ \s ->
allocaBytes (#const sizeof(struct utimbuf)) $ \p -> do
(#poke struct utimbuf, actime) p atime
hugs98-Nov2003/fptools/libraries/unix/System/Posix/Files_hsc_make.c view on Meta::CPAN
" withCString name1 $ \\s1 ->\n"
" withCString name2 $ \\s2 ->\n"
" throwErrnoIfMinus1_ \"rename\" (c_rename s1 s2)\n"
"\n"
"-- -----------------------------------------------------------------------------\n"
"-- chmod()\n"
"\n"
"setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()\n"
"setOwnerAndGroup name uid gid = do\n"
" withCString name $ \\s ->\n"
" throwErrnoIfMinus1_ \"setOwnerAndGroup\" (c_chown s uid gid)\n"
"\n"
"foreign import ccall unsafe \"chown\"\n"
" c_chown :: CString -> CUid -> CGid -> IO CInt\n"
"\n"
"setFdOwnerAndGroup :: Fd -> UserID -> GroupID -> IO ()\n"
"setFdOwnerAndGroup (Fd fd) uid gid = \n"
" throwErrnoIfMinus1_ \"setFdOwnerAndGroup\" (c_fchown fd uid gid)\n"
"\n"
"foreign import ccall unsafe \"fchown\"\n"
" c_fchown :: CInt -> CUid -> CGid -> IO CInt\n"
"\n"
"", stdout);
#line 389 "Files.hsc"
#if HAVE_LCHOWN
fputs ("\n"
"", stdout);
hsc_line (390, "Files.hsc");
fputs ("setSymbolicLinkOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()\n"
"setSymbolicLinkOwnerAndGroup name uid gid = do\n"
" withCString name $ \\s ->\n"
" throwErrnoIfMinus1_ \"setSymbolicLinkOwnerAndGroup\" (c_lchown s uid gid)\n"
"\n"
"foreign import ccall unsafe \"lchown\"\n"
" c_lchown :: CString -> CUid -> CGid -> IO CInt\n"
"", stdout);
#line 397 "Files.hsc"
#endif
fputs ("\n"
"", stdout);
hsc_line (398, "Files.hsc");
fputs ("\n"
"-- -----------------------------------------------------------------------------\n"
"-- utime()\n"
"\n"
hugs98-Nov2003/src/unix/install-sh view on Meta::CPAN
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd=""
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
hugs98-Nov2003/src/unix/install-sh view on Meta::CPAN
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
hugs98-Nov2003/src/unix/install-sh view on Meta::CPAN
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
hugs98-Nov2003/src/unix/install-sh view on Meta::CPAN
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
( run in 0.714 second using v1.01-cache-2.11-cpan-71847e10f99 )