Skip to content

Commit

Permalink
Fix errant if statement in --random codepath, fixes #85
Browse files Browse the repository at this point in the history
  • Loading branch information
daf committed Nov 19, 2016
1 parent c12fe55 commit 2d1ad3e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,29 @@ int set_bg_once(Config *cfg, SetBG* bg_setter, Glib::ustring path, int head, Set

if (random) {
if (path.length() > 0) {
if (Glib::file_test, Glib::FILE_TEST_IS_DIR) {
file = Util::pick_random_file(path, cfg->get_recurse());
} else {
file = path;
if (Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
path = Util::pick_random_file(path, cfg->get_recurse());
}
} else {
file = Util::pick_random_file(cfg->get_dirs(), cfg->get_recurse());
path = Util::pick_random_file(cfg->get_dirs(), cfg->get_recurse());
}

if (file.length() == 0) {
if (path.length() == 0) {
std::cerr << "Could not find an image to set!\n";
return 1;
}
}

// path must be resolved to a file at this point, make sure it exists
if (Glib::file_test(path, Glib::FILE_TEST_IS_REGULAR|Glib::FILE_TEST_IS_SYMLINK)) {
file = path;
} else {
if (Glib::file_test(path, Glib::FILE_TEST_IS_REGULAR|Glib::FILE_TEST_IS_SYMLINK)) {
file = path;
} else {
std::cerr << "Set must be called with a file!\n";
return 1;
}
std::cerr << "Set must be called with a file!\n";
return 1;
}

// @TODO: test file for an image format supported

// saving of pixmaps is for interactive only
bg_setter->disable_pixmap_save();

Expand Down

0 comments on commit 2d1ad3e

Please sign in to comment.