Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,10 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the License). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an AS IS BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
@@ -0,0 +1,16 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the License). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an AS IS BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
ly_add_source_properties(
SOURCES AzToolsFramework/Application/ToolsApplication.cpp
PROPERTY COMPILE_OPTIONS
VALUES -bigobj
)
@@ -0,0 +1,234 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/string/string.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/IO/LocalFileIO.h>
namespace AzToolsFramework
{
namespace Platform
{
static const char ErrorChannel[] = "ArchiveComponent_Linux";
static const char ZipExePath[] = R"(/usr/bin/zip)";
static const char UnzipExePath[] = R"(/usr/bin/unzip)";
static const char CreateArchiveCmd[] = "-r \"%s\" . -i *";
static const char ExtractArchiveCmd[] = R"(-o "%s" -d "%s")";
static const char AddFileCmd[] = R"("%s" "%s")";
static const char ExtractFileCmd[] = R"(%s "%s" %s)";
static const char ExtractFileDestination[] = R"(%s "%s" "%s" -d "%s")";
static const char ExtractOverwrite[] = "-o";
static const char ExtractSkipExisting[] = "-n";
static const char ListFilesInArchiveCmd[] = "-l %s";
AZStd::string GetZipExePath()
{
return ZipExePath;
}
AZStd::string GetUnzipExePath()
{
return UnzipExePath;
}
AZ::Outcome<AZStd::string, AZStd::string> MakePath(const AZStd::string& path)
{
// Create the folder if it does not already exist
if (!AZ::IO::FileIOBase::GetInstance()->Exists(path.c_str()))
{
auto result = AZ::IO::FileIOBase::GetInstance()->CreatePath(path.c_str());
if (!result)
{
return AZ::Failure(AZStd::string::format("Path creation failed. Input path: %s \n", path.c_str()));
}
}
return AZ::Success(path);
}
AZ::Outcome<AZStd::string, AZStd::string> MakeCreateArchivePath(const AZStd::string& archivePath)
{
// Remove the file name from the input path
// /some/folder/path/archive.zip -> /some/folder/path/
AZStd::string strippedArchivePath = archivePath;
AzFramework::StringFunc::Path::StripFullName(strippedArchivePath);
if (strippedArchivePath.empty())
{
return AZ::Failure(AZStd::string::format("Stripped path name is empty. Cancelling path creation. Input path: %s\n", archivePath.c_str()));
}
return MakePath(strippedArchivePath);
}
AZ::Outcome<AZStd::string, AZStd::string> MakeExtractArchivePath(const AZStd::string& archivePath, const AZStd::string& destinationPath, bool includeRoot)
{
if(!includeRoot)
{
// Create the folder for the input destination path with no modifications
// /path/to/destination/
return MakePath(destinationPath);
}
// Get the name of the input archive. This will be the name of the root folder for the archive extraction
// /some/folder/path/archive.zip -> archive
AZStd::string zipFileName;
bool result = AzFramework::StringFunc::Path::GetFileName(archivePath.c_str(), zipFileName);
if(!result)
{
return AZ::Failure(AZStd::string::format("Failed to get name of zip file from the archive path. Cancelling path creation. \n Input Archive Path: %s \n", archivePath.c_str()));
}
// Append the root folder name to the end of the destination path
// /path/to/destination/ + archive -> /path/to/destination/archive
AZStd::string destinationPathWithRoot;
result = AzFramework::StringFunc::Path::Join(destinationPath.c_str(), zipFileName.c_str(), destinationPathWithRoot);
if(!result)
{
return AZ::Failure(AZStd::string::format("Failed to append zip file name to the destination path. Cancelling path creation. \n Destination Path: %s \n Zip file name: %s \n", destinationPath.c_str(), zipFileName.c_str()));
}
// Append a separator so that it is formatted like a folder
// /path/to/destination/archive -> /path/to/destination/archive/
AzFramework::StringFunc::Path::AppendSeparator(destinationPathWithRoot);
return MakePath(destinationPathWithRoot);
}
AZStd::string GetCreateArchiveCommand(const AZStd::string& archivePath, const AZStd::string& dirToArchive)
{
auto pathCreationResult = MakeCreateArchivePath(archivePath);
if (!pathCreationResult)
{
AZ_Error(ErrorChannel, false, "%s", pathCreationResult.GetError().c_str());
return "";
}
AZ_UNUSED(dirToArchive);
return AZStd::string::format(CreateArchiveCmd, archivePath.c_str());
}
AZStd::string GetExtractArchiveCommand(const AZStd::string& archivePath, const AZStd::string& destinationPath, bool includeRoot)
{
auto pathCreationResult = MakeExtractArchivePath(archivePath, destinationPath, includeRoot);
if (!pathCreationResult)
{
AZ_Error(ErrorChannel, false, "%s", pathCreationResult.GetError().c_str());
return "";
}
return AZStd::string::format(ExtractArchiveCmd, archivePath.c_str(), pathCreationResult.GetValue().c_str());
}
AZStd::string GetAddFilesToArchiveCommand(const AZStd::string& /*archivePath*/, const AZStd::string& /*listFilePath*/)
{
// Adding files into a archive using a list file is not currently supported
return {};
}
bool IsAddFilesToArchiveCommandSupported()
{
// Adding files into a archive using a list file is not currently supported
return false;
}
AZStd::string GetAddFileToArchiveCommand(const AZStd::string& archivePath, const AZStd::string& file)
{
if (!MakeCreateArchivePath(archivePath).IsSuccess())
{
AZ_Error(ErrorChannel, false, "Unable to make path for ( %s ).\n", archivePath.c_str());
return {};
}
return AZStd::string::format(AddFileCmd, archivePath.c_str(), file.c_str());
}
AZStd::string GetExtractFileCommand(const AZStd::string& archivePath, const AZStd::string& fileInArchive, const AZStd::string& destinationPath, bool overWrite)
{
AZStd::string commandLineArgs;
if (destinationPath.empty())
{
// Extract file in archive from archive path to the current directory, overwriting a file of the same name that exists there.
commandLineArgs = AZStd::string::format(ExtractFileCmd, overWrite ? ExtractOverwrite : ExtractSkipExisting, archivePath.c_str(), fileInArchive.c_str());
}
else
{
if (!MakePath(destinationPath).IsSuccess())
{
AZ_Error(ErrorChannel, false, "Unable to make path ( %s ).\n", destinationPath.c_str());
return {};
}
// Extract file in archive from archive path to destinationPath, overwriting a file of the same name that exists there.
commandLineArgs = AZStd::string::format(ExtractFileDestination, overWrite ? ExtractOverwrite : ExtractSkipExisting, archivePath.c_str(), fileInArchive.c_str(), destinationPath.c_str());
}
return commandLineArgs;
}
AZStd::string GetListFilesInArchiveCommand(const AZStd::string& archivePath)
{
AZStd::string commandLineArgs = AZStd::string::format(ListFilesInArchiveCmd, archivePath.c_str());
return commandLineArgs;
}
/*
Sample Console Output of the unzip list command
Archive: /var/folders/1q/12nyzqc913qgm532y2c98mnm6w4_qv/T/ArchiveTests-ra8oMy/TestArchive.pak
Length Date Time Name
--------- ---------- ----- ----
0 10-14-2019 15:22 testfolder/
1 10-14-2019 15:22 testfolder/folderfile.txt
1 10-14-2019 15:22 basicfile.txt
1 10-14-2019 15:22 basicfile2.txt
0 10-14-2019 15:22 testfolder2/
1 10-14-2019 15:22 testfolder2/sharedfolderfile2.txt
1 10-14-2019 15:22 testfolder2/sharedfolderfile.txt
0 10-14-2019 15:22 testfolder3/
0 10-14-2019 15:22 testfolder3/testfolder4/
1 10-14-2019 15:22 testfolder3/testfolder4/depthfile.bat
--------- -------
6 10 files
*/
void ParseConsoleOutputFromListFilesInArchive(const AZStd::string& consoleOutput, AZStd::vector<AZStd::string>& fileEntries)
{
AZStd::vector<AZStd::string> fileEntryData;
AzFramework::StringFunc::Tokenize(consoleOutput.c_str(), fileEntryData, "\n");
int startingLineIdx = 3; // first line that might contain the file name
for (size_t lineIdx = startingLineIdx; lineIdx < fileEntryData.size(); ++lineIdx)
{
AZStd::string& line = fileEntryData[lineIdx];
AZStd::vector<AZStd::string> lineEntryData;
AzFramework::StringFunc::Tokenize(line.c_str(), lineEntryData, " ");
AZStd::string& fileName = lineEntryData.back();
if(fileName.back() == AZ_CORRECT_FILESYSTEM_SEPARATOR)
{
// if the filename ends with a separator
// than it indicates that this is a directory
continue;
}
if(fileName.compare("-------") == 0)
{
return;
}
fileEntries.emplace_back(fileName);
}
}
} // namespace Platform
} // namespace AzToolsFramework
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
AzToolsFramework/Archive/ArchiveComponent_Linux.cpp
)
@@ -0,0 +1,267 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/string/string.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/IO/LocalFileIO.h>
namespace AzToolsFramework
{
namespace Platform
{
const char ErrorChannel[] = "ArchiveComponent_OSX";
const char ZipExePath[] = R"(/usr/bin/zip)";
const char UnzipExePath[] = R"(/usr/bin/unzip)";
// v Requires investigation, the correct cmd should be R"(-r "%s" "%s/")" but tests fail
const char CreateArchiveCmd[] = R"(-r "%s" .)";
const char ExtractArchiveCmd[] = R"(-o "%s" -d "%s")";
const char AddFileCmd[] = R"("%s" "%s" -X)";
const char AddFilesCmd[] = R"("%s" -X %s)";
const char ExtractFileCmd[] = R"(%s "%s" %s)";
const char ExtractFileDestination[] = R"(%s "%s" "%s" -d "%s")";
const char ExtractOverwrite[] = "-o";
const char ExtractSkipExisting[] = "-n";
const char ListFilesInArchiveCmd[] = "-l %s";
AZStd::string GetZipExePath()
{
return ZipExePath;
}
AZStd::string GetUnzipExePath()
{
return UnzipExePath;
}
AZ::Outcome<AZStd::string, AZStd::string> MakePath(const AZStd::string& path)
{
// Create the folder if it does not already exist
if (!AZ::IO::FileIOBase::GetInstance()->Exists(path.c_str()))
{
auto result = AZ::IO::FileIOBase::GetInstance()->CreatePath(path.c_str());
if (!result)
{
return AZ::Failure(AZStd::string::format("Path creation failed. Input path: %s \n", path.c_str()));
}
}
return AZ::Success(path);
}
AZ::Outcome<AZStd::string, AZStd::string> MakeCreateArchivePath(const AZStd::string& archivePath)
{
// Remove the file name from the input path
// /some/folder/path/archive.zip -> /some/folder/path/
AZStd::string strippedArchivePath = archivePath;
AzFramework::StringFunc::Path::StripFullName(strippedArchivePath);
if (strippedArchivePath.empty())
{
return AZ::Failure(AZStd::string::format("Stripped path name is empty. Cancelling path creation. Input path: %s\n", archivePath.c_str()));
}
return MakePath(strippedArchivePath);
}
AZ::Outcome<AZStd::string, AZStd::string> MakeExtractArchivePath(const AZStd::string& archivePath, const AZStd::string& destinationPath, bool includeRoot)
{
if(!includeRoot)
{
// Create the folder for the input destination path with no modifications
// /path/to/destination/
return MakePath(destinationPath);
}
// Get the name of the input archive. This will be the name of the root folder for the archive extraction
// /some/folder/path/archive.zip -> archive
AZStd::string zipFileName;
bool result = AzFramework::StringFunc::Path::GetFileName(archivePath.c_str(), zipFileName);
if(!result)
{
return AZ::Failure(AZStd::string::format("Failed to get name of zip file from the archive path. Cancelling path creation. \n Input Archive Path: %s \n", archivePath.c_str()));
}
// Append the root folder name to the end of the destination path
// /path/to/destination/ + archive -> /path/to/destination/archive
AZStd::string destinationPathWithRoot;
result = AzFramework::StringFunc::Path::Join(destinationPath.c_str(), zipFileName.c_str(), destinationPathWithRoot);
if(!result)
{
return AZ::Failure(AZStd::string::format("Failed to append zip file name to the destination path. Cancelling path creation. \n Destination Path: %s \n Zip file name: %s \n", destinationPath.c_str(), zipFileName.c_str()));
}
// Append a separator so that it is formatted like a folder
// /path/to/destination/archive -> /path/to/destination/archive/
AzFramework::StringFunc::Path::AppendSeparator(destinationPathWithRoot);
return MakePath(destinationPathWithRoot);
}
AZStd::string GetCreateArchiveCommand(const AZStd::string& archivePath, const AZStd::string& dirToArchive)
{
auto pathCreationResult = MakeCreateArchivePath(archivePath);
if (!pathCreationResult.IsSuccess())
{
AZ_Error(ErrorChannel, false, pathCreationResult.GetError().c_str());
return "";
}
// LY-116692. Requires proper investigation, the correct format should be:
// AZStd::string::format(CreateArchiveCmd, archivePath.c_str(), dirToArchive.c_str());
// but unit test ArchiveTest.ListFilesInArchiveBlocking_FilesAtThreeDepths_FilesFound fails
AZ_UNUSED(dirToArchive);
return AZStd::string::format(CreateArchiveCmd, archivePath.c_str());
}
AZStd::string GetExtractArchiveCommand(const AZStd::string& archivePath, const AZStd::string& destinationPath, bool includeRoot)
{
auto pathCreationResult = MakeExtractArchivePath(archivePath, destinationPath, includeRoot);
if (!pathCreationResult)
{
AZ_Error(ErrorChannel, false, pathCreationResult.GetError().c_str());
return "";
}
return AZStd::string::format(ExtractArchiveCmd, archivePath.c_str(), pathCreationResult.GetValue().c_str());
}
AZStd::string GetAddFilesToArchiveCommand(const AZStd::string& archivePath, const AZStd::string& listFilePath)
{
auto pathCreationResult = MakeCreateArchivePath(archivePath);
if (!pathCreationResult)
{
AZ_Error(ErrorChannel, false, pathCreationResult.GetError().c_str());
return "";
}
AZStd::string fileListStr;
{
AZ::IO::FileIOStream fileStream(listFilePath.c_str(), AZ::IO::OpenMode::ModeRead | AZ::IO::OpenMode::ModeText);
if (fileStream.IsOpen())
{
AZ::IO::SizeType length = fileStream.GetLength();
AZStd::vector<char> charBuffer;
charBuffer.resize_no_construct(length + 1);
fileStream.Read(length, charBuffer.data());
charBuffer.back() = 0;
fileListStr.append("\"");
fileListStr.insert(1, charBuffer.data());
AzFramework::StringFunc::Replace(fileListStr, "\n", "\" \"");
fileListStr.append("\"");
}
else
{
AZ_Error(ErrorChannel, false, "Unable to read list file ( %s ) \n", listFilePath.c_str());
return "";
}
}
return AZStd::string::format(AddFilesCmd, archivePath.c_str(), fileListStr.c_str());
}
AZStd::string GetAddFileToArchiveCommand(const AZStd::string& archivePath, const AZStd::string& file)
{
auto pathCreationResult = MakeCreateArchivePath(archivePath);
if (!pathCreationResult)
{
AZ_Error(ErrorChannel, false, pathCreationResult.GetError().c_str());
return "";
}
return AZStd::string::format(AddFileCmd, archivePath.c_str(), file.c_str());
}
AZStd::string GetExtractFileCommand(const AZStd::string& archivePath, const AZStd::string& fileInArchive, const AZStd::string& destinationPath, bool overWrite)
{
AZStd::string commandLineArgs;
if (destinationPath.empty())
{
// Extract file in archive from archive path to the current directory, overwriting a file of the same name that exists there.
commandLineArgs = AZStd::string::format(ExtractFileCmd, overWrite ? ExtractOverwrite : ExtractSkipExisting, archivePath.c_str(), fileInArchive.c_str());
}
else
{
if (!MakePath(destinationPath).IsSuccess())
{
AZ_Error(ErrorChannel, false, "Unable to make path ( %s ).\n", destinationPath.c_str());
return "";
}
// Extract file in archive from archive path to destinationPath, overwriting a file of the same name that exists there.
commandLineArgs = AZStd::string::format(ExtractFileDestination, overWrite ? ExtractOverwrite : ExtractSkipExisting, archivePath.c_str(), fileInArchive.c_str(), destinationPath.c_str());
}
return commandLineArgs;
}
AZStd::string GetListFilesInArchiveCommand(const AZStd::string& archivePath)
{
AZStd::string commandLineArgs = AZStd::string::format(ListFilesInArchiveCmd, archivePath.c_str());
return commandLineArgs;
}
/*
Sample Console Output of the unzip list command
Archive: /var/folders/1q/12nyzqc913qgm532y2c98mnm6w4_qv/T/ArchiveTests-ra8oMy/TestArchive.pak
Length Date Time Name
--------- ---------- ----- ----
0 10-14-2019 15:22 testfolder/
1 10-14-2019 15:22 testfolder/folderfile.txt
1 10-14-2019 15:22 basicfile.txt
1 10-14-2019 15:22 basicfile2.txt
0 10-14-2019 15:22 testfolder2/
1 10-14-2019 15:22 testfolder2/sharedfolderfile2.txt
1 10-14-2019 15:22 testfolder2/sharedfolderfile.txt
0 10-14-2019 15:22 testfolder3/
0 10-14-2019 15:22 testfolder3/testfolder4/
1 10-14-2019 15:22 testfolder3/testfolder4/depthfile.bat
--------- -------
6 10 files
*/
void ParseConsoleOutputFromListFilesInArchive(const AZStd::string& consoleOutput, AZStd::vector<AZStd::string>& fileEntries)
{
AZStd::vector<AZStd::string> fileEntryData;
AzFramework::StringFunc::Tokenize(consoleOutput.c_str(), fileEntryData, "\n");
int startingLineIdx = 3; // first line that might contain the file name
for (size_t lineIdx = startingLineIdx; lineIdx < fileEntryData.size(); ++lineIdx)
{
AZStd::string& line = fileEntryData[lineIdx];
AZStd::vector<AZStd::string> lineEntryData;
AzFramework::StringFunc::Tokenize(line.c_str(), lineEntryData, " ");
AZStd::string& fileName = lineEntryData.back();
if(fileName.back() == AZ_CORRECT_FILESYSTEM_SEPARATOR)
{
// if the filename ends with a separator
// than it indicates that this is a directory
continue;
}
if(fileName.compare("-------") == 0)
{
return;
}
fileEntries.emplace_back(fileName);
}
}
} // namespace Platform
} // namespace AzToolsFramework
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
AzToolsFramework/Archive/ArchiveComponent_Mac.cpp
)
@@ -0,0 +1,171 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <AzCore/std/string/string.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzToolsFramework/Archive/ArchiveComponent.h>
namespace AzToolsFramework
{
namespace Platform
{
const char CreateArchiveCmd[] = R"(a -tzip -mx=1 "%s" -r "%s\*")";
// -aos is for skipping extract on existing files
const char ExtractArchiveCmd[] = R"(x -mmt=off "%s" -o"%s\*" -aos)";
const char ExtractArchiveWithoutRootCmd[] = R"(x -mmt=off "%s" -o"%s" -aos)";
const char AddFilesCmd[] = R"(a -tzip "%s" @"%s")";
const char AddFileCmd[] = R"(a -tzip "%s" "%s")";
const char ExtractFileCmd[] = R"(e -mmt=off "%s" "%s" %s)";
const char ExtractFileDestination[] = R"(e -mmt=off "%s" -o"%s" "%s" %s)";
const char ExtractOverwrite[] = "-aoa";
const char ExtractSkipExisting[] = "-aos";
const char ListFilesInArchiveCmd[] = R"(l -r -slt "%s")";
AZStd::string Get7zExePath()
{
const char* rootPath = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(rootPath, &AZ::ComponentApplicationRequests::GetAppRoot);
AZStd::string exePath;
AzFramework::StringFunc::Path::ConstructFull(rootPath, "Tools", "7za", ".exe", exePath);
return exePath;
}
AZStd::string GetZipExePath()
{
return Get7zExePath();
}
AZStd::string GetUnzipExePath()
{
return Get7zExePath();
}
AZStd::string GetCreateArchiveCommand(const AZStd::string& archivePath, const AZStd::string& dirToArchive)
{
return AZStd::string::format(CreateArchiveCmd, archivePath.c_str(), dirToArchive.c_str());
}
AZStd::string GetExtractArchiveCommand(const AZStd::string& archivePath, const AZStd::string& destinationPath, bool includeRoot)
{
if (includeRoot)
{
// Extract archive path to destinationPath\<archiveFileName> and skipping extracting of existing files
return AZStd::string::format(ExtractArchiveCmd, archivePath.c_str(), destinationPath.c_str());
}
else
{
// Extract archive path to destinationPath and skipping extracting of existing files
return AZStd::string::format(ExtractArchiveWithoutRootCmd, archivePath.c_str(), destinationPath.c_str());
}
}
AZStd::string GetAddFilesToArchiveCommand(const AZStd::string& archivePath, const AZStd::string& listFilePath)
{
return AZStd::string::format(AddFilesCmd, archivePath.c_str(), listFilePath.c_str());
}
AZStd::string GetAddFileToArchiveCommand(const AZStd::string& archivePath, const AZStd::string& file)
{
return AZStd::string::format(AddFileCmd, archivePath.c_str(), file.c_str());
}
AZStd::string GetExtractFileCommand(const AZStd::string& archivePath, const AZStd::string& fileInArchive, const AZStd::string& destinationPath, bool overWrite)
{
AZStd::string commandLineArgs;
if (destinationPath.empty())
{
// Extract file in archive from archive path to the current directory, overwriting a file of the same name that exists there.
commandLineArgs = AZStd::string::format(ExtractFileCmd, archivePath.c_str(), fileInArchive.c_str(), overWrite ? ExtractOverwrite : ExtractSkipExisting);
}
else
{
// Extract file in archive from archive path to destinationPath, overwriting a file of the same name that exists there.
commandLineArgs = AZStd::string::format(ExtractFileDestination, archivePath.c_str(), destinationPath.c_str(), fileInArchive.c_str(), overWrite ? ExtractOverwrite : ExtractSkipExisting);
}
return commandLineArgs;
}
AZStd::string GetListFilesInArchiveCommand(const AZStd::string& archivePath)
{
AZStd::string commandLineArgs = AZStd::string::format(ListFilesInArchiveCmd, archivePath.c_str());
return commandLineArgs;
}
/*
File output for our list archive commands takes the following two patterns for files vs directories:
Path = basicfile2.txt
Folder = -
Size = 1
Packed Size = 1
Modified = 2019-03-26 18:31:10
Created = 2019-03-26 18:31:10
Accessed = 2019-03-26 18:31:10
Attributes = A
Encrypted = -
Comment =
CRC = 32D70693
Method = Store
Characteristics = NTFS
Host OS = FAT
Version = 10
Volume Index = 0
Offset = 44
Path = testfolder
Folder = +
Size = 0
Packed Size = 0
Modified = 2019-03-26 18:31:10
Created = 2019-03-26 18:31:10
Accessed = 2019-03-26 18:31:10
Attributes = D
Encrypted = -
Comment =
CRC =
Method = Store
Characteristics = NTFS
Host OS = FAT
Version = 20
Volume Index = 0
Offset = 89
*/
void ParseConsoleOutputFromListFilesInArchive(const AZStd::string& consoleOutput, AZStd::vector<AZStd::string>& fileEntries)
{
AZStd::vector<AZStd::string> fileEntryData;
AzFramework::StringFunc::Tokenize(consoleOutput.c_str(), fileEntryData, "\r\n");
for (size_t slotNum = 0; slotNum < fileEntryData.size(); ++slotNum)
{
AZStd::string& line = fileEntryData[slotNum];
if (AzFramework::StringFunc::StartsWith(line, "Path = "))
{
if ((slotNum + 1) < fileEntryData.size())
{
// We're checking one past each entry we find for the Folder entry and skipping anything marked as a folder
// See sample output above
if (AzFramework::StringFunc::StartsWith(fileEntryData[slotNum + 1], "Folder = -"))
{
AzFramework::StringFunc::Replace(line, "Path = ", "", false, true);
fileEntries.emplace_back(AZStd::move(line));
slotNum++;
}
}
}
}
}
} // namespace Platform
} // namespace AzToolsFramework
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
AzToolsFramework/Archive/ArchiveComponent_Windows.cpp
)