summaryrefslogtreecommitdiff
path: root/ghc/lib/std/cbits/renameFile.c
diff options
context:
space:
mode:
authorsimonmar <unknown>2001-01-11 17:25:59 +0000
committersimonmar <unknown>2001-01-11 17:25:59 +0000
commitefa881239effd5ea4cb403c2c03ebb09fbdfd363 (patch)
tree4df44109399eba37e4c7843115ceaf8d4f45614b /ghc/lib/std/cbits/renameFile.c
parente18bb2e86eb13bdb98cc0afc7c2aa8e56d98bcc7 (diff)
downloadhaskell-efa881239effd5ea4cb403c2c03ebb09fbdfd363.tar.gz
[project @ 2001-01-11 17:25:56 by simonmar]
Re-organisation of ghc/lib/std and hslibs/lang ---------------------------------------------- In brief: move deprecated features out of ghc/lib/std and into hslibs/lang, move new FFI libraries into ghc/lib/std and start using them. - foreign import may now return an unboxed type (this was advertised to work before, but in fact didn't). Subsequent cleanups in PrelInt/PrelWord. - Ptr is now defined in ghc/lib/std/PrelPtr.lhs. Ptr is no longer a newtype of Addr, it is defined directly in terms of Addr#. - PrelAddr has disappeared from ghc/lib/std, all uses of Addr in ghc/lib/std have been replaced with Ptr. The definitions of Addr has been moved to hslibs/lang/Addr.lhs, as has lots of other Addr-related stuff. - ForeignObj has been removed from ghc/lib/std, and replaced with ForeignPtr. The definition of ForeignObj has been moved to hslibs/lang/ForeignObj.lhs. - Most of the new FFI has been moved into ghc/lib/std in the form of modules PrelMarshalAlloc, PrelCString, PrelCError, PrelMarshalError, PrelMarshalArray, PrelMarshalUtils, PrelCTypes, PrelCTypesISO, and PrelStorable. The corresponding modules in hslibs/lang simply re-export the contents of these modules. - PrelPosixTypes defines a few POSIX types (CMode == mode_t, etc.) - PrelCError changed to access errno using foreign label and peek (the POSIX book I have says that errno is guaranteed to be an extern int, so this should be OK until I get around to making errno thread-safe). - Hacked the macros that generate the code for CTypes and CTypesISO to generate much less code (ghc/lib/std/cbits/CTypes.h). - RtsAPI is now a bit more honest when it comes to building heap objects (it uses the correct constructors). - the Bits class and related stuff has been moved to ghc/lib/std (it was simpler this way). - Directory and System have been converted to use the new FFI.
Diffstat (limited to 'ghc/lib/std/cbits/renameFile.c')
-rw-r--r--ghc/lib/std/cbits/renameFile.c84
1 files changed, 0 insertions, 84 deletions
diff --git a/ghc/lib/std/cbits/renameFile.c b/ghc/lib/std/cbits/renameFile.c
deleted file mode 100644
index 2126849a63..0000000000
--- a/ghc/lib/std/cbits/renameFile.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
- *
- * $Id: renameFile.c,v 1.8 2000/04/06 10:33:06 rrt Exp $
- *
- * renameFile Runtime Support
- */
-
-#include "Rts.h"
-#include "stgio.h"
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-
-StgInt
-renameFile(StgByteArray opath, StgByteArray npath)
-{
- struct stat sb;
-
- /* Check for a non-directory source */
- while (stat(opath, &sb) != 0) {
- if (errno != EINTR) {
- cvtErrno();
- stdErrno();
- return -1;
- }
- }
- if (S_ISDIR(sb.st_mode)) {
- ghc_errtype = ERR_INAPPROPRIATETYPE;
- ghc_errstr = "file is a directory";
- return -1;
- }
-
- /* Check for a non-directory destination */
- while (stat(npath, &sb) != 0 && errno != ENOENT) {
- if (errno != EINTR) {
- cvtErrno();
- stdErrno();
- return -1;
- }
- }
-
- if (errno != ENOENT) {
- if (S_ISDIR(sb.st_mode)) {
- ghc_errtype = ERR_INAPPROPRIATETYPE;
- ghc_errstr = "file is a directory";
- return -1;
- }
- while (chmod(npath, S_IWUSR) != 0) {
- if (errno != EINTR) {
- cvtErrno();
- stdErrno();
- return -1;
- }
- }
- while (unlink(npath) != 0) {
- if (errno != EINTR) {
- cvtErrno();
- stdErrno();
- return -1;
- }
- }
- }
-
- while(rename(opath, npath) != 0) {
- if (errno != EINTR) {
- cvtErrno();
- stdErrno();
- return -1;
- }
- }
-
- return 0;
-}