Package 업데이트 분리 작업 진행중
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
@@ -30,7 +31,9 @@ namespace CommonLibrary
|
||||
}
|
||||
|
||||
public override void Flush() => insideStream.Flush();
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin) => insideStream.Seek(offset, origin);
|
||||
|
||||
public override void SetLength(long value) => insideStream.SetLength(value);
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
@@ -116,6 +119,62 @@ namespace CommonLibrary
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<PackList> GetTopLevelItem(string packFileName)
|
||||
{
|
||||
List<PackList> packLists = new List<PackList>();
|
||||
|
||||
using (ZipArchive archive = ZipFile.OpenRead(packFileName))
|
||||
{
|
||||
// 최상위 항목들(폴더/파일명) 추출
|
||||
|
||||
var results = new List<PackList>();
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var entry in archive.Entries)
|
||||
{
|
||||
string path = entry.FullName.Replace('\\', '/');
|
||||
if (string.IsNullOrEmpty(path)) continue;
|
||||
|
||||
int firstSlash = path.IndexOf('/');
|
||||
|
||||
if (firstSlash < 0)
|
||||
{
|
||||
// ZIP 루트에 바로 들어있는 항목
|
||||
if (string.IsNullOrEmpty(entry.Name))
|
||||
{
|
||||
// 디렉터리 엔트리
|
||||
if (seen.Add(path.TrimEnd('/')))
|
||||
results.Add(new PackList { IsDirectory = true, Name = path.TrimEnd('/') });
|
||||
}
|
||||
else
|
||||
{
|
||||
// 파일
|
||||
if (seen.Add(path))
|
||||
results.Add(new PackList { IsDirectory = false, Name = path });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 하위 경로가 있음 → 최상위는 폴더
|
||||
string top = path.Substring(0, firstSlash);
|
||||
if (!string.IsNullOrEmpty(top) && seen.Add(top))
|
||||
{
|
||||
results.Add(new PackList { IsDirectory = true, Name = top });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
public struct PackList
|
||||
|
||||
{
|
||||
public bool IsDirectory { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class BasicProgress<T> : IProgress<T>
|
||||
@@ -132,4 +191,4 @@ namespace CommonLibrary
|
||||
actionHandler(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user