X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=sbr%2Ffolder_addmsg.c;h=1a1c8b10fe3d6e2dda946a51068a7a4b18e65bb9;hb=eabbcb91ae4e824930e9d9c9a206e40f0bdaf61f;hp=f90cedfbae04504f4817e228a528a383dd7e0b6e;hpb=30fd2ad6d3eff3749b2ae99ec90d2215bf1b1aca;p=mmh diff --git a/sbr/folder_addmsg.c b/sbr/folder_addmsg.c index f90cedf..1a1c8b1 100644 --- a/sbr/folder_addmsg.c +++ b/sbr/folder_addmsg.c @@ -2,8 +2,6 @@ /* * folder_addmsg.c -- Link message into folder * - * $Id$ - * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. @@ -22,39 +20,30 @@ int folder_addmsg (struct msgs **mpp, char *msgfile, int selected, int unseen, int preserve, int deleting, char *from_dir) { - int infd, outfd, linkerr, first_time, msgnum; + int infd, outfd, linkerr, msgnum; char *nmsg, newmsg[BUFSIZ]; char oldmsg[BUFSIZ]; struct msgs *mp; struct stat st1, st2; - first_time = 1; /* this is first attempt */ mp = *mpp; + /* should we preserve the numbering of the message? */ + if (preserve && (msgnum = m_atoi (msgfile)) > 0) { + ; + } else if (mp->nummsg == 0) { + /* check if we are adding to empty folder */ + msgnum = 1; + } else { + /* else use highest message number + 1 */ + msgnum = mp->hghmsg + 1; + } + /* * We might need to make several attempts * in order to add the message to the folder. */ - for (;;) { - /* - * Get the message number we will attempt to add. - */ - if (first_time) { - /* should we preserve the numbering of the message? */ - if (preserve && (msgnum = m_atoi (msgfile)) > 0) { - ; - } else if (mp->nummsg == 0) { - /* check if we are adding to empty folder */ - msgnum = 1; - } else { - /* else use highest message number + 1 */ - msgnum = mp->hghmsg + 1; - } - first_time = 0; - } else { - /* another attempt, so try next higher message number */ - msgnum++; - } + for (;; msgnum++) { /* * See if we need more space. If we need space at the @@ -177,8 +166,9 @@ folder_addmsg (struct msgs **mpp, char *msgfile, int selected, * across devices, then check if there is a message * already in the desired location. If so, then return * error, else just copy the message. + * Cygwin with FAT32 filesystem produces EPERM. */ - if (linkerr == EXDEV) { + if (linkerr == EXDEV || linkerr == EPERM) { if (stat (newmsg, &st1) == 0) { advise (NULL, "message %s:%s already exists", mp->foldpath, newmsg); return -1;