return -1;
}
- return (fd);
+ return fd;
}
flags |= (mode[1] == '+' ? O_RDWR : O_WRONLY);
if ((fd = safe_open(path, flags)) < 0)
- return (NULL);
+ return NULL;
return fdopen (fd, mode);
}
return p ? p + 1 : f;
}
+ssize_t m_dirname(char *dst, ssize_t dlen, const char *path)
+{
+ ssize_t plen = m_strlen(path);
+
+ while (plen > 0 && path[plen - 1] == '/')
+ plen--;
+
+ while (plen > 0 && path[plen - 1] != '/')
+ plen--;
+
+ while (plen > 0 && path[plen - 1] == '/')
+ plen--;
+
+ if (plen)
+ return m_strncpy(dst, dlen, path, plen);
+
+ if (*path == '/')
+ return m_strcpy(dst, dlen, "/");
+ return m_strcpy(dst, dlen, ".");
+}
char *
mutt_concat_path(char *d, ssize_t n, const char *dir, const char *fname)