|
|
@@ -25,6 +25,7 @@
|
|
|
#include <Urho3D/Core/ProcessUtils.h>
|
|
|
#include <Urho3D/IO/File.h>
|
|
|
#include <Urho3D/IO/FileSystem.h>
|
|
|
+#include <Urho3D/IO/PackageFile.h>
|
|
|
|
|
|
#ifdef WIN32
|
|
|
#include <windows.h>
|
|
|
@@ -92,11 +93,16 @@ void Run(const Vector<String>& arguments)
|
|
|
"-c Enable package file LZ4 compression\n"
|
|
|
"-q Enable quiet mode\n"
|
|
|
"\n"
|
|
|
- "Basepath is an optional prefix that will be added to the file entries.\n"
|
|
|
+ "Basepath is an optional prefix that will be added to the file entries.\n\n"
|
|
|
+ "Alternative output usage: PackageTool <output option> <package name>\n"
|
|
|
+ "Output option:\n"
|
|
|
+ "-i Output package file information\n"
|
|
|
+ "-l Output file names (including its path) contained in the package\n"
|
|
|
);
|
|
|
|
|
|
const String& dirName = arguments[0];
|
|
|
const String& packageName = arguments[1];
|
|
|
+ bool isOutputMode = arguments[0].Length() == 2 && arguments[0][0] == '-';
|
|
|
if (arguments.Size() > 2)
|
|
|
{
|
|
|
for (unsigned i = 2; i < arguments.Size(); ++i)
|
|
|
@@ -115,39 +121,66 @@ void Run(const Vector<String>& arguments)
|
|
|
case 'q':
|
|
|
quiet_ = true;
|
|
|
break;
|
|
|
+ default: break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!quiet_)
|
|
|
- PrintLine("Scanning directory " + dirName + " for files");
|
|
|
+ if (!isOutputMode)
|
|
|
+ {
|
|
|
+ if (!quiet_)
|
|
|
+ PrintLine("Scanning directory " + dirName + " for files");
|
|
|
|
|
|
- // Get the file list recursively
|
|
|
- Vector<String> fileNames;
|
|
|
- fileSystem_->ScanDir(fileNames, dirName, "*.*", SCAN_FILES, true);
|
|
|
- if (!fileNames.Size())
|
|
|
- ErrorExit("No files found");
|
|
|
+ // Get the file list recursively
|
|
|
+ Vector<String> fileNames;
|
|
|
+ fileSystem_->ScanDir(fileNames, dirName, "*.*", SCAN_FILES, true);
|
|
|
+ if (!fileNames.Size())
|
|
|
+ ErrorExit("No files found");
|
|
|
|
|
|
- // Check for extensions to ignore
|
|
|
- for (unsigned i = fileNames.Size() - 1; i < fileNames.Size(); --i)
|
|
|
- {
|
|
|
- String extension = GetExtension(fileNames[i]);
|
|
|
- for (unsigned j = 0; ignoreExtensions_[j].Length(); ++j)
|
|
|
+ // Check for extensions to ignore
|
|
|
+ for (unsigned i = fileNames.Size() - 1; i < fileNames.Size(); --i)
|
|
|
{
|
|
|
- if (extension == ignoreExtensions_[j])
|
|
|
+ String extension = GetExtension(fileNames[i]);
|
|
|
+ for (unsigned j = 0; ignoreExtensions_[j].Length(); ++j)
|
|
|
{
|
|
|
- fileNames.Erase(fileNames.Begin() + i);
|
|
|
- break;
|
|
|
+ if (extension == ignoreExtensions_[j])
|
|
|
+ {
|
|
|
+ fileNames.Erase(fileNames.Begin() + i);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- for (unsigned i = 0; i < fileNames.Size(); ++i)
|
|
|
- ProcessFile(fileNames[i], dirName);
|
|
|
+ for (unsigned i = 0; i < fileNames.Size(); ++i)
|
|
|
+ ProcessFile(fileNames[i], dirName);
|
|
|
|
|
|
- WritePackageFile(packageName, dirName);
|
|
|
+ WritePackageFile(packageName, dirName);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SharedPtr<PackageFile> packageFile(new PackageFile(context_, packageName));
|
|
|
+ switch (arguments[0][1])
|
|
|
+ {
|
|
|
+ case 'i':
|
|
|
+ PrintLine("Number of files: " + String(packageFile->GetNumFiles()));
|
|
|
+ PrintLine("File data size: " + String(packageFile->GetTotalDataSize()));
|
|
|
+ PrintLine("Package size: " + String(packageFile->GetTotalSize()));
|
|
|
+ PrintLine("Checksum: " + String(packageFile->GetChecksum()));
|
|
|
+ PrintLine("Compressed: " + String(packageFile->IsCompressed() ? "yes" : "no"));
|
|
|
+ break;
|
|
|
+ case 'l':
|
|
|
+ {
|
|
|
+ const HashMap<String, PackageEntry>& entries = packageFile->GetEntries();
|
|
|
+ for (HashMap<String, PackageEntry>::ConstIterator i = entries.Begin(); i != entries.End(); ++i)
|
|
|
+ PrintLine(i->first_);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ErrorExit("Unrecognized output option");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void ProcessFile(const String& fileName, const String& rootDir)
|
|
|
@@ -268,9 +301,11 @@ void WritePackageFile(const String& fileName, const String& rootDir)
|
|
|
|
|
|
if (!quiet_)
|
|
|
{
|
|
|
- PrintLine("Number of files " + String(entries_.Size()));
|
|
|
- PrintLine("File data size " + String(totalDataSize));
|
|
|
- PrintLine("Package size " + String(dest.GetSize()));
|
|
|
+ PrintLine("Number of files: " + String(entries_.Size()));
|
|
|
+ PrintLine("File data size: " + String(totalDataSize));
|
|
|
+ PrintLine("Package size: " + String(dest.GetSize()));
|
|
|
+ PrintLine("Checksum: " + String(checksum_));
|
|
|
+ PrintLine("Compressed: " + String(compress_ ? "yes" : "no"));
|
|
|
}
|
|
|
}
|
|
|
|