Path Manager - change MakeAbsolutePath to take a default system parameter rather than requiring a useless empty parameter, and change all references to it accordingly

This commit is contained in:
adelikat 2012-12-30 17:52:40 +00:00
parent 926cf64fe7
commit 09da012d94
10 changed files with 32 additions and 32 deletions

View File

@ -407,11 +407,11 @@ namespace BizHawk.MultiClient
target.SMS_ShowBG = Global.Config.SMSDispBG;
target.SMS_ShowOBJ = Global.Config.SMSDispOBJ;
target.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, ""); // PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
target.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
target.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, ""); // PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
target.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
target.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, ""); // PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
target.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath); // PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
target.SNES_ShowBG1_0 = Global.Config.SNES_ShowBG1_0;
target.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_1;
target.SNES_ShowBG2_0 = Global.Config.SNES_ShowBG2_0;
@ -4119,12 +4119,12 @@ namespace BizHawk.MultiClient
if (!(Global.Emulator is NullEmulator))
{
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath);
}
else
{
sfd.FileName = "NULL";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.AVIPath);
}
sfd.Filter = String.Format("{0} (*.{0})|*.{0}|All Files|*.*", aw.DesiredExtension());
@ -4356,7 +4356,7 @@ namespace BizHawk.MultiClient
void ProcessMovieImport(string fn)
{
var file = new FileInfo(fn);
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
string errorMsg = "";
string warningMsg = "";
Movie m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg);

View File

@ -79,7 +79,7 @@ namespace BizHawk.MultiClient
private void BrowseMovies_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
ofd.Filter = filter;
@ -284,7 +284,7 @@ namespace BizHawk.MultiClient
{
ClearList();
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
string d = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
if (!Directory.Exists(d))
Directory.CreateDirectory(d);
string extension = "*." + Global.Config.MovieExtension;

View File

@ -38,7 +38,7 @@ namespace BizHawk.MultiClient
{
if (path[0] != '\\')
path = path.Insert(0, "\\");
path = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "") + path;
path = PathManager.MakeAbsolutePath(Global.Config.MoviesPath) + path;
if (path[path.Length - 4] != '.') //If no file extension, add movie extension
path += "." + Global.Config.MovieExtension;
@ -165,7 +165,7 @@ namespace BizHawk.MultiClient
{
string filename = "";
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
sfd.DefaultExt = "." + Global.Config.MovieExtension;
sfd.FileName = RecordBox.Text;
sfd.OverwritePrompt = false;

View File

@ -470,7 +470,7 @@ namespace BizHawk.MultiClient
{
FolderBrowserDialog f = new FolderBrowserDialog();
f.Description = "Set the directory for " + Name;
f.SelectedPath = PathManager.MakeAbsolutePath(box.Text, "");
f.SelectedPath = PathManager.MakeAbsolutePath(box.Text);
DialogResult result = f.ShowDialog();
if (result == DialogResult.OK)
box.Text = f.SelectedPath;
@ -1080,7 +1080,7 @@ namespace BizHawk.MultiClient
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin,*.pce)|*.rom;*.bin;*.pce|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();
@ -1094,7 +1094,7 @@ namespace BizHawk.MultiClient
private void NESBrowseFDSBIOS_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin)|*.rom;*.bin|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();
@ -1108,7 +1108,7 @@ namespace BizHawk.MultiClient
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin)|*.rom;*.bin|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();
@ -1122,7 +1122,7 @@ namespace BizHawk.MultiClient
private void button4_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin)|*.rom;*.bin|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();
@ -1141,7 +1141,7 @@ namespace BizHawk.MultiClient
private void Atari7800BrowseNTSCBIOS_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin)|*.rom;*.bin|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();
@ -1155,7 +1155,7 @@ namespace BizHawk.MultiClient
private void Atari7800BrowsePALBIOS_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin)|*.rom;*.bin|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();
@ -1169,7 +1169,7 @@ namespace BizHawk.MultiClient
private void Atari7800BrowseHSCBIOS_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.FirmwaresPath);
ofd.Filter = "Binary Files (*.rom,*.bin)|*.rom;*.bin|All Files|*.*";
ofd.RestoreDirectory = false;
DialogResult result = ofd.ShowDialog();

