本文整理汇总了C#中Lucene.Net.Store.Directory.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Store.Directory.Copy方法的具体用法?C# Lucene.Net.Store.Directory.Copy怎么用?C# Lucene.Net.Store.Directory.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Store.Directory
的用法示例。
在下文中一共展示了Lucene.Net.Store.Directory.Copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewDirectory
/// <summary>
/// Returns a new Directory instance, using the specified random
/// with contents copied from the provided directory. See
/// <seealso cref="#newDirectory()"/> for more information.
/// </summary>
public static BaseDirectoryWrapper NewDirectory(Random r, Directory d)
{
Directory impl = NewDirectoryImpl(r, TEST_DIRECTORY);
foreach (string file in d.ListAll())
{
d.Copy(impl, file, file, NewIOContext(r));
}
return WrapDirectory(r, impl, Rarely(r));
}
示例2: CreateCompoundFile
/// <summary>
/// NOTE: this method creates a compound file for all files returned by
/// info.files(). While, generally, this may include separate norms and
/// deletion files, this SegmentInfo must not reference such files when this
/// method is called, because they are not allowed within a compound file.
/// </summary>
public static ICollection<string> CreateCompoundFile(InfoStream infoStream, Directory directory, CheckAbort checkAbort, SegmentInfo info, IOContext context)
{
string fileName = Index.IndexFileNames.SegmentFileName(info.Name, "", Lucene.Net.Index.IndexFileNames.COMPOUND_FILE_EXTENSION);
if (infoStream.IsEnabled("IW"))
{
infoStream.Message("IW", "create compound file " + fileName);
}
Debug.Assert(Lucene3xSegmentInfoFormat.GetDocStoreOffset(info) == -1);
// Now merge all added files
ICollection<string> files = info.Files;
CompoundFileDirectory cfsDir = new CompoundFileDirectory(directory, fileName, context, true);
IOException prior = null;
try
{
foreach (string file in files)
{
directory.Copy(cfsDir, file, file, context);
checkAbort.Work(directory.FileLength(file));
}
}
catch (System.IO.IOException ex)
{
prior = ex;
}
finally
{
bool success = false;
try
{
IOUtils.CloseWhileHandlingException(prior, cfsDir);
success = true;
}
finally
{
if (!success)
{
try
{
directory.DeleteFile(fileName);
}
catch (Exception)
{
}
try
{
directory.DeleteFile(Lucene.Net.Index.IndexFileNames.SegmentFileName(info.Name, "", Lucene.Net.Index.IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
}
catch (Exception)
{
}
}
}
}
// Replace all previous files with the CFS/CFE files:
HashSet<string> siFiles = new HashSet<string>();
siFiles.Add(fileName);
siFiles.Add(Lucene.Net.Index.IndexFileNames.SegmentFileName(info.Name, "", Lucene.Net.Index.IndexFileNames.COMPOUND_FILE_ENTRIES_EXTENSION));
info.Files = siFiles;
return files;
}