FileExtractor tool, remove default mod deps on mix files (pchote: squashed)
This commit is contained in:
54
FileExtractor/FileExtractor.cs
Normal file
54
FileExtractor/FileExtractor.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using OpenRA.FileFormats;
|
||||
using System.IO;
|
||||
|
||||
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);
|
||||
|
||||
foreach (var folder in manifest.Folders) FileSystem.Mount(folder);
|
||||
foreach (var pkg in manifest.Packages) FileSystem.Mount(pkg);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
FileExtractor/FileExtractor.csproj
Normal file
43
FileExtractor/FileExtractor.csproj
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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>
|
||||
13
FileExtractor/Main.cs
Normal file
13
FileExtractor/Main.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace FileExtractor
|
||||
{
|
||||
public class MainClass
|
||||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
new FileExtractor(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user