fix bug with symbolic links

This commit is contained in:
Persephone Bubblegum-Holiday 2025-02-28 22:13:55 -07:00
parent 6757602b00
commit 6567881ce5

View file

@ -59,9 +59,12 @@ namespace AFCExplorer
{
if (fn == "." || fn == "..") continue;
afc.afc_get_file_info(afcHandle, path + fn, out ReadOnlyCollection<string> fileInfo).ThrowOnError();
string readableSize = FormatBytes(ulong.Parse(fileInfo[1]));
string readableType = fileInfo[7] == "S_IFDIR" ? "Directory" : "File";
int unixSeconds = (int)(((long.Parse(fileInfo[9]) / 1000) / 1000) / 1000);
Dictionary<string, string> fileInfoD = new Dictionary<string, string>();
for (int i = 0; i < fileInfo.Count; i += 2) fileInfoD.Add(fileInfo[i], fileInfo[i+1]);
//MessageBox.Show(string.Join("\n", fileInfo));
string readableSize = FormatBytes(ulong.Parse(fileInfoD["st_size"]));
string readableType = ReadableTypes[fileInfoD["st_ifmt"]];
int unixSeconds = (int)(((long.Parse(fileInfoD["st_mtime"]) / 1000) / 1000) / 1000);
string readableTime = DateTimeOffset.FromUnixTimeSeconds(unixSeconds).DateTime.ToString();
afcDirectory.Add(new AFCFileType(fn, readableType, readableTime, readableSize));
}
@ -359,5 +362,12 @@ namespace AFCExplorer
return string.Format("{0:0.##} {1}", dblSByte, Suffix[i]);
}
public static Dictionary<string, string> ReadableTypes = new Dictionary<string, string>
{
{ "S_IFDIR", "Directory" },
{ "S_IFREG", "File" },
{ "S_IFLNK", "Symbolic Link" },
};
}
}