#include "opcodes.h"
#include "options.h"
#include "protos.h"
-#include "rfc1524.h"
#include "rfc822.h"
#include "sort.h"
#ifdef MIXMASTER
* | mutt_quote_filename() | Quote a filename to survive the shell's quoting rules
* | mutt_read_line() | Read a line from a file
* | mutt_rmtree() | Recursively remove a directory
+ * | mutt_rename_file() | Rename a file
* | mutt_regex_sanitize_string() | Escape any regex-magic characters in a string
* | mutt_sanitize_filename() | Replace unsafe characters in a filename
* | mutt_set_mtime() | Set the modification time of one file from another
mutt_unlock_file(path, fd);
close(fd);
}
+
+/**
+ * mutt_rename_file - Rename a file
+ *
+ * This function returns 0 on successful move, 1 on old file doesn't exist,
+ * 2 on new file already exists, and 3 on other failure.
+ *
+ * note on access(2) use: No dangling symlink problems here due to
+ * safe_fopen().
+ */
+
+int mutt_rename_file(char *oldfile, char *newfile)
+{
+ FILE *ofp = NULL, *nfp = NULL;
+
+ if (access(oldfile, F_OK) != 0)
+ return 1;
+ if (access(newfile, F_OK) == 0)
+ return 2;
+ ofp = fopen(oldfile, "r");
+ if (!ofp)
+ return 3;
+ nfp = safe_fopen(newfile, "w");
+ if (!nfp)
+ {
+ safe_fclose(&ofp);
+ return 3;
+ }
+ mutt_copy_stream(ofp, nfp);
+ safe_fclose(&nfp);
+ safe_fclose(&ofp);
+ mutt_unlink(oldfile);
+ return 0;
+}
char * mutt_read_line(char *s, size_t *size, FILE *fp, int *line, int flags);
int mutt_rmtree(const char *path);
int mutt_regex_sanitize_string(char *dest, size_t destlen, const char *src);
+int mutt_rename_file(char *oldfile, char *newfile);
void mutt_sanitize_filename(char *f, short slash);
void mutt_set_mtime(const char *from, const char *to);
void mutt_touch_atime(int f);
else
return 1;
}
-
-/* If rfc1524_expand_command() is used on a recv'd message, then
- * the filename doesn't exist yet, but if it's used while sending a message,
- * then we need to rename the existing file.
- *
- * This function returns 0 on successful move, 1 on old file doesn't exist,
- * 2 on new file already exists, and 3 on other failure.
- */
-
-/* note on access(2) use: No dangling symlink problems here due to
- * safe_fopen().
- */
-
-int mutt_rename_file(char *oldfile, char *newfile)
-{
- FILE *ofp = NULL, *nfp = NULL;
-
- if (access(oldfile, F_OK) != 0)
- return 1;
- if (access(newfile, F_OK) == 0)
- return 2;
- ofp = fopen(oldfile, "r");
- if (!ofp)
- return 3;
- nfp = safe_fopen(newfile, "w");
- if (!nfp)
- {
- safe_fclose(&ofp);
- return 3;
- }
- mutt_copy_stream(ofp, nfp);
- safe_fclose(&nfp);
- safe_fclose(&ofp);
- mutt_unlink(oldfile);
- return 0;
-}
int rfc1524_expand_command(struct Body *a, char *filename, char *_type, char *command, int clen);
int rfc1524_expand_filename(char *nametemplate, char *oldfile, char *newfile, size_t nflen);
int rfc1524_mailcap_lookup(struct Body *a, char *type, struct Rfc1524MailcapEntry *entry, int opt);
-int mutt_rename_file(char *oldfile, char *newfile);
#endif /* _MUTT_RFC1524_H */