Skip to content
Permalink
Browse files

When importing files check to see if they start with a number and dis…

…play an error notification for the files that do.

Summary: Fixes T2519.

Test Plan: Import a file (fbx, png) that starts with a number.

Reviewers: #zero_engine_developers, trevor.sundberg

Reviewed By: #zero_engine_developers, trevor.sundberg

Subscribers: dane.curbow

Maniphest Tasks: T2519

Differential Revision: https://dev.zeroengine.io/D743
  • Loading branch information...
danecurbow authored and TrevorSundberg committed Sep 28, 2018
1 parent f383ecb commit 945a169b7654998b7dedac8547cb68f066599bfe
Showing with 23 additions and 2 deletions.
  1. +23 −2 Systems/Content/ImportOptions.cpp
@@ -186,19 +186,40 @@ ImportOptions::~ImportOptions()
void ImportOptions::Initialize(Array<String>& files, ContentLibrary* library)
{
mLibrary = library;
Array<String> invalidFiles;

for(uint i = 0; i < files.Size(); ++i)
{
String fullPath = files[i];

// Strip the path
String fileName = SanitizeContentFilename(FilePath::GetFileName(fullPath.All()));
String originalFilename = FilePath::GetFileName(fullPath.All());
String fileName = SanitizeContentFilename(originalFilename);

// Check to see if the filename contained any valid characters
if (fileName == Zilch::EmptyUpperIdentifier && !originalFilename.Contains(Zilch::EmptyUpperIdentifier))
{
invalidFiles.PushBack(originalFilename);
continue;
}

// Check to see if it already exists
if(mLibrary->FindContentItemByFileName(fileName))
mConflictedFiles.PushBack(fullPath);
else
mFiles.PushBack(fullPath);
mFiles.PushBack(fullPath);
}

// If there are any invalid filenames create a do notify error message
if (!invalidFiles.Empty())
{
StringBuilder builder;
builder.Append(invalidFiles.Front());
for (unsigned i = 1; i < invalidFiles.Size(); ++i)
builder.AppendFormat(", %s", invalidFiles[i].c_str());

String errorMessage = String::Format("The following files do not contain any valid characters: %s", builder.ToString().c_str());
DoNotifyError("File Import Failed", errorMessage);
}

BuildOptions();

0 comments on commit 945a169

Please sign in to comment.
You can’t perform that action at this time.