Adjust naming conventions and general refactoring in HLE Project (#527)

* Rename enum fields

* Naming conventions

* Remove unneeded ".this"

* Remove unneeded semicolons

* Remove unused Usings

* Don't use var

* Remove unneeded enum underlying types

* Explicitly label class visibility

* Remove unneeded @ prefixes

* Remove unneeded commas

* Remove unneeded if expressions

* Method doesn't use unsafe code

* Remove unneeded casts

* Initialized objects don't need an empty constructor

* Remove settings from DotSettings

* Revert "Explicitly label class visibility"

This reverts commit ad5eb5787cc5b27a4631cd46ef5f551c4ae95e51.

* Small changes

* Revert external enum renaming

* Changes from feedback

* Apply previous refactorings to the merged code
This commit is contained in:
Alex Barney 2018-12-06 05:16:24 -06:00 committed by gdkchan
parent 3615a70cae
commit fb1d9493a3
298 changed files with 12034 additions and 12037 deletions

View file

@ -18,40 +18,40 @@ namespace Ryujinx.HLE.FileSystem
public Stream RomFs { get; private set; }
public void LoadRomFs(string FileName)
public void LoadRomFs(string fileName)
{
RomFs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
RomFs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
}
public void SetRomFs(Stream RomfsStream)
public void SetRomFs(Stream romfsStream)
{
RomFs?.Close();
RomFs = RomfsStream;
RomFs = romfsStream;
}
public string GetFullPath(string BasePath, string FileName)
public string GetFullPath(string basePath, string fileName)
{
if (FileName.StartsWith("//"))
if (fileName.StartsWith("//"))
{
FileName = FileName.Substring(2);
fileName = fileName.Substring(2);
}
else if (FileName.StartsWith('/'))
else if (fileName.StartsWith('/'))
{
FileName = FileName.Substring(1);
fileName = fileName.Substring(1);
}
else
{
return null;
}
string FullPath = Path.GetFullPath(Path.Combine(BasePath, FileName));
string fullPath = Path.GetFullPath(Path.Combine(basePath, fileName));
if (!FullPath.StartsWith(GetBasePath()))
if (!fullPath.StartsWith(GetBasePath()))
{
return null;
}
return FullPath;
return fullPath;
}
public string GetSdCardPath() => MakeDirAndGetFullPath(SdCardPath);
@ -60,84 +60,84 @@ namespace Ryujinx.HLE.FileSystem
public string GetSystemPath() => MakeDirAndGetFullPath(SystemPath);
public string GetGameSavePath(SaveInfo Save, ServiceCtx Context)
public string GetGameSavePath(SaveInfo save, ServiceCtx context)
{
return MakeDirAndGetFullPath(SaveHelper.GetSavePath(Save, Context));
return MakeDirAndGetFullPath(SaveHelper.GetSavePath(save, context));
}
public string GetFullPartitionPath(string PartitionPath)
public string GetFullPartitionPath(string partitionPath)
{
return MakeDirAndGetFullPath(PartitionPath);
return MakeDirAndGetFullPath(partitionPath);
}
public string SwitchPathToSystemPath(string SwitchPath)
public string SwitchPathToSystemPath(string switchPath)
{
string[] Parts = SwitchPath.Split(":");
string[] parts = switchPath.Split(":");
if (Parts.Length != 2)
if (parts.Length != 2)
{
return null;
}
return GetFullPath(MakeDirAndGetFullPath(Parts[0]), Parts[1]);
return GetFullPath(MakeDirAndGetFullPath(parts[0]), parts[1]);
}
public string SystemPathToSwitchPath(string SystemPath)
public string SystemPathToSwitchPath(string systemPath)
{
string BaseSystemPath = GetBasePath() + Path.DirectorySeparatorChar;
string baseSystemPath = GetBasePath() + Path.DirectorySeparatorChar;
if (SystemPath.StartsWith(BaseSystemPath))
if (systemPath.StartsWith(baseSystemPath))
{
string RawPath = SystemPath.Replace(BaseSystemPath, "");
int FirstSeparatorOffset = RawPath.IndexOf(Path.DirectorySeparatorChar);
string rawPath = systemPath.Replace(baseSystemPath, "");
int firstSeparatorOffset = rawPath.IndexOf(Path.DirectorySeparatorChar);
if (FirstSeparatorOffset == -1)
if (firstSeparatorOffset == -1)
{
return $"{RawPath}:/";
return $"{rawPath}:/";
}
string BasePath = RawPath.Substring(0, FirstSeparatorOffset);
string FileName = RawPath.Substring(FirstSeparatorOffset + 1);
string basePath = rawPath.Substring(0, firstSeparatorOffset);
string fileName = rawPath.Substring(firstSeparatorOffset + 1);
return $"{BasePath}:/{FileName}";
return $"{basePath}:/{fileName}";
}
return null;
}
private string MakeDirAndGetFullPath(string Dir)
private string MakeDirAndGetFullPath(string dir)
{
// Handles Common Switch Content Paths
switch (Dir)
switch (dir)
{
case ContentPath.SdCard:
case "@Sdcard":
Dir = SdCardPath;
dir = SdCardPath;
break;
case ContentPath.User:
Dir = UserNandPath;
dir = UserNandPath;
break;
case ContentPath.System:
Dir = SystemNandPath;
dir = SystemNandPath;
break;
case ContentPath.SdCardContent:
Dir = Path.Combine(SdCardPath, "Nintendo", "Contents");
dir = Path.Combine(SdCardPath, "Nintendo", "Contents");
break;
case ContentPath.UserContent:
Dir = Path.Combine(UserNandPath, "Contents");
dir = Path.Combine(UserNandPath, "Contents");
break;
case ContentPath.SystemContent:
Dir = Path.Combine(SystemNandPath, "Contents");
dir = Path.Combine(SystemNandPath, "Contents");
break;
}
string FullPath = Path.Combine(GetBasePath(), Dir);
string fullPath = Path.Combine(GetBasePath(), dir);
if (!Directory.Exists(FullPath))
if (!Directory.Exists(fullPath))
{
Directory.CreateDirectory(FullPath);
Directory.CreateDirectory(fullPath);
}
return FullPath;
return fullPath;
}
public DriveInfo GetDrive()
@ -147,9 +147,9 @@ namespace Ryujinx.HLE.FileSystem
public string GetBasePath()
{
string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
return Path.Combine(AppDataPath, BasePath);
return Path.Combine(appDataPath, BasePath);
}
public void Dispose()