Lucene.Net.Demo.IndexHTML.IndexDocs C# (CSharp) Method

IndexDocs() private static method

private static IndexDocs ( System file ) : void
file System
return void
        private static void IndexDocs(System.IO.DirectoryInfo file)
		{
			if (System.IO.Directory.Exists(file.FullName))
			{
				// if a directory
				System.String[] files = System.IO.Directory.GetFileSystemEntries(file.FullName); // list its files
				System.Array.Sort(files); // sort the files
				for (int i = 0; i < files.Length; i++)
				// recursively index them
                    IndexDocs(new System.IO.DirectoryInfo(System.IO.Path.Combine(file.FullName, files[i])));
			}
			else if (file.FullName.EndsWith(".html") || file.FullName.EndsWith(".htm") || file.FullName.EndsWith(".txt"))
			{
				// index .txt files
				
				if (uidIter != null)
				{
					System.String uid = HTMLDocument.Uid(file); // construct uid for doc
					
					while (uidIter.Term() != null && (System.Object) uidIter.Term().Field == (System.Object) "uid" && String.CompareOrdinal(uidIter.Term().Text, uid) < 0)
					{
						if (deleting)
						{
							// delete stale docs
							System.Console.Out.WriteLine("deleting " + HTMLDocument.Uid2url(uidIter.Term().Text));
							reader.DeleteDocuments(uidIter.Term());
						}
						uidIter.Next();
					}
					if (uidIter.Term() != null && (System.Object) uidIter.Term().Field == (System.Object) "uid" && String.CompareOrdinal(uidIter.Term().Text, uid) == 0)
					{
						uidIter.Next(); // keep matching docs
					}
					else if (!deleting)
					{
						// add new docs
						Document doc = HTMLDocument.Document(file);
						System.Console.Out.WriteLine("adding " + doc.Get("path"));
						writer.AddDocument(doc);
					}
				}
				else
				{
					// creating a new index
					Document doc = HTMLDocument.Document(file);
					System.Console.Out.WriteLine("adding " + doc.Get("path"));
					writer.AddDocument(doc); // add docs unconditionally
				}
			}
		}
	}

Same methods

IndexHTML::IndexDocs ( System file, System index, bool create ) : void