public bool SaveHouse(int houseID, Files.Formats.IFF.IffFile file) { using (var stream = new FileStream(GetHousePath(houseID), FileMode.Create, FileAccess.Write, FileShare.None)) file.Write(stream); return(true); }
public void SaveChange(Files.Formats.IFF.IffFile file) { lock (this) { if (file.RuntimeInfo.State == IffRuntimeState.Standalone) { //just save out iff var filename = file.RuntimeInfo.Path; Directory.CreateDirectory(Path.GetDirectoryName(filename)); using (var stream = new FileStream(filename, FileMode.Create)) file.Write(stream); foreach (var chunk in file.ListAll()) { chunk.RuntimeInfo = ChunkRuntimeState.Normal; } } else { string dest = Path.Combine(FSOEnvironment.ContentDir, ((file.RuntimeInfo.State == IffRuntimeState.PIFFClone) ? "Objects/" : "Patch/User/")); Directory.CreateDirectory(dest); if (file.RuntimeInfo.State == IffRuntimeState.ReadOnly) { file.RuntimeInfo.State = IffRuntimeState.PIFFPatch; } var stringResources = new HashSet <Type> { typeof(STR), typeof(CTSS), typeof(TTAs) }; var sprites = (file.RuntimeInfo.UseCase == IffUseCase.ObjectSprites); file.RuntimeInfo.Patches.Clear(); var piff = FSO.Files.Formats.PiffEncoder.GeneratePiff(file, null, stringResources); string name = file.Filename.Substring(0, file.Filename.Length - 4); //get without extension if (piff != null) { var filename = dest + name + (sprites ? ".spf" : "") + ".piff"; using (var stream = new FileStream(filename, FileMode.Create)) piff.Write(stream); file.RuntimeInfo.Patches.Add(piff); } if (!sprites) { piff = FSO.Files.Formats.PiffEncoder.GeneratePiff(file, stringResources, null); if (piff != null) { var filename = dest + name + ".str.piff"; using (var stream = new FileStream(filename, FileMode.Create)) piff.Write(stream); file.RuntimeInfo.Patches.Add(piff); } } } file.RuntimeInfo.Dirty = false; ChangedFiles.Remove(file); } }
public bool SaveNeighbourhood(bool withSims) { //todo: save iffs for dirty avatars. DirtyAvatars.Clear(); using (var stream = new FileStream(Path.Combine(UserPath, "Neighborhood.iff"), FileMode.Create, FileAccess.Write, FileShare.None)) MainResource.Write(stream); return(true); }