mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-27 14:02:19 +00:00
File.Exists works for files in subdirectories as well.
This commit is contained in:
parent
667861ebe3
commit
65fdc07bad
4 changed files with 73 additions and 54 deletions
|
|
@ -41,7 +41,7 @@ namespace SentinelKernel
|
||||||
}
|
}
|
||||||
Console.WriteLine("Subfolder exists as well!");
|
Console.WriteLine("Subfolder exists as well!");
|
||||||
|
|
||||||
xTest = File.Exists(@"0:\Kudzu.txt");
|
xTest = File.Exists(@"0:\KudzU.txt");
|
||||||
if (!xTest)
|
if (!xTest)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"\Kudzu.txt not found!");
|
Console.WriteLine(@"\Kudzu.txt not found!");
|
||||||
|
|
@ -50,6 +50,15 @@ namespace SentinelKernel
|
||||||
|
|
||||||
Console.WriteLine("Kudzu.txt found!");
|
Console.WriteLine("Kudzu.txt found!");
|
||||||
|
|
||||||
|
xTest = File.Exists(@"0:\Test\DirInTest\Readme.txt");
|
||||||
|
if (!xTest)
|
||||||
|
{
|
||||||
|
Console.WriteLine(@"\Test\DirInTest\Readme.txt not found!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine(@"Test\DirInTest\Readme.txt found!");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -241,17 +241,20 @@ namespace SentinelKernel.System.FileSystem.FAT
|
||||||
{
|
{
|
||||||
var xResult = new List<Base>();
|
var xResult = new List<Base>();
|
||||||
//TODO: Change xLongName to StringBuilder
|
//TODO: Change xLongName to StringBuilder
|
||||||
|
string xLongName = "";
|
||||||
|
string xName = "";
|
||||||
for (UInt32 i = 0; i < xData.Length; i = i + 32)
|
for (UInt32 i = 0; i < xData.Length; i = i + 32)
|
||||||
{
|
{
|
||||||
FatHelpers.Debug("-------------------------------------------------");
|
FatHelpers.Debug("-------------------------------------------------");
|
||||||
string xLongName = "";
|
|
||||||
byte xAttrib = xData[i + 11];
|
byte xAttrib = xData[i + 11];
|
||||||
FatHelpers.Debug("Attrib = " + xAttrib.ToString());
|
byte xStatus = xData[i];
|
||||||
|
|
||||||
|
FatHelpers.Debug("Attrib = " + xAttrib.ToString() + ", Status = " + xStatus);
|
||||||
if (xAttrib == DirectoryEntryAttributeConsts.LongName)
|
if (xAttrib == DirectoryEntryAttributeConsts.LongName)
|
||||||
{
|
{
|
||||||
byte xType = xData[i + 12];
|
byte xType = xData[i + 12];
|
||||||
byte xOrd = xData[i];
|
byte xOrd = xData[i];
|
||||||
FatHelpers.Debug("Reading LFN with Seqnr " + xOrd.ToString());
|
FatHelpers.Debug("Reading LFN with Seqnr " + xOrd.ToString() + ", Type = " + xType);
|
||||||
if (xOrd == 0xE5)
|
if (xOrd == 0xE5)
|
||||||
{
|
{
|
||||||
FatHelpers.Debug("Skipping deleted entry");
|
FatHelpers.Debug("Skipping deleted entry");
|
||||||
|
|
@ -280,11 +283,13 @@ namespace SentinelKernel.System.FileSystem.FAT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xLongName = xLongPart + xLongName;
|
xLongName = xLongPart + xLongName;
|
||||||
|
xLongPart = null;
|
||||||
//TODO: LDIR_Chksum
|
//TODO: LDIR_Chksum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string xName = xLongName;
|
else
|
||||||
byte xStatus = xData[i];
|
{
|
||||||
|
xName = xLongName;
|
||||||
if (xStatus == 0x00)
|
if (xStatus == 0x00)
|
||||||
{
|
{
|
||||||
// Empty slot, and no more entries after this
|
// Empty slot, and no more entries after this
|
||||||
|
|
@ -323,6 +328,7 @@ namespace SentinelKernel.System.FileSystem.FAT
|
||||||
//Substring to remove the periods
|
//Substring to remove the periods
|
||||||
xName = xName.Substring(0, nameIndex + 1);
|
xName = xName.Substring(0, nameIndex + 1);
|
||||||
}
|
}
|
||||||
|
xLongName = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -335,10 +341,16 @@ namespace SentinelKernel.System.FileSystem.FAT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
UInt32 xFirstCluster = (UInt32)(xData.ToUInt16(i + 20) << 16 | xData.ToUInt16(i + 26));
|
UInt32 xFirstCluster = (UInt32)(xData.ToUInt16(i + 20) << 16 | xData.ToUInt16(i + 26));
|
||||||
|
|
||||||
var xTest = xAttrib & (DirectoryEntryAttributeConsts.Directory | DirectoryEntryAttributeConsts.VolumeID);
|
var xTest = xAttrib & (DirectoryEntryAttributeConsts.Directory | DirectoryEntryAttributeConsts.VolumeID);
|
||||||
if (xTest == 0)
|
if (xAttrib == DirectoryEntryAttributeConsts.LongName)
|
||||||
|
{
|
||||||
|
// skip adding, as it's a LongFileName entry, meaning the next normal entry is the item with the name.
|
||||||
|
FatHelpers.Debug("Entry was an Long FileName entry. Current LongName = '" + xLongName + "'");
|
||||||
|
}
|
||||||
|
else if (xTest == 0)
|
||||||
{
|
{
|
||||||
UInt32 xSize = xData.ToUInt32(i + 28);
|
UInt32 xSize = xData.ToUInt32(i + 28);
|
||||||
if (xSize == 0 && xName.Length == 0)
|
if (xSize == 0 && xName.Length == 0)
|
||||||
|
|
@ -348,11 +360,11 @@ namespace SentinelKernel.System.FileSystem.FAT
|
||||||
xResult.Add(new FatFile(this, xName, xSize, xFirstCluster));
|
xResult.Add(new FatFile(this, xName, xSize, xFirstCluster));
|
||||||
FatHelpers.Debug("Returning file '" + xName + "'");
|
FatHelpers.Debug("Returning file '" + xName + "'");
|
||||||
}
|
}
|
||||||
else if (xTest == DirectoryEntryAttributeConsts.Directory || xAttrib == DirectoryEntryAttributeConsts.LongName)
|
else if (xTest == DirectoryEntryAttributeConsts.Directory)
|
||||||
{
|
{
|
||||||
UInt32 xSize = xData.ToUInt32(i + 28);
|
UInt32 xSize = xData.ToUInt32(i + 28);
|
||||||
var xFatDirectory = new FatDirectory(this, xName, xFirstCluster);
|
var xFatDirectory = new FatDirectory(this, xName, xFirstCluster);
|
||||||
FatHelpers.Debug("Returning directory '" + xFatDirectory.Name + "'");
|
FatHelpers.Debug("Returning directory '" + xFatDirectory.Name + "', FirstCluster = " + xFirstCluster);
|
||||||
xResult.Add(xFatDirectory);
|
xResult.Add(xFatDirectory);
|
||||||
}
|
}
|
||||||
else if (xTest == DirectoryEntryAttributeConsts.VolumeID)
|
else if (xTest == DirectoryEntryAttributeConsts.VolumeID)
|
||||||
|
|
@ -364,7 +376,6 @@ namespace SentinelKernel.System.FileSystem.FAT
|
||||||
{
|
{
|
||||||
FatHelpers.Debug("Not sure what to do!");
|
FatHelpers.Debug("Not sure what to do!");
|
||||||
}
|
}
|
||||||
xLongName = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return xResult;
|
return xResult;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace SentinelKernel.System.FileSystem
|
||||||
private static Debugger mDebugger = new Debugger("FAT", "Debug");
|
private static Debugger mDebugger = new Debugger("FAT", "Debug");
|
||||||
public static void Debug(string message)
|
public static void Debug(string message)
|
||||||
{
|
{
|
||||||
mDebugger.Send("FAT Debug: " + message);
|
//mDebugger.Send("FAT Debug: " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,6 @@ namespace SentinelKernel.System.FileSystem.VFS
|
||||||
xDirectory = xDirectory + Path.DirectorySeparatorChar;
|
xDirectory = xDirectory + Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var xList = GetDirectoryListing(xDirectory);
|
var xList = GetDirectoryListing(xDirectory);
|
||||||
for (int i = 0; i < xList.Count; i++)
|
for (int i = 0; i < xList.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue