aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/filesystem.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index e8bdea325a..ec1a0b4c3b 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -1523,6 +1523,7 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
#endif
ws_statb64 s_buf;
int ret;
+ int save_errno;
if (profilename) {
/*
@@ -1537,7 +1538,18 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
* If not then create it.
*/
pf_dir_path = get_profiles_dir ();
- if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
+ if (ws_stat64(pf_dir_path, &s_buf) != 0) {
+ if (errno != ENOENT) {
+ /* Some other problem; give up now. */
+ save_errno = errno;
+ *pf_dir_path_return = g_strdup(pf_dir_path);
+ errno = save_errno;
+ return -1;
+ }
+
+ /*
+ * It doesn't exist; try to create it.
+ */
ret = ws_mkdir(pf_dir_path, 0755);
if (ret == -1) {
*pf_dir_path_return = g_strdup(pf_dir_path);
@@ -1547,7 +1559,14 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
}
pf_dir_path = get_persconffile_dir(profilename);
- if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
+ if (ws_stat64(pf_dir_path, &s_buf) != 0) {
+ if (errno != ENOENT) {
+ /* Some other problem; give up now. */
+ save_errno = errno;
+ *pf_dir_path_return = g_strdup(pf_dir_path);
+ errno = save_errno;
+ return -1;
+ }
#ifdef _WIN32
/*
* Does the parent directory of that directory
@@ -1567,6 +1586,16 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
&& pf_dir_parent_path[pf_dir_parent_path_len - 1] != ':'
&& ws_stat64(pf_dir_parent_path, &s_buf) != 0) {
/*
+ * Not a drive letter and the stat() failed.
+ */
+ if (errno != ENOENT) {
+ /* Some other problem; give up now. */
+ save_errno = errno;
+ *pf_dir_path_return = g_strdup(pf_dir_path);
+ errno = save_errno;
+ return -1;
+ }
+ /*
* No, it doesn't exist - make it first.
*/
ret = ws_mkdir(pf_dir_parent_path, 0755);