* make mu_util_create_dir_maybe potentially not warn (useful when the logging
system is not initialized yet)
This commit is contained in:
@ -128,7 +128,7 @@ mu_util_create_tmpdir (void)
|
|||||||
G_DIR_SEPARATOR,
|
G_DIR_SEPARATOR,
|
||||||
(int)random()*getpid()*(int)time(NULL));
|
(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);
|
g_free (dirname);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -237,7 +237,7 @@ mu_util_guess_mu_homedir (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
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;
|
struct stat statbuf;
|
||||||
|
|
||||||
@ -247,14 +247,17 @@ mu_util_create_dir_maybe (const gchar *path, mode_t mode)
|
|||||||
if (stat (path, &statbuf) == 0) {
|
if (stat (path, &statbuf) == 0) {
|
||||||
if ((!S_ISDIR(statbuf.st_mode)) ||
|
if ((!S_ISDIR(statbuf.st_mode)) ||
|
||||||
(access (path, W_OK|R_OK) != 0)) {
|
(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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mkdir_with_parents (path, mode) != 0) {
|
if (g_mkdir_with_parents (path, mode) != 0) {
|
||||||
g_warning ("failed to create %s: %s",
|
if (!nowarn)
|
||||||
path, strerror(errno));
|
g_warning ("failed to create %s: %s",
|
||||||
|
path, strerror(errno));
|
||||||
return FALSE;
|
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
|
* if path exists, check that's a read/writeable dir; otherwise try to
|
||||||
* create it (with perms 0700)
|
* 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
|
* @return TRUE if a read/writeable directory `path' exists after
|
||||||
* leaving this function, FALSE otherwise
|
* 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;
|
G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -408,6 +410,7 @@ enum _MuExitCode {
|
|||||||
};
|
};
|
||||||
typedef enum _MuExitCode MuExitCode;
|
typedef enum _MuExitCode MuExitCode;
|
||||||
|
|
||||||
|
|
||||||
enum _MuError {
|
enum _MuError {
|
||||||
MU_ERROR_XAPIAN, /* general xapian related error */
|
MU_ERROR_XAPIAN, /* general xapian related error */
|
||||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, /* can't get write lock */
|
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, /* can't get write lock */
|
||||||
|
|||||||
Reference in New Issue
Block a user