mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Handle invalid characters in shader filename paths everywhere
This commit is contained in:
@@ -366,9 +366,44 @@ namespace renderdoc
|
||||
public struct DebugFile
|
||||
{
|
||||
[CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)]
|
||||
public string filename;
|
||||
private string filename_;
|
||||
[CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)]
|
||||
public string filetext;
|
||||
|
||||
public string FullFilename
|
||||
{
|
||||
get
|
||||
{
|
||||
return filename_;
|
||||
}
|
||||
}
|
||||
|
||||
// get filename handling possibly invalid characters
|
||||
public string BaseFilename
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return System.IO.Path.GetFileName(filename_);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// invalid path or similar, just try to go from last \ or / onwards
|
||||
|
||||
string ret = filename_;
|
||||
int idx = ret.LastIndexOfAny(new char[] { '/', '\\' });
|
||||
if (idx > 0)
|
||||
ret = ret.Substring(idx + 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
filename_ = value;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[CustomMarshalAs(CustomUnmanagedType.TemplatedArray)]
|
||||
|
||||
@@ -229,19 +229,7 @@ namespace renderdocui.Windows.PipelineState
|
||||
if (entryFile < 0 || entryFile >= shaderDetails.DebugInfo.files.Length)
|
||||
entryFile = 0;
|
||||
|
||||
try
|
||||
{
|
||||
shaderfn = Path.GetFileName(shaderDetails.DebugInfo.files[entryFile].filename);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
// invalid path or similar, just try to go from last \ or / onwards
|
||||
|
||||
shaderfn = shaderDetails.DebugInfo.files[entryFile].filename;
|
||||
int idx = shaderfn.LastIndexOfAny(new char[] { '/', '\\' });
|
||||
if (idx > 0)
|
||||
shaderfn = shaderfn.Substring(idx + 1);
|
||||
}
|
||||
shaderfn = shaderDetails.DebugInfo.files[entryFile].BaseFilename;
|
||||
|
||||
shader.Text = shaderDetails.DebugInfo.entryFunc + "()" + " - " + shaderfn;
|
||||
}
|
||||
@@ -1901,13 +1889,13 @@ namespace renderdocui.Windows.PipelineState
|
||||
entryFunc = shaderDetails.DebugInfo.entryFunc;
|
||||
|
||||
foreach (var s in shaderDetails.DebugInfo.files)
|
||||
files.Add(Path.GetFileName(s.filename), s.filetext);
|
||||
files.Add(s.BaseFilename, s.filetext);
|
||||
|
||||
int entryFile = shaderDetails.DebugInfo.entryFile;
|
||||
if (entryFile < 0 || entryFile >= shaderDetails.DebugInfo.files.Length)
|
||||
entryFile = 0;
|
||||
|
||||
mainfile = Path.GetFileName(shaderDetails.DebugInfo.files[entryFile].filename);
|
||||
mainfile = shaderDetails.DebugInfo.files[entryFile].BaseFilename;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2728,7 +2716,7 @@ namespace renderdocui.Windows.PipelineState
|
||||
|
||||
if (shaderDetails != null && shaderDetails.DebugInfo.entryFunc.Length > 0 && shaderDetails.DebugInfo.files.Length > 0)
|
||||
shadername = shaderDetails.DebugInfo.entryFunc + "()" + " - " +
|
||||
Path.GetFileName(shaderDetails.DebugInfo.files[0].filename);
|
||||
shaderDetails.DebugInfo.files[0].BaseFilename;
|
||||
|
||||
writer.WriteStartElement("p");
|
||||
writer.WriteString(shadername);
|
||||
|
||||
@@ -1872,7 +1872,7 @@ namespace renderdocui.Windows.PipelineState
|
||||
|
||||
var files = new Dictionary<string, string>();
|
||||
foreach (var s in shaderDetails.DebugInfo.files)
|
||||
files.Add(Path.GetFileName(s.filename), s.filetext);
|
||||
files.Add(s.BaseFilename, s.filetext);
|
||||
|
||||
if (files.Count == 0)
|
||||
return;
|
||||
|
||||
@@ -530,7 +530,7 @@ namespace renderdocui.Windows
|
||||
DockContent sel = null;
|
||||
foreach (var f in shader.DebugInfo.files)
|
||||
{
|
||||
var name = Path.GetFileName(f.filename);
|
||||
var name = f.BaseFilename;
|
||||
|
||||
ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.filetext, true);
|
||||
scintilla1.IsReadOnly = true;
|
||||
|
||||
Reference in New Issue
Block a user