Browse Source

Added constants for pack file extension and search filter. Added support for absolute pack file paths. Added -logname param to override log file path.

Matt Benic 10 years ago
parent
commit
0613ca3646

+ 10 - 3
Source/Atomic/Engine/Engine.cpp

@@ -245,7 +245,7 @@ bool Engine::Initialize(const VariantMap& parameters)
         // If path is not absolute, prefer to add it as a package if possible
         if (!IsAbsolutePath(resourcePaths[i]))
         {
-            String packageName = resourcePrefixPath + resourcePaths[i] + ".pak";
+            String packageName = resourcePrefixPath + resourcePaths[i] + PAK_EXTENSION;
             if (fileSystem->FileExists(packageName))
                 success = cache->AddPackageFile(packageName);
 
@@ -259,7 +259,9 @@ bool Engine::Initialize(const VariantMap& parameters)
         else
         {
             String pathName = resourcePaths[i];
-            if (fileSystem->DirExists(pathName))
+            if (pathName.EndsWith(PAK_EXTENSION) && fileSystem->FileExists(pathName))
+                success = cache->AddPackageFile(pathName);
+            else if (fileSystem->DirExists(pathName))
                 success = cache->AddResourceDir(pathName);
         }
 
@@ -320,7 +322,7 @@ bool Engine::Initialize(const VariantMap& parameters)
 
             // Add all the found package files (non-recursive)
             Vector<String> paks;
-            fileSystem->ScanDir(paks, autoLoadPath, "*.pak", SCAN_FILES, false);
+            fileSystem->ScanDir(paks, autoLoadPath, PAK_EXTENSION, SCAN_FILES, false);
             for (unsigned y = 0; y < paks.Size(); ++y)
             {
                 String pak = paks[y];
@@ -829,6 +831,11 @@ VariantMap Engine::ParseParameters(const Vector<String>& arguments)
                     ++i;
                 }
             }
+            else if (argument == "logname" && !value.Empty())
+            {
+                ret["LogName"] = value;
+                ++i;
+            }
             else if (argument == "x" && !value.Empty())
             {
                 ret["WindowWidth"] = ToInt(value);

+ 2 - 0
Source/Atomic/Resource/ResourceCache.cpp

@@ -64,6 +64,8 @@ static const char* checkDirs[] =
 };
 
 static const SharedPtr<Resource> noResource;
+const char* Atomic::PAK_EXTENSION = ".pak";
+const char* Atomic::PAK_FILTER = "*.pak";
 
 ResourceCache::ResourceCache(Context* context) :
     Object(context),

+ 4 - 0
Source/Atomic/Resource/ResourceCache.h

@@ -37,6 +37,10 @@ class PackageFile;
 
 /// Sets to priority so that a package or file is pushed to the end of the vector.
 static const unsigned PRIORITY_LAST = 0xffffffff;
+/// Extension used for package files
+extern const char* PAK_EXTENSION;
+/// File search filter used to find package files
+extern const char* PAK_FILTER;
 
 /// Container of resources with specific type.
 struct ResourceGroup

+ 2 - 1
Source/ToolCore/Build/BuildIOS.cpp

@@ -7,6 +7,7 @@
 
 #include <Atomic/IO/File.h>
 #include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
@@ -308,7 +309,7 @@ void BuildIOS::Build(const String& buildPath)
 
     fileSystem->CreateDir(buildDestDist);
 
-    String resourcePackagePath = buildDestDist + "/AtomicResources.pak";
+    String resourcePackagePath = buildDestDist + "/AtomicResources" + PAK_EXTENSION;
     GenerateResourcePackage(resourcePackagePath);
 
     fileSystem->Copy(buildAppSourceDir + "/AtomicPlayer", buildDestDist + "/AtomicPlayer");

+ 2 - 1
Source/ToolCore/Build/BuildMac.cpp

@@ -6,6 +6,7 @@
 //
 
 #include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
@@ -81,7 +82,7 @@ void BuildMac::Build(const String& buildPath)
     fileSystem->CreateDir(buildPath_ + "/Contents/MacOS");
     fileSystem->CreateDir(buildPath_ + "/Contents/Resources");
 
-    String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources.pak";
+    String resourcePackagePath = buildPath_ + "/Contents/Resources/AtomicResources" + PAK_EXTENSION;
     GenerateResourcePackage(resourcePackagePath);
 
     fileSystem->Copy(appSrcPath + "/Contents/Resources/Atomic.icns", buildPath_ + "/Contents/Resources/Atomic.icns");

+ 2 - 1
Source/ToolCore/Build/BuildWeb.cpp

@@ -8,6 +8,7 @@
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/File.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
@@ -99,7 +100,7 @@ void BuildWeb::Build(const String& buildPath)
     file.Close();
 
     String request;
-    request.AppendWithFormat("new DataRequest(0, %i, 0, 0).open('GET', '/AtomicResources.pak');", rsize);
+    request.AppendWithFormat("new DataRequest(0, %i, 0, 0).open('GET', '/AtomicResources%s');", rsize, PAK_EXTENSION);
 
     resourcejs.Replace("$$REMOTE_PACKAGE_SIZE$$", ToString("%i", rsize));
     resourcejs.Replace("$$ATOMIC_RESOURCES_DATA_REQUEST$$", request);

+ 2 - 1
Source/ToolCore/Build/BuildWindows.cpp

@@ -7,6 +7,7 @@
 
 #include <Atomic/Core/StringUtils.h>
 #include <Atomic/IO/FileSystem.h>
+#include <Atomic/Resource/ResourceCache.h>
 
 #include "../ToolSystem.h"
 #include "../ToolEnvironment.h"
@@ -143,7 +144,7 @@ void BuildWindows::Build(const String& buildPath)
     fileSystem->CreateDir(buildPath_);
     fileSystem->CreateDir(buildPath_ + "/AtomicPlayer_Resources");
 
-    String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources.pak";
+    String resourcePackagePath = buildPath_ + "/AtomicPlayer_Resources/AtomicResources" + PAK_EXTENSION;
     GenerateResourcePackage(resourcePackagePath);
 
     fileSystem->Copy(playerBinary, buildPath_ + "/AtomicPlayer.exe");