Jypeli  5
The simple game programming library
NameHelpers.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6 
7 namespace Jypeli
8 {
9  public partial class FileManager
10  {
11  internal static string SanitizeFileName( string fileName )
12  {
13  StringBuilder newName = new StringBuilder( fileName );
14  newName.Replace( "[]", "Array" ).Replace( "()", "Func" );
15 
16  for ( int i = 0; i < newName.Length; i++ )
17  {
18  char c = newName[i];
19  if ( !Char.IsLetterOrDigit( c ) && c != '-' && c != '_' && c != '.' )
20  newName[i] = '_';
21  }
22 
23  return newName.ToString();
24  }
25 
26  internal void MakeAbsolute( ref string path )
27  {
28  if ( !Path.IsPathRooted( path ) )
29  path = Path.Combine( _currentDir, path );
30  }
31  }
32 }