int i;
struct stat statbuf;
flock_t lock_data;
-uschar spoolname[256];
int fd;
/* If split_spool_directory is set, first look for the file in the appropriate
for (i = 0; i < 2; i++)
{
+ uschar * fname;
int save_errno;
message_subdir[0] = split_spool_directory == (i == 0) ? id[5] : 0;
- snprintf(CS spoolname, sizeof(spoolname), "%s/input/%s/%s/%s-D",
- spool_directory, queue_name, message_subdir, id);
- DEBUG(D_deliver) debug_printf("Trying spool file %s\n", spoolname);
+ fname = spool_fname(US"input", message_subdir, id, US"-D");
+ DEBUG(D_deliver) debug_printf("Trying spool file %s\n", fname);
- if ((fd = Uopen(spoolname, O_RDWR | O_APPEND, 0)) >= 0)
+ if ((fd = Uopen(fname, O_RDWR | O_APPEND, 0)) >= 0)
break;
save_errno = errno;
if (errno == ENOENT)
if (!queue_running)
log_write(0, LOG_MAIN, "Spool file %s-D not found", id);
}
- else log_write(0, LOG_MAIN, "Spool error for %s: %s", spoolname,
+ else log_write(0, LOG_MAIN, "Spool error for %s: %s", fname,
strerror(errno));
errno = save_errno;
return -1;
{
if (!subdir_set)
message_subdir[0] = split_spool_directory == (n == 0) ? name[5] : 0;
- sprintf(CS big_buffer, "%s/input/%s/%s/%s",
- spool_directory, queue_name, message_subdir, name);
- if ((f = Ufopen(big_buffer, "rb"))) break;
- if (n != 0 || subdir_set || errno != ENOENT) return spool_read_notopen;
+
+ if ((f = Ufopen(spool_fname(US"input", message_subdir, name, US""), "rb")))
+ break;
+ if (n != 0 || subdir_set || errno != ENOENT)
+ return spool_read_notopen;
}
errno = 0;