Move 38 files from root directory into organized subfolders: - Enums/ (7 files): StatusType, ApplicationType, DrawingType, etc. - Geometry/ (5 files): Vector, Box, Size, Spacing, Node - Models/ (15 files): Nest, Plate, Part, Program, Report, etc. - Utilities/ (7 files): MathHelper, Tolerance, ZipHelper, etc. - Extensions/ (2 files): PartListExtensions, PlateListExtensions - Interfaces/ (1 file): IMovable Update namespaces to follow folder hierarchy (e.g., PepLib.Models). Add GlobalUsings.cs for internal backward compatibility. Update Codes/ and IO/ files with new using statements. Update PepApi.Core consumers to reference new namespaces. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using PepLib.IO;
|
|
using System.Text;
|
|
|
|
namespace PepLib.Models
|
|
{
|
|
public class NestIndex
|
|
{
|
|
public string Directory { get; set; }
|
|
|
|
public List<NestInfo> Entries;
|
|
|
|
public NestIndex()
|
|
{
|
|
Entries = new List<NestInfo>();
|
|
}
|
|
|
|
public string GetPath(NestInfo entry)
|
|
{
|
|
return Path.Combine(Directory, entry.Name + ".zip");
|
|
}
|
|
|
|
public static NestIndex LoadFromDir(string directory)
|
|
{
|
|
var file = Path.Combine(directory, "pepfiles.lfn");
|
|
return Load(file);
|
|
}
|
|
|
|
public static NestIndex Load(string file)
|
|
{
|
|
if (!File.Exists(file))
|
|
return null;
|
|
|
|
var index = new NestIndex() { Directory = Path.GetDirectoryName(file) };
|
|
var stream = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
|
var reader = new StreamReader(stream);
|
|
var buffer = new char[4000];
|
|
|
|
while (reader.Read(buffer, 0, buffer.Length) > 0)
|
|
{
|
|
var memstream = new MemoryStream(Encoding.ASCII.GetBytes(buffer));
|
|
var inforeader = new NestInfoReader();
|
|
|
|
inforeader.Read(memstream);
|
|
index.Entries.Add(inforeader.Info);
|
|
}
|
|
|
|
reader.Close();
|
|
|
|
return index;
|
|
}
|
|
|
|
public static NestIndex Build(string directory)
|
|
{
|
|
var index = new NestIndex() { Directory = directory };
|
|
|
|
foreach (var file in System.IO.Directory.GetFiles(directory, "*.zip"))
|
|
{
|
|
var reader = new NestInfoReader();
|
|
reader.Read(file);
|
|
index.Entries.Add(reader.Info);
|
|
}
|
|
|
|
return index;
|
|
}
|
|
}
|
|
}
|