mirror of https://github.com/djcb/mu.git
* make mu_util_create_dir_maybe potentially not warn (useful when the logging
system is not initialized yet)
This commit is contained in:
parent
a3b627f866
commit
785a09ef76
|
@ -128,7 +128,7 @@ mu_util_create_tmpdir (void)
|
|||
G_DIR_SEPARATOR,
|
||||
(int)random()*getpid()*(int)time(NULL));
|
||||
|
||||
if (!mu_util_create_dir_maybe (dirname, 0700)) {
|
||||
if (!mu_util_create_dir_maybe (dirname, 0700, FALSE)) {
|
||||
g_free (dirname);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ mu_util_guess_mu_homedir (void)
|
|||
}
|
||||
|
||||
gboolean
|
||||
mu_util_create_dir_maybe (const gchar *path, mode_t mode)
|
||||
mu_util_create_dir_maybe (const gchar *path, mode_t mode, gboolean nowarn)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
|
@ -247,14 +247,17 @@ mu_util_create_dir_maybe (const gchar *path, mode_t mode)
|
|||
if (stat (path, &statbuf) == 0) {
|
||||
if ((!S_ISDIR(statbuf.st_mode)) ||
|
||||
(access (path, W_OK|R_OK) != 0)) {
|
||||
g_warning ("not a read-writable directory: %s", path);
|
||||
if (!nowarn)
|
||||
g_warning ("not a read-writable"
|
||||
"directory: %s", path);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_mkdir_with_parents (path, mode) != 0) {
|
||||
g_warning ("failed to create %s: %s",
|
||||
path, strerror(errno));
|
||||
if (!nowarn)
|
||||
g_warning ("failed to create %s: %s",
|
||||
path, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,12 +75,14 @@ gchar* mu_util_guess_mu_homedir (void)
|
|||
* if path exists, check that's a read/writeable dir; otherwise try to
|
||||
* create it (with perms 0700)
|
||||
*
|
||||
* @param path path to the dir
|
||||
* @param path path to the dir
|
||||
* @param mode to set for the dir (as per chmod(1))
|
||||
* @param nowarn, if TRUE, don't write warnings (if any) to stderr
|
||||
*
|
||||
* @return TRUE if a read/writeable directory `path' exists after
|
||||
* leaving this function, FALSE otherwise
|
||||
*/
|
||||
gboolean mu_util_create_dir_maybe (const gchar *path, mode_t mode)
|
||||
gboolean mu_util_create_dir_maybe (const gchar *path, mode_t mode, gboolean nowarn)
|
||||
G_GNUC_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
|
@ -408,6 +410,7 @@ enum _MuExitCode {
|
|||
};
|
||||
typedef enum _MuExitCode MuExitCode;
|
||||
|
||||
|
||||
enum _MuError {
|
||||
MU_ERROR_XAPIAN, /* general xapian related error */
|
||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, /* can't get write lock */
|
||||
|
|
Loading…
Reference in New Issue