private void AddFileSystemEntry(Disk disk, FileSystemDiskEntry fs, ref int maxOffset) { int offset = maxOffset; var data = disk.GetData(); Array.Copy(fs.Words, 0, data, offset, fs.Words.Length); disk.SetData(data); offset += fs.Words.Length; maxOffset = Math.Max(offset, maxOffset); }
public BuildOutput Build(IBuildManager manager, ISolution solution, IProject project, IBuildProgressMonitor monitor) { var watch = new Stopwatch(); var entries = new List<DiskEntry>(); var buildSvc = this._workspace.GetService<ISimpleFileBuildService>(); var msgs = new List<ICompileMessage>(); var projPath = Path.GetDirectoryName(project.AbsolutePath); var fname = Path.Combine(projPath, project.GetProperty("outputFilename")); watch.Start(); foreach (var file in project.Files) { DiskEntry newEntry; var fet = file.GetProperty("disk.entryTypeName"); var op = buildSvc.Build(manager, solution, project, file, monitor, false); ushort[] words = op.Words; msgs.AddRange(op.Messages); if (!op.Success || words == null) { monitor.StatusUpdate("Build failed for " + file.AbsolutePath); return new BuildOutput { Success = false, Time = watch.Elapsed, Messages = msgs }; } switch (fet) { case "sector": newEntry = new SpecificSectorDiskEntry { Name = file.Path, Sector = int.Parse(file.GetProperty("disk.index") ?? "0"), Words = words }; break; case "offset": newEntry = new SpecificOffsetDiskEntry { Name = file.Path, Offset = int.Parse(file.GetProperty("disk.index") ?? "0"), Words = words }; break; case null: case "": case "fileSystem": newEntry = new FileSystemDiskEntry { Name = file.Path, Path = file.Path, Words = words }; break; default: continue; } entries.Add(newEntry); } var disk = new Disk(this._plugin, project.Name, fname); disk.Compress = bool.Parse(project.GetProperty("compress") ?? "true"); var provider = this._workspace.GetServices<IDiskFormatProvider>().Single(df => df.FormatName == project.GetProperty("filesystem.type")); provider.BuildDisk(disk, entries); disk.Save(); watch.Stop(); if (bool.Parse(project.GetProperty("autoLoad.enabled") ?? "false")) { int driveIndex = int.Parse(project.GetProperty("autoLoad.drive") ?? "0"); this._plugin.LoadDisk(driveIndex, disk); } return new BuildOutput { CodeModel = null, DebugInfo = null, Messages = msgs, Success = true, Time = watch.Elapsed, Words = disk.GetData() }; }