Chromium Code Reviews| Index: tools/skimage_main.cpp |
| diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp |
| index 572f9f54f6a8040eb0280db1742c206b98a9083c..e82be4d59321e62b5f618e3bc943f3f10cb8b332 100644 |
| --- a/tools/skimage_main.cpp |
| +++ b/tools/skimage_main.cpp |
| @@ -489,6 +489,19 @@ static void append_path_separator_if_necessary(SkString* directory) { |
| } |
| } |
| +/** |
| + * Return true if the filename represents an image. |
| + * Note: This only returns false if the filename begins with 'TIMESTAMP', |
| + * which is the file we are trying to avoid. A better implementation might |
| + * be to return true if it matches one of the many image file extensions. |
| + * Even that is not a perfect solution though, since a file could have the |
| + * wrong extension. |
| + */ |
| +static bool is_image_file(const char* filename) { |
| + SkString basename = SkOSPath::SkBasename(filename); |
| + return !basename.startsWith("TIMESTAMP"); |
|
borenet
2013/06/28 19:50:38
How much better is this than just looking for file
scroggo
2013/06/28 20:00:10
It is shorter and faster.
Changed in the latest p
|
| +} |
| + |
| int tool_main(int argc, char** argv); |
| int tool_main(int argc, char** argv) { |
| SkCommandLineFlags::SetUsage("Decode files, and optionally write the results to files."); |
| @@ -528,10 +541,13 @@ int tool_main(int argc, char** argv) { |
| SkOSFile::Iter iter(dir); |
| SkString filename; |
| while (iter.next(&filename)) { |
| + if (!is_image_file(filename.c_str())) { |
| + continue; |
| + } |
| SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str()); |
| decodeFileAndWrite(fullname.c_str(), outDirPtr); |
| } |
| - } else if (sk_exists(readPath)) { |
| + } else if (sk_exists(readPath) && is_image_file(readPath)) { |
| decodeFileAndWrite(readPath, outDirPtr); |
| } |
| } |