/// <summary> Loads WMO from file </summary> /// <param name="fileName">Full name of file of the WMO</param> /// <returns>Loaded WMO</returns> private static Model LoadWMO(string fileName) { var path = fileName; MOHD mohd; var fileInfo = FileInfoFactory.Create(); if (fileInfo.Exists(path) == false) { throw new Exception(String.Format("File does not exist: {0}", path)); } using (var br = new BinaryReader(fileInfo.OpenRead(path))) { int version = new MVERChunkParser(br, br.BaseStream.Position).Parse(); mohd = new MOHDChunkParser(br, br.BaseStream.Position).Parse(); } var list = new TriangleListCollection(); for (int wmoGroup = 0; wmoGroup < mohd.GroupsCount; wmoGroup++) { list.Add(LoadWMOSub(String.Format("{0}_{1:D3}.wmo", fileName.Substring(0, fileName.Length - 4), wmoGroup))); } return(new Model(list)); }
protected override void Arrange() { base.Arrange(); base.Act(); FolderSettings.Stub(x => x.GetSsis()).Return(FolderPath); DirectoryImpl.Stub(x => x.ReadDirectory(FolderPath)).Return(Files); FileInfoFactory.Stub(x => x.Create(File1)).Return(FileInfo1); FileInfoFactory.Stub(x => x.Create(File2)).Return(FileInfo2); }
public FileSystem() { DriveInfo = new DriveInfoFactory(this); DirectoryInfo = new DirectoryInfoFactory(this); FileInfo = new FileInfoFactory(this); Path = new PathWrapper(this); File = new FileWrapper(this); Directory = new DirectoryWrapper(this); FileStream = new FileStreamFactory(); FileSystemWatcher = new FileSystemWatcherFactory(); }
public void ExtendedFileInfoTestShortFilePath() { var shortFilePath = @"C:\FilePath\ShortPath\Textdocument.txt"; var extendedFileInfo = FileInfoFactory.Create(shortFilePath); using (var fileStream = extendedFileInfo.Open(FileMode.Open, FileAccess.Read)) { var buffer = new byte[fileStream.Length]; fileStream.Read(buffer, 0, buffer.Length); } }
private ADT ReadADT(int x, int y) { string file = GetAdtFileName(x, y); IFileInfo fileInfo = FileInfoFactory.Create(); if (fileInfo.Exists(file) == false) { throw new Exception(String.Format("ADT Doesn't exist: {0}", file)); } using (var reader = new BinaryReader(fileInfo.OpenRead(file))) { return(new ADTChunkFileParser(reader).Parse()); } }
private static Model LoadM2(string fileName) { string path = fileName; if (path.Substring(path.Length - 4) == ".mdx") { path = path.Substring(0, path.Length - 4) + ".m2"; } var fileInfo = FileInfoFactory.Create(); if (!fileInfo.Exists(path)) { throw new Exception(String.Format("File does not exist: {0}", path)); } using (var br = new BinaryReader(fileInfo.OpenRead(path))) { br.BaseStream.Position = 60; //wotlk uint numberOfVerts = br.ReadUInt32(); uint vertsOffset = br.ReadUInt32(); uint numberOfViews = br.ReadUInt32(); //UInt32 viewsOffset = br.ReadUInt32(); //now in skins br.BaseStream.Position = 216; //wotlk uint nBoundingTriangles = br.ReadUInt32(); uint ofsBoundingTriangles = br.ReadUInt32(); uint nBoundingVertices = br.ReadUInt32(); uint ofsBoundingVertices = br.ReadUInt32(); uint nBoundingNormals = br.ReadUInt32(); uint ofsBoundingNormals = br.ReadUInt32(); var indices = new IndicesParser(br, ofsBoundingTriangles, nBoundingTriangles).Parse(); var vectors = new VectorsListParser(br, ofsBoundingVertices, nBoundingVertices).Parse(); //var normals = new VectorsListParser(br, ofsBoundingNormals, nBoundingNormals).Parse(); var vertices = vectors .Select(t => new VertexPositionNormalColored(t, Color.Red, Vector3.Up)) .ToList(); var list = new TriangleList(indices, vertices); return(new Model(list)); } }
public IFileInfo GetFileInfoWithPath (string filePath, FileInfoFactory fileInfoFactory) { ArgumentUtility.CheckNotNullOrEmpty ("filePath", filePath); ArgumentUtility.CheckNotNull ("fileInfoFactory", fileInfoFactory); var pathParts = GetPathPaths (filePath); var fileName = pathParts[pathParts.Length - 1]; InMemoryDirectoryInfo directory = null; if (pathParts.Length > 1) directory = GetLeafDirectoryInfo (GetElementsExceptLast (pathParts)); var fileInfo = fileInfoFactory (fileName, directory); if (directory != null) directory.Files.Add (fileInfo); return fileInfo; }
/// <summary> /// Gets a WMO_Sub from the WMO Group file /// </summary> /// <param name="fileName">Full Filename of the WMO_Sub</param> /// <returns></returns> private static TriangleList LoadWMOSub(string fileName) { var path = fileName; var fileInfo = FileInfoFactory.Create(); if (fileInfo.Exists(path) == false) { throw new Exception(String.Format("File does not exist: {0}", path)); } using (var reader = new BinaryReader(fileInfo.OpenRead(path))) { var indices = new MOVIChunkParser(reader, FileChunkHelper.SearchChunk(reader, "MOVI").StartPosition).Parse(); var vectors = new MOVTChunkParser(reader, FileChunkHelper.SearchChunk(reader, "MOVT").StartPosition).Parse(); var normals = new MONRChunkParser(reader, FileChunkHelper.SearchChunk(reader, "MONR").StartPosition).Parse(); var vertices = new List <VertexPositionNormalColored>(); for (var i = 0; i < vectors.Count; i++) { vertices.Add(new VertexPositionNormalColored(vectors[i], Color.Yellow, normals[i])); } return(new TriangleList(indices, vertices)); } }
/// <summary> Creates a new PGX file reader from the specified file name. /// /// </summary> /// <param name="inName">The input file name. /// /// </param> public ImgReaderPGX(System.String inName) : this(FileInfoFactory.New(inName)) { }
/// <summary> Constructor. Always needs a size for the buffer. /// /// </summary> /// <param name="name">The name of the file associated with the buffer /// /// </param> /// <param name="mode">"r" for read, "rw" or "rw+" for read and write mode /// ("rw+" opens the file for update whereas "rw" removes /// it before. So the 2 modes are different only if the /// file already exists). /// /// </param> /// <param name="bufferSize">The number of bytes to buffer /// /// </param> /// <exception cref="java.io.IOException">If an I/O error ocurred. /// /// </exception> protected internal BufferedRandomAccessFile(System.String name, System.String mode, int bufferSize) : this(FileInfoFactory.New(name), mode, bufferSize) { }
/// <summary> Creates a new writer to the specified file, to write data from the /// specified component. /// /// <p>The three components that will be written as R, G and B must be /// specified through the b1, b2 and b3 arguments.</p> /// /// </summary> /// <param name="fname">The name of the file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="n1">The index of the first component from where to get the data, /// that will be written as the red channel. /// /// </param> /// <param name="n2">The index of the second component from where to get the data, /// that will be written as the green channel. /// /// </param> /// <param name="n3">The index of the third component from where to get the data, /// that will be written as the green channel. /// /// </param> /// <seealso cref="DataBlk"> /// /// </seealso> public ImgWriterPPM(System.String fname, BlkImgDataSrc imgSrc, int n1, int n2, int n3) : this(FileInfoFactory.New(fname), imgSrc, n1, n2, n3) { }
public static void Register() { FileInfoFactory.RegisterCreator(new DotnetFileInfoCreator()); }
public DotnetFileInfoCreator() { FileInfoFactory.RegisterCreator(this); }
public FileReader(FolderSettings folderSettings, DirectoryImpl directoryImpl, FileInfoFactory fileInfoFactory) { _fileInfoFactory = fileInfoFactory; _directoryImpl = directoryImpl; _folderSettings = folderSettings; }
public static void Register() { FileInfoFactory.Register(Instance); }
/// <summary> Creates a new writer to the specified file, to write data from the /// specified component. /// /// <p>The size of the image that is written to the file is the size of the /// component from which to get the data, specified by b, not the size of /// the source image (they differ if there is some sub-sampling).</p> /// /// <p>All header information is given by the BlkImgDataSrc source /// (component width, component height, bit-depth) and sign flag, which are /// provided to the constructor. The endianness is always big-endian (MSB /// first). /// /// </summary> /// <param name="fname">The name of the file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="c">The index of the component from where to get the data. /// /// </param> /// <param name="isSigned">Whether the datas are signed or not (needed only when /// writing header). /// /// </param> /// <seealso cref="DataBlk"> /// /// </seealso> public ImgWriterPGX(System.String fname, BlkImgDataSrc imgSrc, int c, bool isSigned) : this(FileInfoFactory.New(fname), imgSrc, c, isSigned) { }
protected override void Act() { Sut = new FileInfoFactory(FileExtensionFactory,FilenameFactory); }
/// <summary> Creates a new writer to the specified file, to write data from the /// specified component. /// /// <P>The size of the image that is written to the file is the size of the /// component from which to get the data, specified by b, not the size of /// the source image (they differ if there is some sub-sampling). /// /// </summary> /// <param name="fname">The name of the file where to write the data /// /// </param> /// <param name="imgSrc">The source from where to get the image data to write. /// /// </param> /// <param name="c">The index of the component from where to get the data. /// /// </param> public ImgWriterPGM(System.String fname, BlkImgDataSrc imgSrc, int c) : this(FileInfoFactory.New(fname), imgSrc, c) { }
public StoreFileInfoCreator() { FileInfoFactory.RegisterCreator(this); }
protected override void Act() { Sut = new FileInfoFactory(FileExtensionFactory, FilenameFactory); }