@@ -188,46 +188,22 @@ private static bool IsDirectory(string path)
188188
189189 string defaultInstallPath ;
190190 string ? defaultConfigPath = null ;
191-
192- // check if we are building within the dev structure
193- string [ ] directoryStructure = [ "net8.0" , "*" , "bin" , "Senzing.Sdk.Tests" , "sz-sdk-csharp" , "csharp" , "g2" , "apps" , "dev" ] ;
194- DirectoryInfo ? workingDir = new DirectoryInfo ( Environment . CurrentDirectory ) ;
195- DirectoryInfo ? previousDir = null ;
196- bool devStructure = true ;
197- foreach ( var dirName in directoryStructure )
198- {
199- if ( workingDir == null ) break ;
200- if ( ! dirName . Equals ( "*" , OrdinalIgnoreCase ) && ! workingDir . Name . Equals ( dirName , OrdinalIgnoreCase ) )
201- {
202- devStructure = false ;
203- break ;
204- }
205- previousDir = workingDir ;
206- workingDir = workingDir . Parent ;
207- }
208- DirectoryInfo ? devDistDir = ( devStructure && previousDir != null )
209- ? new DirectoryInfo ( Path . Combine ( previousDir . FullName , "dist" ) ) : null ;
191+ string defaultSupportPath ;
210192
211193 switch ( Environment . OSVersion . Platform )
212194 {
213195 case PlatformID . Win32NT :
214- defaultInstallPath = ( devDistDir == null )
215- ? "C:\\ Program Files\\ Senzing\\ er" : devDistDir . FullName ;
196+ defaultInstallPath = "C: \\ Program Files \\ Senzing \\ er" ;
197+ defaultSupportPath = "C:\\ Program Files\\ Senzing\\ er\\ data" ;
216198 break ;
217199 case PlatformID . MacOSX :
218- defaultInstallPath = ( devDistDir == null )
219- ? "/opt/senzing/er" : devDistDir . FullName ;
200+ defaultInstallPath = "/opt/senzing/er" ;
201+ defaultSupportPath = "/opt/senzing/er/data" ;
220202 break ;
221203 case PlatformID . Unix :
222- if ( devDistDir == null )
223- {
224- defaultInstallPath = "/opt/senzing/er" ;
225- defaultConfigPath = "/etc/opt/senzing" ;
226- }
227- else
228- {
229- defaultInstallPath = devDistDir . FullName ;
230- }
204+ defaultInstallPath = "/opt/senzing/er" ;
205+ defaultConfigPath = "/etc/opt/senzing" ;
206+ defaultSupportPath = "/opt/senzing/data" ;
231207 break ;
232208 default :
233209 throw new NotSupportedException (
@@ -314,109 +290,19 @@ private static bool IsDirectory(string path)
314290 return null ;
315291 }
316292
317- if ( supportPath == null || supportPath . Trim ( ) . Length == 0 )
318- {
319- // try to determine the support path
320- DirectoryInfo ? installParent = installDir . Parent ;
321- DirectoryInfo ? dataRoot = ( installParent != null )
322- ? new DirectoryInfo ( Path . Combine ( installParent . FullName , "data" ) )
323- : null ;
324-
325- if ( dataRoot != null && dataRoot . Exists && IsDirectory ( dataRoot . FullName ) )
326- {
327- DirectoryInfo ? versionFile
328- = new DirectoryInfo (
329- Path . Combine ( installDir . FullName , "szBuildVersion.json" ) ) ;
330-
331- string ? dataVersion = null ;
332- if ( versionFile != null && versionFile . Exists )
333- {
334-
335- String text = File . ReadAllText ( versionFile . FullName , UTF8 ) ;
336- JsonDocument jsonDoc = JsonDocument . Parse ( text ) ;
337- JsonElement rootElem = jsonDoc . RootElement ;
338- JsonElement dataVerElem = rootElem . GetProperty ( "DATA_VERSION" ) ;
339- dataVersion = dataVerElem . GetString ( ) ;
340- }
341-
342- // try the data version directory
343- supportDir = ( dataVersion == null )
344- ? null
345- : new DirectoryInfo (
346- Path . Combine ( dataRoot . FullName , dataVersion . Trim ( ) ) ) ;
347-
348- // check if data version was not found
349- if ( supportDir == null || ! supportDir . Exists )
350- {
351- Regex regex = new Regex ( "\\ d+\\ .\\ d+\\ .\\ d+" ) ;
352- // look to see if we only have one data version installed
353- string [ ] dirs = Directory . GetDirectories ( dataRoot . FullName ) ;
354- List < DirectoryInfo > versionDirs
355- = new List < DirectoryInfo > ( ) ;
356- foreach ( string dir in dirs )
357- {
358- DirectoryInfo versionDir = new DirectoryInfo ( dir ) ;
359- if ( ! regex . IsMatch ( versionDir . Name ) ) continue ;
360- versionDirs . Add ( versionDir ) ;
361- }
362- if ( versionDirs . Count == 1 && supportDir == null )
363- {
364- // use the single data version found
365- supportDir = versionDirs [ 0 ] ;
366- }
367- else if ( versionDirs . Count > 1 )
368- {
369- Console . Error . WriteLine (
370- "Could not infer support directory. Multiple data "
371- + "directory versions at: " ) ;
372- Console . Error . WriteLine ( " " + dataRoot ) ;
373- if ( supportDir != null )
374- {
375- Console . Error . WriteLine ( ) ;
376- Console . Error . WriteLine ( "Expected to find: " + supportDir ) ;
377- }
378- throw new InvalidOperationException (
379- ( ( supportDir == null )
380- ? "Could not infer support directory."
381- : "Could not find support directory (" + supportDir + ")." )
382- + " Multiple data directory versions found at: "
383- + dataRoot ) ;
384- }
385- else
386- {
387- // no version directories were found, maybe the data root is
388- // the actual support directory (mapped in a docker image)
389- string [ ] files = Directory . GetFiles ( dataRoot . FullName ) ;
390- List < FileInfo > ibmFiles = new List < FileInfo > ( ) ;
391- foreach ( string file in files )
392- {
393- if ( file . EndsWith ( ".ibm" , OrdinalIgnoreCase ) )
394- {
395- ibmFiles . Add ( new FileInfo ( file ) ) ;
396- }
397- }
398- DirectoryInfo ? libPostalDir = new DirectoryInfo (
399- Path . Combine ( dataRoot . FullName , "libpostal" ) ) ;
400-
401- // require the .ibm files and libpostal to exist
402- if ( ibmFiles . Count > 0 && libPostalDir . Exists )
403- {
404- supportDir = dataRoot ;
405- }
406- }
407- }
408-
409- }
410- if ( supportDir == null )
411- {
412- // use the default path
293+ // check if an explicit support path has been specified
294+ if ( supportPath == null || supportPath . Trim ( ) . Length == 0 ) {
295+ // check if using a dev build
296+ if ( "dist" . Equals ( installDir . Name , OrdinalIgnoreCase ) ) {
297+ // use the "data" sub-directory of the dev build
413298 supportDir = new DirectoryInfo (
414299 Path . Combine ( installDir . FullName , "data" ) ) ;
300+ } else {
301+ // no explicit path, try the default support path
302+ supportDir = new DirectoryInfo ( defaultSupportPath ) ;
415303 }
416304
417- }
418- else
419- {
305+ } else {
420306 // use the specified explicit path
421307 supportDir = new DirectoryInfo ( supportPath ) ;
422308 }
0 commit comments