mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-26 23:24:00 +08:00
(EntryViewModel): ignore invalid characters in filenames.
This commit is contained in:
parent
3391bcfa46
commit
21652280df
@ -78,10 +78,23 @@ namespace GARbro.GUI
|
|||||||
public EntryViewModel (Entry entry, int priority)
|
public EntryViewModel (Entry entry, int priority)
|
||||||
{
|
{
|
||||||
Source = entry;
|
Source = entry;
|
||||||
Name = Path.GetFileName (entry.Name);
|
Name = SafeGetFileName (entry.Name);
|
||||||
Priority = priority;
|
Priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char[] SeparatorCharacters = { '\\', '/', ':' };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Same as Path.GetFileName, but ignores invalid charactes
|
||||||
|
/// </summary>
|
||||||
|
string SafeGetFileName (string filename)
|
||||||
|
{
|
||||||
|
var name_start = filename.LastIndexOfAny (SeparatorCharacters);
|
||||||
|
if (-1 == name_start)
|
||||||
|
return filename;
|
||||||
|
return filename.Substring (name_start+1);
|
||||||
|
}
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
public Entry Source { get; private set; }
|
public Entry Source { get; private set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user