Language-Haskell
view release on metacpan or search on metacpan
hugs98-Nov2003/fptools/libraries/unix/System/Posix/Files_hsc_make.c view on Meta::CPAN
" withCString name1 $ \\s1 ->\n"
" withCString name2 $ \\s2 ->\n"
" throwErrnoIfMinus1_ \"createLink\" (c_link s1 s2)\n"
"\n"
"removeLink :: FilePath -> IO ()\n"
"removeLink name =\n"
" withCString name $ \\s ->\n"
" throwErrnoIfMinus1_ \"removeLink\" (c_unlink s)\n"
"\n"
"-- -----------------------------------------------------------------------------\n"
"-- Symbolic Links\n"
"\n"
"createSymbolicLink :: FilePath -> FilePath -> IO ()\n"
"createSymbolicLink file1 file2 =\n"
" withCString file1 $ \\s1 ->\n"
" withCString file2 $ \\s2 ->\n"
" throwErrnoIfMinus1_ \"createSymbolicLink\" (c_symlink s1 s2)\n"
"\n"
"foreign import ccall unsafe \"symlink\"\n"
" c_symlink :: CString -> CString -> IO CInt\n"
"\n"
"-- ToDo: should really use SYMLINK_MAX, but not everyone supports it yet,\n"
"-- and it seems that the intention is that SYMLINK_MAX is no larger than\n"
"-- PATH_MAX.\n"
"readSymbolicLink :: FilePath -> IO FilePath\n"
"readSymbolicLink file =\n"
" allocaArray0 (", stdout);
#line 353 "Files.hsc"
hsc_const (PATH_MAX);
fputs (") $ \\buf -> do\n"
"", stdout);
hsc_line (354, "Files.hsc");
fputs (" withCString file $ \\s -> do\n"
" len <- throwErrnoIfMinus1 \"readSymbolicLink\" $ \n"
"\tc_readlink s buf (", stdout);
#line 356 "Files.hsc"
hsc_const (PATH_MAX);
fputs (")\n"
"", stdout);
hsc_line (357, "Files.hsc");
fputs (" peekCStringLen (buf,fromIntegral len)\n"
"\n"
"foreign import ccall unsafe \"readlink\"\n"
" c_readlink :: CString -> CString -> CInt -> IO CInt\n"
"\n"
"-- -----------------------------------------------------------------------------\n"
"-- Renaming files\n"
"\n"
"rename :: FilePath -> FilePath -> IO ()\n"
"rename name1 name2 =\n"
" 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"
"setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()\n"
"setFileTimes name atime mtime = do\n"
" withCString name $ \\s ->\n"
" allocaBytes (", stdout);
#line 405 "Files.hsc"
hsc_const (sizeof(struct utimbuf));
fputs (") $ \\p -> do\n"
"", stdout);
hsc_line (406, "Files.hsc");
fputs (" (", stdout);
#line 406 "Files.hsc"
hsc_poke (struct utimbuf, actime);
fputs (") p atime\n"
"", stdout);
hsc_line (407, "Files.hsc");
fputs (" (", stdout);
#line 407 "Files.hsc"
hsc_poke (struct utimbuf, modtime);
fputs (") p mtime\n"
"", stdout);
hsc_line (408, "Files.hsc");
fputs (" throwErrnoIfMinus1_ \"setFileTimes\" (c_utime s p)\n"
"\n"
"touchFile :: FilePath -> IO ()\n"
"touchFile name = do\n"
" withCString name $ \\s ->\n"
" throwErrnoIfMinus1_ \"touchFile\" (c_utime s nullPtr)\n"
"\n"
"-- -----------------------------------------------------------------------------\n"
"-- Setting file sizes\n"
"\n"
"setFileSize :: FilePath -> FileOffset -> IO ()\n"
"setFileSize file off = \n"
" withCString file $ \\s ->\n"
" throwErrnoIfMinus1_ \"setFileSize\" (c_truncate s off)\n"
"\n"
"foreign import ccall unsafe \"truncate\"\n"
" c_truncate :: CString -> COff -> IO CInt\n"
"\n"
"setFdSize :: Fd -> FileOffset -> IO ()\n"
"setFdSize fd off =\n"
" throwErrnoIfMinus1_ \"setFdSize\" (c_ftruncate fd off)\n"
"\n"
"foreign import ccall unsafe \"ftruncate\"\n"
" c_ftruncate :: Fd -> COff -> IO CInt\n"
"\n"
"-- -----------------------------------------------------------------------------\n"
"-- pathconf()/fpathconf() support\n"
"\n"
"data PathVar\n"
( run in 0.493 second using v1.01-cache-2.11-cpan-71847e10f99 )