@@ -79,15 +79,31 @@ public static IDictionary<string, int> ToDictionary(IEnumerable<FileIndex> fileI
7979 }
8080
8181
82- public static IEnumerable < FileIndex > FromFile ( string filePath )
82+ //public static IEnumerable<FileIndex> FromFile(string filePath)
83+ //{
84+ // return FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "buffer"), filePath);
85+ //}
86+
87+ public static IEnumerable < FileIndex > FromFile ( string basePath , string filePath )
8388 {
8489 var fileIndexes = new List < FileIndex > ( ) ;
8590
8691 if ( ! string . IsNullOrEmpty ( filePath ) )
8792 {
8893 try
8994 {
90- var path = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "buffer" , "index" , filePath ) ;
95+ var baseDir = basePath ;
96+
97+ if ( ! string . IsNullOrEmpty ( baseDir ) )
98+ {
99+ if ( ! Path . IsPathRooted ( baseDir ) ) baseDir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , baseDir ) ;
100+ }
101+ else
102+ {
103+ baseDir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "buffer" ) ;
104+ }
105+
106+ var path = Path . Combine ( baseDir , "index" , filePath ) ;
91107 if ( File . Exists ( path ) )
92108 {
93109 var lines = File . ReadAllLines ( path ) ;
@@ -107,7 +123,12 @@ public static IEnumerable<FileIndex> FromFile(string filePath)
107123 return fileIndexes ;
108124 }
109125
110- public static bool ToFile ( string filePath , IEnumerable < FileIndex > fileIndexes )
126+ //public static bool ToFile(string filePath, IEnumerable<FileIndex> fileIndexes)
127+ //{
128+ // return ToFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "buffer"), filePath, fileIndexes);
129+ //}
130+
131+ public static bool ToFile ( string basePath , string filePath , IEnumerable < FileIndex > fileIndexes )
111132 {
112133 if ( ! string . IsNullOrEmpty ( filePath ) && ! fileIndexes . IsNullOrEmpty ( ) )
113134 {
@@ -120,7 +141,18 @@ public static bool ToFile(string filePath, IEnumerable<FileIndex> fileIndexes)
120141
121142 try
122143 {
123- var dir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "buffer" , "index" ) ;
144+ var baseDir = basePath ;
145+
146+ if ( ! string . IsNullOrEmpty ( baseDir ) )
147+ {
148+ if ( ! Path . IsPathRooted ( baseDir ) ) baseDir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , baseDir ) ;
149+ }
150+ else
151+ {
152+ baseDir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "buffer" ) ;
153+ }
154+
155+ var dir = Path . Combine ( baseDir , "index" ) ;
124156 if ( ! Directory . Exists ( dir ) ) Directory . CreateDirectory ( dir ) ;
125157
126158 var path = Path . Combine ( dir , filePath ) ;
@@ -134,9 +166,20 @@ public static bool ToFile(string filePath, IEnumerable<FileIndex> fileIndexes)
134166 return false ;
135167 }
136168
137- public static void Reset ( )
169+ public static void Reset ( string basePath )
138170 {
139- var dir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "buffer" , "index" ) ;
171+ var baseDir = basePath ;
172+
173+ if ( ! string . IsNullOrEmpty ( baseDir ) )
174+ {
175+ if ( ! Path . IsPathRooted ( baseDir ) ) baseDir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , baseDir ) ;
176+ }
177+ else
178+ {
179+ baseDir = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "buffer" ) ;
180+ }
181+
182+ var dir = Path . Combine ( baseDir , "index" ) ;
140183 if ( Directory . Exists ( dir ) )
141184 {
142185 try
0 commit comments