mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Resolves Issue #10 where channel names with illegal filename characters are preventing log file creation.
This commit is contained in:
@@ -30,6 +30,14 @@ import util.TimeStamp;
|
||||
|
||||
public abstract class EventLogger
|
||||
{
|
||||
/* Illegal filename characters */
|
||||
private static final String[] mIllegalCharacters = { "#", "%", "&", "{",
|
||||
"}", "\\", "<", ">",
|
||||
"*", "?", "/", " ",
|
||||
"$", "!", "'", "\"",
|
||||
":", "@", "+", "`",
|
||||
"|", "=" };
|
||||
|
||||
private Path mLogDirectory;
|
||||
private String mFileNameSuffix;
|
||||
private String mLogFileName;
|
||||
@@ -67,7 +75,7 @@ public abstract class EventLogger
|
||||
sb.append( "_" );
|
||||
sb.append( mFileNameSuffix );
|
||||
|
||||
mLogFileName = sb.toString();
|
||||
mLogFileName = replaceIllegalCharacters( sb.toString() );
|
||||
|
||||
Log.info( "Creating log file:" + mLogFileName );
|
||||
|
||||
@@ -81,6 +89,19 @@ public abstract class EventLogger
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces any illegal filename characters in the proposed filename
|
||||
*/
|
||||
private String replaceIllegalCharacters( String filename )
|
||||
{
|
||||
for( String illegalCharacter: mIllegalCharacters )
|
||||
{
|
||||
filename.replace( illegalCharacter, "_" );
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if( mLogFile != null )
|
||||
|
||||
Reference in New Issue
Block a user