diff --git a/FileExtractor/FileExtractor.cs b/FileExtractor/FileExtractor.cs new file mode 100644 index 0000000000..12e5017b32 --- /dev/null +++ b/FileExtractor/FileExtractor.cs @@ -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(); + } + } +} + diff --git a/FileExtractor/FileExtractor.csproj b/FileExtractor/FileExtractor.csproj new file mode 100644 index 0000000000..cc2b94ef25 --- /dev/null +++ b/FileExtractor/FileExtractor.csproj @@ -0,0 +1,43 @@ + + + + Debug + AnyCPU + 9.0.21022 + 2.0 + {210645C7-E99E-46B6-863E-E211AE6C7D70} + Exe + FileExtractor + FileExtractor + v3.5 + + + true + full + false + ..\ + DEBUG + prompt + 4 + false + + + none + false + ..\ + prompt + 4 + false + + + + {BDAEAB25-991E-46A7-AF1E-4F0E03358DAA} + OpenRA.FileFormats + + + + + + + + \ No newline at end of file diff --git a/FileExtractor/Main.cs b/FileExtractor/Main.cs new file mode 100644 index 0000000000..2fefff38fa --- /dev/null +++ b/FileExtractor/Main.cs @@ -0,0 +1,13 @@ +using System; + +namespace FileExtractor +{ + public class MainClass + { + public static void Main (string[] args) + { + new FileExtractor(args); + } + } +} + diff --git a/Makefile b/Makefile index cc617784a8..3417b3fac8 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CSC = gmcs CSFLAGS = -nologo -warn:4 -debug:+ -debug:full -optimize- -codepage:utf8 -unsafe DEFINE = DEBUG;TRACE -PROGRAMS =fileformats gl game ra cnc aftermath seqed mapcvtr editor ralint +PROGRAMS =fileformats gl game ra cnc aftermath seqed mapcvtr editor ralint filex prefix = /usr/local datarootdir = $(prefix)/share datadir = $(datarootdir) @@ -13,8 +13,6 @@ INSTALL_PROGRAM = $(INSTALL) COMMON_LIBS = System.dll System.Core.dll System.Drawing.dll System.Xml.dll -CORE = fileformats gl game seqed mapcvtr - fileformats_SRCS = $(shell find OpenRA.FileFormats/ -iname '*.cs') fileformats_TARGET = OpenRA.FileFormats.dll fileformats_KIND = library @@ -79,10 +77,16 @@ ralint_KIND = winexe ralint_DEPS = $(fileformats_TARGET) $(game_TARGET) ralint_LIBS = $(COMMON_LIBS) $(ralint_DEPS) +filex_SRCS = $(shell find FileExtractor/ -iname '*.cs') +filex_TARGET = FileExtractor.exe +filex_KIND = winexe +filex_DEPS = $(fileformats_TARGET) +filex_LIBS = $(COMMON_LIBS) $(filex_DEPS) + # -platform:x86 .SUFFIXES: -.PHONY: clean all game tool default mods mod_ra mod_aftermath mod_cnc install uninstall editor_res editor ralint seqed mapcvtr +.PHONY: clean all game tool default mods mod_ra mod_aftermath mod_cnc install uninstall editor_res editor ralint seqed mapcvtr filex game: $(fileformats_TARGET) $(gl_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(aftermath_TARGET) @@ -91,6 +95,8 @@ clean: distclean: clean +CORE = fileformats gl game seqed mapcvtr + install: all @-echo "Installing OpenRA to $(INSTALL_DIR)" @$(INSTALL_PROGRAM) -d $(INSTALL_DIR) @@ -149,8 +155,9 @@ editor: editor_res $(editor_TARGET) ralint: $(ralint_TARGET) seqed: $(seqed_TARGET) mapcvtr: $(mapcvtr_TARGET) +filex: $(filex_TARGET) -tools: editor ralint seqed mapcvtr +tools: editor ralint seqed mapcvtr filex all: game tools define BUILD_ASSEMBLY diff --git a/OpenRA.sln b/OpenRA.sln index 400c20207a..751bb8d7aa 100644 --- a/OpenRA.sln +++ b/OpenRA.sln @@ -29,6 +29,8 @@ 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 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -52,6 +54,14 @@ 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