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