blob: 60b5f126fe3fbcb5579ad3df2044436c2ae1c6cb [file] [log] [blame]
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "src/core/SkOSFile.h"
#include "src/utils/SkOSPath.h"
#include "tools/flags/CommonFlags.h"
bool CollectImages(CommandLineFlags::StringArray images, SkTArray<SkString>* output) {
static const char* const exts[] = {
#if !defined(SK_BUILD_FOR_WIN)
#if !defined(SK_BUILD_FOR_WIN)
#if !defined(SK_BUILD_FOR_WIN)
for (int i = 0; i < images.count(); ++i) {
const char* flag = images[i];
if (!sk_exists(flag)) {
SkDebugf("%s does not exist!\n", flag);
return false;
if (sk_isdir(flag)) {
// If the value passed in is a directory, add all the images
bool foundAnImage = false;
for (const char* ext : exts) {
SkOSFile::Iter it(flag, ext);
SkString file;
while ( {
foundAnImage = true;
output->push_back() = SkOSPath::Join(flag, file.c_str());
if (!foundAnImage) {
SkDebugf("No supported images found in %s!\n", flag);
return false;
} else {
// Also add the value if it is a single image
output->push_back() = flag;
return true;