Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: tools/skimage_main.cpp

Issue 18175008: Skip the TIMESTAMP file. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm_expectations.h" 8 #include "gm_expectations.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 * If directory is non null and does not end with a path separator, append one. 482 * If directory is non null and does not end with a path separator, append one.
483 * @param directory SkString representing the path to a directory. If the last character is not a 483 * @param directory SkString representing the path to a directory. If the last character is not a
484 * path separator (specific to the current OS), append one. 484 * path separator (specific to the current OS), append one.
485 */ 485 */
486 static void append_path_separator_if_necessary(SkString* directory) { 486 static void append_path_separator_if_necessary(SkString* directory) {
487 if (directory != NULL && directory->c_str()[directory->size() - 1] != SkPATH _SEPARATOR) { 487 if (directory != NULL && directory->c_str()[directory->size() - 1] != SkPATH _SEPARATOR) {
488 directory->appendf("%c", SkPATH_SEPARATOR); 488 directory->appendf("%c", SkPATH_SEPARATOR);
489 } 489 }
490 } 490 }
491 491
492 /**
493 * Return true if the filename represents an image.
494 * Note: This only returns false if the filename begins with 'TIMESTAMP',
495 * which is the file we are trying to avoid. A better implementation might
496 * be to return true if it matches one of the many image file extensions.
497 * Even that is not a perfect solution though, since a file could have the
498 * wrong extension.
499 */
500 static bool is_image_file(const char* filename) {
501 SkString basename = SkOSPath::SkBasename(filename);
502 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
503 }
504
492 int tool_main(int argc, char** argv); 505 int tool_main(int argc, char** argv);
493 int tool_main(int argc, char** argv) { 506 int tool_main(int argc, char** argv) {
494 SkCommandLineFlags::SetUsage("Decode files, and optionally write the results to files."); 507 SkCommandLineFlags::SetUsage("Decode files, and optionally write the results to files.");
495 SkCommandLineFlags::Parse(argc, argv); 508 SkCommandLineFlags::Parse(argc, argv);
496 509
497 if (FLAGS_readPath.count() < 1) { 510 if (FLAGS_readPath.count() < 1) {
498 SkDebugf("Folder(s) or image(s) to decode are required.\n"); 511 SkDebugf("Folder(s) or image(s) to decode are required.\n");
499 return -1; 512 return -1;
500 } 513 }
501 514
(...skipping 19 matching lines...) Expand all
521 for (int i = 0; i < FLAGS_readPath.count(); i++) { 534 for (int i = 0; i < FLAGS_readPath.count(); i++) {
522 const char* readPath = FLAGS_readPath[i]; 535 const char* readPath = FLAGS_readPath[i];
523 if (strlen(readPath) < 1) { 536 if (strlen(readPath) < 1) {
524 break; 537 break;
525 } 538 }
526 if (sk_isdir(readPath)) { 539 if (sk_isdir(readPath)) {
527 const char* dir = readPath; 540 const char* dir = readPath;
528 SkOSFile::Iter iter(dir); 541 SkOSFile::Iter iter(dir);
529 SkString filename; 542 SkString filename;
530 while (iter.next(&filename)) { 543 while (iter.next(&filename)) {
544 if (!is_image_file(filename.c_str())) {
545 continue;
546 }
531 SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str()); 547 SkString fullname = SkOSPath::SkPathJoin(dir, filename.c_str());
532 decodeFileAndWrite(fullname.c_str(), outDirPtr); 548 decodeFileAndWrite(fullname.c_str(), outDirPtr);
533 } 549 }
534 } else if (sk_exists(readPath)) { 550 } else if (sk_exists(readPath) && is_image_file(readPath)) {
535 decodeFileAndWrite(readPath, outDirPtr); 551 decodeFileAndWrite(readPath, outDirPtr);
536 } 552 }
537 } 553 }
538 554
539 if (!FLAGS_createExpectationsPath.isEmpty()) { 555 if (!FLAGS_createExpectationsPath.isEmpty()) {
540 // Use an empty value for everything besides expectations, since the rea der only cares 556 // Use an empty value for everything besides expectations, since the rea der only cares
541 // about the expectations. 557 // about the expectations.
542 Json::Value nullValue; 558 Json::Value nullValue;
543 Json::Value root = skiagm::CreateJsonTree(gExpectationsToWrite, nullValu e, nullValue, 559 Json::Value root = skiagm::CreateJsonTree(gExpectationsToWrite, nullValu e, nullValue,
544 nullValue, nullValue); 560 nullValue, nullValue);
(...skipping 16 matching lines...) Expand all
561 } 577 }
562 578
563 return failed ? -1 : 0; 579 return failed ? -1 : 0;
564 } 580 }
565 581
566 #if !defined SK_BUILD_FOR_IOS 582 #if !defined SK_BUILD_FOR_IOS
567 int main(int argc, char * const argv[]) { 583 int main(int argc, char * const argv[]) {
568 return tool_main(argc, (char**) argv); 584 return tool_main(argc, (char**) argv);
569 } 585 }
570 #endif 586 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698