本文整理汇总了C#中Library.OpenRead方法的典型用法代码示例。如果您正苦于以下问题:C# Library.OpenRead方法的具体用法?C# Library.OpenRead怎么用?C# Library.OpenRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library
的用法示例。
在下文中一共展示了Library.OpenRead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Patch
//.........这里部分代码省略.........
string contentprefix = Utility.Utility.AppendDirSeparator(CONTENT_ROOT);
List<string> contentfiles = m_filter.FilterList(contentprefix, patch.ListFiles(contentprefix));
string deltaprefix = Utility.Utility.AppendDirSeparator(DELTA_ROOT);
List<string> deltafiles = m_filter.FilterList(deltaprefix, patch.ListFiles(deltaprefix));
string symlinkprefix = Utility.Utility.AppendDirSeparator(SYMLINK_ROOT);
List<string> symlinks = m_filter.FilterList(symlinkprefix, patch.ListFiles(symlinkprefix));
long totalfiles = deltafiles.Count + contentfiles.Count;
long fileindex = 0;
//Restore new files
foreach (string s in contentfiles)
{
string target = GetFullPathFromRelname(destination, s.Substring(contentprefix.Length));
try
{
if (!SystemIO.DirectoryExists(SystemIO.PathGetDirectoryName(target)))
{
Logging.Log.WriteMessage(string.Format(Strings.RSyncDir.RestoreFolderMissingError, target), XervBackup.Library.Logging.LogMessageType.Warning);
SystemIO.DirectoryCreate(SystemIO.PathGetDirectoryName(target));
}
//Update each 0.5%
int pg = (int)((fileindex / (double)totalfiles) * 200);
if (pg != lastPg)
{
ProgressEvent(pg / 2, target);
lastPg = pg;
}
using (System.IO.Stream s1 = patch.OpenRead(s))
{
PartialEntryRecord pex = null;
Utility.TempFile partialFile = null;
if (pe != null && string.Equals(pe.PlatformConvertedFilename, s))
pex = pe; //The file is incomplete
else if (fe != null && string.Equals(fe.PlatformConvertedFilename, s))
pex = fe; //The file has the final segment
if (pex != null && string.Equals(pex.PlatformConvertedFilename, s))
{
//Ensure that the partial file list is in the correct state
if (pex.StartOffset == 0 && m_partialDeltas.ContainsKey(s))
throw new Exception(string.Format(Strings.RSyncDir.InvalidPartialFileEntry, s));
else if (pex.StartOffset != 0 && !m_partialDeltas.ContainsKey(s))
throw new Exception(string.Format(Strings.RSyncDir.InvalidPartialFileEntry, s));
else if (pex.StartOffset == 0) //First entry, so create a temp file
m_partialDeltas.Add(s, new XervBackup.Library.Utility.TempFile());
partialFile = m_partialDeltas[s];
}
else if (m_partialDeltas.ContainsKey(s))
throw new Exception(string.Format(Strings.RSyncDir.FileShouldBePartialError, s));
long startOffset = pex == null ? 0 : pex.StartOffset;
using (System.IO.Stream s2 = SystemIO.FileOpenWrite(partialFile == null ? target : (string)partialFile))
{
if (s2.Length != startOffset)
throw new Exception(string.Format(Strings.RSyncDir.InvalidPartialFileEntry, s));
s2.Position = startOffset;
if (startOffset == 0)