Source/NFX/ApplicationModel/Pile/PileImpl/MMFMemory.cs
/// <summary>
/// Returns file names in the order of segment idex
/// </summary>
Returns file names in the order of segment idex
Returns file names in the order of segment idex
public static KeyValuePair<string, int>[] GetSegmentFileNames(string path)
    {
      var all = path.AllFileNamesThatMatch("{0}*.{1}".Args(MMF_PREFIX, MMF_EXT), false)
                    .Select( f => Path.GetFileName(f) );
      var result = new List<KeyValuePair<string, int>>();
      foreach(var fn in all)
      {
        var name = fn;
        if (!name.StartsWith(MMF_PREFIX, StringComparison.InvariantCultureIgnoreCase)) continue;
        name = name.Substring(MMF_PREFIX.Length);
        var ie = name.LastIndexOf('.');
        if (ie<0) continue;
        name = name.Substring(0, ie);
        int idx;
        if (!int.TryParse(name, out idx)) continue;
        result.Add( new KeyValuePair<string, int>(fn, idx) );
      }
      result.Sort( (l, r) => l.Value.CompareTo(r.Value) );
      return result.ToArray();
    }
public static KeyValuePair < string , int > [ ] GetSegmentFileNames ( string path ) { var all = path . AllFileNamesThatMatch ( " " . Args ( MMF_PREFIX , MMF_EXT ) , false ) . Select ( f => Path . GetFileName ( f ) ) ; var result = new List < KeyValuePair < string , int > > ( ) ; foreach ( var fn in all ) { var name = fn ; if ( ! name . StartsWith ( MMF_PREFIX , StringComparison . InvariantCultureIgnoreCase ) ) continue ; name = name . Substring ( MMF_PREFIX . Length ) ; var ie = name . LastIndexOf ( ' ' ) ; if ( ie < 0 ) continue ; name = name . Substring ( 0 , ie ) ; int idx ; if ( ! int . TryParse ( name , out idx ) ) continue ; result . Add ( new KeyValuePair < string , int > ( fn , idx ) ) ; } result . Sort ( ( l , r ) => l . Value . CompareTo ( r . Value ) ) ; return result . ToArray ( ) ; }
Returns file names in the order of segment idex
Returns file names in the order of segment idex
//ignore non-pile files //cut "pile-" //wrong file name // wrong file name
path
string