View File

@ -19,7 +19,7 @@ namespace BizHawk.MultiClient
/// <summary>
/// Makes a path relative to the %exe% dir
/// </summary>
public static string MakeProgramRelativePath(string path) { return MakeAbsolutePath("%exe%/" + path, ""); }
public static string MakeProgramRelativePath(string path) { return MakeAbsolutePath("%exe%/" + path); }
/// <summary>
/// The location of the default INI file
@ -110,10 +110,10 @@ namespace BizHawk.MultiClient
public static string StandardFirmwareName(string name)
{
return Path.Combine(MakeAbsolutePath(Global.Config.FirmwaresPath, ""), name);
return Path.Combine(MakeAbsolutePath(Global.Config.FirmwaresPath), name);
}
public static string MakeAbsolutePath(string path, string system)
public static string MakeAbsolutePath(string path, string system = null)
{
//This function translates relative path and special identifiers in absolute paths
@ -139,7 +139,7 @@ namespace BizHawk.MultiClient
if (path[0] == '.')
{
if (system.Length > 0)
if (!String.IsNullOrWhiteSpace(system))
{
path = path.Remove(0, 1);
@ -219,7 +219,7 @@ namespace BizHawk.MultiClient
public static string GetLuaPath()
{
return MakeAbsolutePath(Global.Config.LuaPath, "");
return MakeAbsolutePath(Global.Config.LuaPath);
}
public static string GetRomsPath(string sysID)
@ -282,7 +282,7 @@ namespace BizHawk.MultiClient
path = PathManager.MakeAbsolutePath(Global.Config.PathCOLROMs, "Coleco");
break;
default:
path = PathManager.MakeAbsolutePath(Global.Config.BaseROMPath, "");
path = PathManager.MakeAbsolutePath(Global.Config.BaseROMPath);
break;
}

View File

@ -1886,7 +1886,7 @@ namespace BizHawk.MultiClient
var ofd = new OpenFileDialog();
if (currentFile.Length > 0)
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
ofd.RestoreDirectory = true;
if (currentFile.Length > 0)

View File

@ -592,7 +592,7 @@ namespace BizHawk.MultiClient
var ofd = new OpenFileDialog();
if (currentFile.Length > 0)
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
ofd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
ofd.RestoreDirectory = true;

View File

@ -453,7 +453,7 @@ namespace BizHawk.MultiClient
private static string SaveRecordingAs()
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.MoviesPath);
sfd.DefaultExt = "." + Global.Config.MovieExtension;
sfd.FileName = Global.MovieSession.Movie.Filename;
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";

View File

@ -242,7 +242,7 @@ namespace BizHawk.MultiClient
FileBox.Visible = true;
BrowseBox.Visible = true;
string name = PathManager.FilesystemSafeName(Global.Game);
string filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.LogPath, ""), name) + ".txt";
string filename = Path.Combine(PathManager.MakeAbsolutePath(Global.Config.LogPath), name) + ".txt";
LogFile = new FileInfo(filename);
if (!LogFile.Directory.Exists)
{
@ -313,7 +313,7 @@ namespace BizHawk.MultiClient
{
string name = PathManager.FilesystemSafeName(Global.Game);
sfd.FileName = name + ".txt";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LogPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LogPath);
}
else if (!String.IsNullOrWhiteSpace(LogFile.FullName))
{
@ -323,7 +323,7 @@ namespace BizHawk.MultiClient
else
{
sfd.FileName = Path.GetFileNameWithoutExtension(LogFile.FullName);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LogPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.LogPath);
}
sfd.Filter = "Text Files (*.txt)|*.txt|Log Files (*.log)|*.log|All Files|*.*";

View File

@ -196,12 +196,12 @@ namespace BizHawk.MultiClient
else if (!(Global.Emulator is NullEmulator))
{
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
}
else
{
sfd.FileName = "NULL";
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath, "");
sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.WatchPath);
}
sfd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*";
sfd.RestoreDirectory = true;