convert FileExtractor into a Utility cmdlet
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace FileExtractor
|
||||
{
|
||||
public class FileExtractor
|
||||
{
|
||||
int Length = 256;
|
||||
|
||||
public FileExtractor (string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
Console.WriteLine("usage: FileExtractor mod[,mod]* filename");
|
||||
return;
|
||||
}
|
||||
|
||||
var mods = args[0].Split(',');
|
||||
var manifest = new Manifest(mods);
|
||||
FileSystem.LoadFromManifest( manifest );
|
||||
|
||||
try
|
||||
{
|
||||
var readStream = FileSystem.Open(args[1]);
|
||||
var writeStream = new FileStream(args[1], FileMode.OpenOrCreate, FileAccess.Write);
|
||||
|
||||
WriteOutFile(readStream, writeStream);
|
||||
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine(String.Format("No Such File {0}", args[1]));
|
||||
}
|
||||
}
|
||||
|
||||
void WriteOutFile (Stream readStream, Stream writeStream)
|
||||
{
|
||||
Byte[] buffer = new Byte[Length];
|
||||
int bytesRead = readStream.Read(buffer,0,Length);
|
||||
|
||||
while( bytesRead > 0 )
|
||||
{
|
||||
writeStream.Write(buffer,0,bytesRead);
|
||||
bytesRead = readStream.Read(buffer,0,Length);
|
||||
}
|
||||
readStream.Close();
|
||||
writeStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{210645C7-E99E-46B6-863E-E211AE6C7D70}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>FileExtractor</RootNamespace>
|
||||
<AssemblyName>FileExtractor</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
<Project>{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}</Project>
|
||||
<Name>OpenRA.FileFormats</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="FileExtractor.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,23 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace FileExtractor
|
||||
{
|
||||
public class MainClass
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
new FileExtractor(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Makefile
11
Makefile
@@ -6,7 +6,7 @@ PHONY = core tools package all mods clean distclean
|
||||
|
||||
.SUFFIXES:
|
||||
core: game renderers mod_ra mod_cnc utility
|
||||
tools: editor ralint seqed filex tsbuild
|
||||
tools: editor ralint seqed tsbuild
|
||||
package: core editor
|
||||
mods: mod_ra mod_cnc
|
||||
all: core tools
|
||||
@@ -137,15 +137,6 @@ ralint_LIBS = $(COMMON_LIBS) $(ralint_DEPS)
|
||||
PROGRAMS += ralint
|
||||
ralint: $(ralint_TARGET)
|
||||
|
||||
# Extracts files from packages (mixfiles, zips, etc)
|
||||
filex_SRCS := $(shell find FileExtractor/ -iname '*.cs')
|
||||
filex_TARGET = FileExtractor.exe
|
||||
filex_KIND = exe
|
||||
filex_DEPS = $(fileformats_TARGET)
|
||||
filex_LIBS = $(COMMON_LIBS) $(filex_DEPS)
|
||||
PROGRAMS += filex
|
||||
filex: $(filex_TARGET)
|
||||
|
||||
# Builds and exports tilesets from a bitmap
|
||||
tsbuild_SRCS := $(shell find OpenRA.TilesetBuilder/ -iname '*.cs')
|
||||
tsbuild_TARGET = TilesetBuilder.exe
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -302,7 +302,6 @@
|
||||
<Compile Include="Widgets\Logic\ConnectionDialogsLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\CreateServerMenuLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\DeveloperModeLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\DiplomacyLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\LobbyLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\MainMenuButtonsLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\MapChooserLogic.cs" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
||||
@@ -128,5 +128,24 @@ namespace OpenRA.Utility
|
||||
ShpWriter.Write(destStream, size.Width, size.Height,
|
||||
srcImage.Select( im => im.Image ));
|
||||
}
|
||||
|
||||
public static void ExtractFiles(string[] args)
|
||||
{
|
||||
var mods = args[1].Split(',');
|
||||
var files = args.Skip(2);
|
||||
|
||||
var manifest = new Manifest(mods);
|
||||
FileSystem.LoadFromManifest(manifest);
|
||||
|
||||
foreach( var f in files )
|
||||
{
|
||||
var src = FileSystem.Open(f);
|
||||
if (src == null)
|
||||
throw new InvalidOperationException("File not found: {0}".F(f));
|
||||
var data = src.ReadAllBytes();
|
||||
|
||||
File.WriteAllBytes( f, data );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenRA.Utility
|
||||
{ "--shp", Command.ConvertPngToShp },
|
||||
{ "--png", Command.ConvertShpToPng },
|
||||
{ "--fromd2", Command.ConvertFormat2ToFormat80 },
|
||||
{ "--extract", Command.ExtractFiles },
|
||||
};
|
||||
|
||||
if (args.Length == 0) { PrintUsage(); return; }
|
||||
@@ -57,6 +58,7 @@ namespace OpenRA.Utility
|
||||
Console.WriteLine(" --settings-value KEY Get value of KEY from settings.yaml");
|
||||
Console.WriteLine(" --shp PNGFILE FRAMEWIDTH Convert a PNG containing one or more frames to a SHP");
|
||||
Console.WriteLine(" --png SHPFILE PALETTE Convert a SHP to a PNG containing all of its frames");
|
||||
Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages");
|
||||
}
|
||||
|
||||
static T WithDefault<T>(T def, Func<T> f)
|
||||
|
||||
10
OpenRA.sln
10
OpenRA.sln
@@ -25,8 +25,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.TilesetBuilder", "Op
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RALint", "RALint\RALint.csproj", "{F9FA4D9F-2302-470A-8A07-6E37F488C124}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileExtractor", "FileExtractor\FileExtractor.csproj", "{210645C7-E99E-46B6-863E-E211AE6C7D70}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Utility", "OpenRA.Utility\OpenRA.Utility.csproj", "{F33337BE-CB69-4B24-850F-07D23E408DDF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.Renderer.Null", "OpenRA.Renderer.Null\OpenRA.Renderer.Null.csproj", "{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}"
|
||||
@@ -66,14 +64,6 @@ Global
|
||||
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{0DFB103F-2962-400F-8C6D-E2C28CCBA633}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{210645C7-E99E-46B6-863E-E211AE6C7D70}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{230F65CE-A6DE-4235-8B38-13A3D606C7F7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
||||
Reference in New Issue
Block a user