From cd6fd2ab18bdc1364ede3a33773df4e3ad719efa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 19 Sep 2013 21:39:01 +0100 Subject: Various KDM and encryption fixes. --- src/lib/util.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/lib/util.cc') diff --git a/src/lib/util.cc b/src/lib/util.cc index b8bc1fc9e..4e4493ac7 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -800,3 +800,18 @@ valid_image_file (boost::filesystem::path f) return (ext == ".tif" || ext == ".tiff" || ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".bmp" || ext == ".tga"); } +string +tidy_for_filename (string f) +{ + string t; + for (size_t i = 0; i < f.length(); ++i) { + if (isalpha (f[i]) || f[i] == '_' || f[i] == '-') { + t += f[i]; + } else { + t += '_'; + } + } + + return t; +} + -- cgit v1.2.3