public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { var viwStream = await fileSystem.OpenFileAsync(filePath); var infStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".inf")); var dataStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension("")); Files = _arc.Load(viwStream, infStream, dataStream); }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { var viwStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); var infStream = fileSystem.OpenFile(savePath.ChangeExtension(".inf"), FileMode.Create, FileAccess.Write); var dataStream = fileSystem.OpenFile(savePath.ChangeExtension(""), FileMode.Create, FileAccess.Write); _arc.Save(viwStream, infStream, dataStream, Files); return(Task.CompletedTask); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { var hedStream = await fileSystem.OpenFileAsync(filePath); var mrgStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension("mrg")); Stream namStream = null; if (fileSystem.FileExists(filePath.ChangeExtension("nam"))) { namStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension("nam")); } Files = _hed.Load(hedStream, mrgStream, namStream); }
public void TestExtensions() { { var path = new UPath("/a/b/c/d.txt"); Assert.Equal(new UPath("/a/b/c"), path.GetDirectory()); Assert.Equal("d.txt", path.GetName()); Assert.Equal("d", path.GetNameWithoutExtension()); Assert.Equal(".txt", path.GetExtensionWithDot()); var newPath = path.ChangeExtension(".zip"); Assert.Equal("/a/b/c/d.zip", newPath.FullName); Assert.Equal(new UPath("a/b/c/d.txt"), path.ToRelative()); Assert.Equal(path, path.AssertAbsolute()); Assert.Throws <ArgumentNullException>(() => new UPath().AssertNotNull()); Assert.Throws <ArgumentException>(() => new UPath("not_absolute").AssertAbsolute()); } { var path = new UPath("d.txt"); Assert.Equal(UPath.Empty, path.GetDirectory()); Assert.Equal("d.txt", path.GetName()); Assert.Equal("d", path.GetNameWithoutExtension()); Assert.Equal(".txt", path.GetExtensionWithDot()); var newPath = path.ChangeExtension(".zip"); Assert.Equal("d.zip", newPath.FullName); Assert.Equal(new UPath("d.txt"), path.ToRelative()); } }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { var dataStream = await fileSystem.OpenFileAsync(filePath); var matStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".sar.mat")); Files = _arc.Load(dataStream, matStream); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { var fileStream = await fileSystem.OpenFileAsync(filePath); var arcName = filePath.ChangeExtension(".arc"); var arcStream = await fileSystem.OpenFileAsync(arcName); Files = _arc.Load(fileStream, arcStream); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { var ncgrStream = await fileSystem.OpenFileAsync(filePath); var nclrStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension("NCLR")); var kanvasImage = new KanvasImage(EncodingDefinition, _ncgr.Load(ncgrStream, nclrStream)); Images = new IKanvasImage[] { kanvasImage }; }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { Stream ltFileStream; Stream lpFileStream; if (savePath.GetExtensionWithDot() == ".lt") { ltFileStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); lpFileStream = fileSystem.OpenFile(savePath.ChangeExtension(".lp"), FileMode.Create, FileAccess.Write); } else { ltFileStream = fileSystem.OpenFile(savePath.ChangeExtension(".lt"), FileMode.Create, FileAccess.Write); lpFileStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); } _img.Save(ltFileStream, lpFileStream, Images[0].ImageInfo); return(Task.CompletedTask); }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { var fileStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); var arcName = savePath.ChangeExtension(".arc"); var arcStream = fileSystem.OpenFile(arcName, FileMode.Create, FileAccess.Write); _arc.Save(fileStream, arcStream, Files); return(Task.CompletedTask); }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { Stream srdStream; Stream srdvStream; if (savePath.GetExtensionWithDot() == ".srd") { srdStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); srdvStream = fileSystem.OpenFile(savePath.ChangeExtension(".srdv"), FileMode.Create, FileAccess.Write); } else { srdStream = fileSystem.OpenFile(savePath.ChangeExtension(".srd"), FileMode.Create, FileAccess.Write); srdvStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); } _img.Save(srdStream, srdvStream, Images.Select(x => x.ImageInfo).ToArray()); return(Task.CompletedTask); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { Stream srdStream; Stream srdvStream; if (filePath.GetExtensionWithDot() == ".srd") { srdStream = await fileSystem.OpenFileAsync(filePath); srdvStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".srdv")); } else { srdStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".srd")); srdvStream = await fileSystem.OpenFileAsync(filePath); } Images = _img.Load(srdStream, srdvStream).Select(x => new KanvasImage(EncodingDefinition, x)).ToArray(); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { var segStream = await fileSystem.OpenFileAsync(filePath); var binStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".BIN")); var sizeName = filePath.GetDirectory() / filePath.GetNameWithoutExtension() + "SIZE.BIN"; var sizeStream = fileSystem.FileExists(sizeName) ? await fileSystem.OpenFileAsync(sizeName) : null; Files = _arc.Load(segStream, binStream, sizeStream); }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { Stream idxStream; Stream binStream; if (savePath.GetExtensionWithDot() == ".idx") { idxStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); binStream = fileSystem.OpenFile(savePath.ChangeExtension(".bin"), FileMode.Create, FileAccess.Write); } else { idxStream = fileSystem.OpenFile(savePath.ChangeExtension(".idx"), FileMode.Create, FileAccess.Write); binStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); } _arc.Save(idxStream, binStream, Files); return(Task.CompletedTask); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { Stream idxStream; Stream binStream; if (filePath.GetExtensionWithDot() == ".idx") { idxStream = await fileSystem.OpenFileAsync(filePath); binStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".bin")); } else { idxStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".idx")); binStream = await fileSystem.OpenFileAsync(filePath); } Files = _arc.Load(idxStream, binStream); }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { var segStream = fileSystem.OpenFile(savePath, FileMode.Create, FileAccess.Write); var binStream = fileSystem.OpenFile(savePath.ChangeExtension(".BIN"), FileMode.Create, FileAccess.Write); var sizeName = savePath.GetDirectory() / savePath.GetNameWithoutExtension() + "SIZE.BIN"; var sizeStream = Files.Any(x => x.UsesCompression) ? fileSystem.OpenFile(sizeName, FileMode.Create, FileAccess.Write) : null; _arc.Save(segStream, binStream, sizeStream, Files); return(Task.CompletedTask); }
public async Task Load(IFileSystem fileSystem, UPath filePath, LoadContext loadContext) { Stream ltFileStream; Stream lpFileStream; if (filePath.GetExtensionWithDot() == ".lt") { ltFileStream = await fileSystem.OpenFileAsync(filePath); lpFileStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".lp")); } else { ltFileStream = await fileSystem.OpenFileAsync(filePath.ChangeExtension(".lt")); lpFileStream = await fileSystem.OpenFileAsync(filePath); } Images = new List <IKanvasImage> { new KanvasImage(EncodingDefinition, _img.Load(ltFileStream, lpFileStream)) }; }
public async Task <bool> IdentifyAsync(IFileSystem fileSystem, UPath filePath, IdentifyContext identifyContext) { filePath = filePath.GetExtensionWithDot() == ".srd" ? filePath : filePath.ChangeExtension(".srd"); if (!fileSystem.FileExists(filePath)) { return(false); } var fileStream = await fileSystem.OpenFileAsync(filePath); using var br = new BinaryReaderX(fileStream); return(br.ReadString(4) == "$CFH"); }
public Task Save(IFileSystem fileSystem, UPath savePath, SaveContext saveContext) { Stream hpiStream; Stream hpbStream; switch (savePath.GetExtensionWithDot()) { case ".HPI": hpiStream = fileSystem.OpenFile(savePath, FileMode.Create); hpbStream = fileSystem.OpenFile(savePath.ChangeExtension("HPB"), FileMode.Create); break; default: hpiStream = fileSystem.OpenFile(savePath.ChangeExtension("HPI"), FileMode.Create); hpbStream = fileSystem.OpenFile(savePath, FileMode.Create); break; } _hpiHpb.Save(hpiStream, hpbStream, Files); return(Task.CompletedTask); }