From 5db79c6e267eea1468524800a1e8e480ec5d85ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D0=BD=D1=8C=D0=BA=D0=B8=D0=BD=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Wed, 12 Oct 2022 14:35:20 +0300 Subject: [PATCH] fix cpio reader --- NyaFs/Filesystem/Cpio/CpioFsBuilder.cs | 1 + NyaFs/Filesystem/Cpio/CpioFsReader.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NyaFs/Filesystem/Cpio/CpioFsBuilder.cs b/NyaFs/Filesystem/Cpio/CpioFsBuilder.cs index f64d2d9..fa513fb 100644 --- a/NyaFs/Filesystem/Cpio/CpioFsBuilder.cs +++ b/NyaFs/Filesystem/Cpio/CpioFsBuilder.cs @@ -2,6 +2,7 @@ using NyaFs.Filesystem.Universal; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text; namespace NyaFs.Filesystem.Cpio diff --git a/NyaFs/Filesystem/Cpio/CpioFsReader.cs b/NyaFs/Filesystem/Cpio/CpioFsReader.cs index bfb3edb..d76a824 100644 --- a/NyaFs/Filesystem/Cpio/CpioFsReader.cs +++ b/NyaFs/Filesystem/Cpio/CpioFsReader.cs @@ -80,7 +80,7 @@ public string ReadLink(string Path) { if (UnifyPath(N.Path) == UnifyPath(Path)) { - if (N.FileType == Types.CpioModeFileType.C_ISREG) + if (N.FileType == Types.CpioModeFileType.C_ISLNK) return UTF8Encoding.UTF8.GetString(N.Content); else return null; @@ -124,6 +124,8 @@ public FilesystemEntry[] ReadDir(string Path) Pos = Pos + Path.Length + 1; if((Pos < UPath.Length) && UPath.IndexOf('/', Pos) < 0) { + if ((Path.Length > 0) && UPath[Path.Length] != '/') continue; + Res.Add(new FilesystemEntry(N.FsType, UPath, N.UserId, N.GroupId, N.HexMode, Convert.ToUInt32(N.Content.Length))); } }