@@ -19,7 +19,7 @@ public string Path
1919 private set ;
2020 }
2121
22- public string DatabasePath => FileAsDatabaseString ( Path ) ;
22+ public string DatabasePath => PathAsDatabaseId ( Path ) ;
2323
2424 public override bool NeedsPopulation => Context . DefinesFile ( Path ) || Path == Context . Extractor . OutputPath ;
2525
@@ -41,7 +41,7 @@ public override void Populate()
4141 // remove the dot from the extension
4242 if ( extension . Length > 0 )
4343 extension = extension . Substring ( 1 ) ;
44- Context . Emit ( Tuples . files ( this , DatabasePath , name , extension ) ) ;
44+ Context . Emit ( Tuples . files ( this , PathAsDatabaseString ( Path ) , name , extension ) ) ;
4545
4646 Context . Emit ( Tuples . containerparent ( Entities . Folder . Create ( Context , fi . Directory ) , this ) ) ;
4747 if ( fromSource == 1 )
@@ -73,14 +73,21 @@ public override IId Id
7373 }
7474 }
7575
76- internal static string FileAsDatabaseString ( string fileName )
76+ /// <summary>
77+ /// Converts a path string into a string to use as an ID
78+ /// in the QL database.
79+ /// </summary>
80+ /// <param name="path">An absolute path.</param>
81+ /// <returns>The database ID.</returns>
82+ public static string PathAsDatabaseId ( string path )
7783 {
78- fileName = fileName . Replace ( '\\ ' , '/' ) ;
79- if ( fileName . Length > 1 && fileName [ 1 ] == ':' )
80- fileName = Char . ToUpper ( fileName [ 0 ] ) + fileName . Substring ( 1 ) ;
81- return fileName ;
84+ if ( path . Length >= 2 && path [ 1 ] == ':' && Char . IsLower ( path [ 0 ] ) )
85+ path = Char . ToUpper ( path [ 0 ] ) + "_" + path . Substring ( 2 ) ;
86+ return path . Replace ( '\\ ' , '/' ) . Replace ( ":" , "_" ) ;
8287 }
8388
89+ public static string PathAsDatabaseString ( string path ) => path . Replace ( '\\ ' , '/' ) ;
90+
8491 public static File Create ( Context cx , string path ) => FileFactory . Instance . CreateEntity ( cx , path ) ;
8592
8693 public static File CreateGenerated ( Context cx ) => GeneratedFile . Create ( cx ) ;
0 commit comments