本文整理汇总了C#中IDirectory.ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.ReadFile方法的具体用法?C# IDirectory.ReadFile怎么用?C# IDirectory.ReadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectory
的用法示例。
在下文中一共展示了IDirectory.ReadFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteData
public void WriteData(BinaryWriter writer, IDirectory inputDirectory)
{
long ftexHeaderPosition = writer.BaseStream.Position;
writer.BaseStream.Position += HeaderSize + Entries.Count * PftxsFtexsFileEntry.HeaderSize;
foreach (var entry in Entries)
{
entry.CalculateHash();
var data = inputDirectory.ReadFile(Hashing.NormalizeFilePath(entry.FilePath));
entry.Offset = Convert.ToInt32(writer.BaseStream.Position - ftexHeaderPosition);
entry.Size = Convert.ToInt32(data.Length);
writer.Write(data);
}
CalculateHash();
long endPosition = writer.BaseStream.Position;
writer.BaseStream.Position = ftexHeaderPosition;
writer.Write(Convert.ToUInt32(0x58455446)); // FTEX
writer.Write(Convert.ToUInt32(endPosition - ftexHeaderPosition)); // Size
writer.Write(Hash);
writer.Write(Convert.ToUInt32(Entries.Count));
writer.Write(0U);
writer.Write(0U);
writer.Write(0U);
foreach (var entry in Entries)
{
entry.Write(writer);
}
writer.BaseStream.Position = endPosition;
}
示例2: WriteData
public void WriteData(Stream output, IDirectory inputDirectory)
{
Magic = Path.GetExtension(FileName).Trim('.') + '\0';
Offset = (uint)output.Position;
byte[] data = inputDirectory.ReadFile(FileName);
Size = data.Length;
output.Write(data, 0, data.Length);
}
示例3: Write
public void Write(Stream output, IDirectory inputDirectory)
{
const ulong xorMask1Long = 0x4144104341441043;
const uint xorMask1 = 0x41441043;
const uint xorMask2 = 0x11C22050;
const uint xorMask3 = 0xD05608C3;
const uint xorMask4 = 0x532C7319;
byte[] data = inputDirectory.ReadFile(Hashing.NormalizeFilePath(FilePath));
byte[] hash = Hashing.Md5Hash(data);
uint uncompressedSize = (uint)data.Length;
uint compressedSize;
if (Compressed)
{
data = Compression.Compress(data);
compressedSize = (uint) data.Length;
}
else
{
compressedSize = uncompressedSize;
}
Decrypt1(data, hashLow: (uint)(Hash & 0xFFFFFFFF));
BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);
writer.Write(Hash ^ xorMask1Long);
writer.Write(compressedSize ^ xorMask2);
writer.Write(uncompressedSize ^ xorMask3);
writer.Write(BitConverter.ToUInt32(hash, 0) ^ xorMask4);
writer.Write(BitConverter.ToUInt32(hash, 4) ^ xorMask1);
writer.Write(BitConverter.ToUInt32(hash, 8) ^ xorMask1);
writer.Write(BitConverter.ToUInt32(hash, 12) ^ xorMask2);
// TODO: Maybe reencrypt the lua files.
writer.Write(data);
}
示例4: Directory
public void Directory(IDirectory sdir, IDirectory ddir)
{
if (ddir == null || sdir == null) return;
sdir.Source = ddir.Source = sdir;
sdir.Destination = ddir.Destination = ddir;
int con;
if (sdir is LocalDirectory && ddir is LocalDirectory) con = 1;
else {
con = Math.Max(FtpConnections.Count(true, sdir.Url), FtpConnections.Count(false, ddir.Url));
if (ddir is FtpDirectory) {
((FtpDirectory)ddir).TransferProgress = true;
} else if (sdir is FtpDirectory) {
((FtpDirectory)sdir).TransferProgress = true;
}
}
if (con == 0) con = 1;
var list = sdir.List().Where(file => !Silversite.Services.Paths.Match(ExcludePatterns, file.RelativePath)).ToList();
var dlist = ddir.List();
//ddir.CreateDirectory(null);
Parallel.ForEach<FileOrDirectory>(list, new ParallelOptions { MaxDegreeOfParallelism = con },
(src) => {
FileOrDirectory dest = null;
lock(dlist) { if (dlist.Contains(src.Name)) dest = dlist[src.Name]; }
if (dest != null && dest.Class != src.Class && (src.Changed > dest.Changed || Mode == Silversite.Services.Sync.Mode.Clone)) {
ddir.Delete(dest);
dest = null;
}
if (src.Class == ObjectClass.File) { // src is a file
if (dest == null
|| ((Mode == Silversite.Services.Sync.Mode.Update || Mode == Silversite.Services.Sync.Mode.Add) && src.Changed > dest.Changed)
|| (Mode == Silversite.Services.Sync.Mode.Clone && (src.Changed > dest.Changed + dt))) {
var s = sdir.ReadFile(src);
if (s != null) {
using (s) {
ddir.WriteFile(s, src);
}
}
}
} else { // src is a directory
if (dest == null) Directory((IDirectory)src, ddir.CreateDirectory(src));
else Directory((IDirectory)src, (IDirectory)dest);
}
lock (dlist) { dlist.Remove(src.Name); }
});
if (Mode != Silversite.Services.Sync.Mode.Add) {
foreach (var dest in dlist) ddir.Delete(dest);
}
}
示例5: WriteData
public void WriteData(Stream output, IDirectory inputDirectory)
{
DataOffset = (uint)output.Position;
byte[] data = inputDirectory.ReadFile(GetFpkEntryFileName());
DataSize = data.Length;
output.Write(data, 0, data.Length);
}
示例6: WriteData
public void WriteData(X360Writer writer, IDirectory inputDirectory)
{
long ftexHeaderPosition = writer.BaseStream.Position;
writer.BaseStream.Position += HeaderSize + Entries.Count * PftxsFtexsFileEntry.HeaderSize;
bool flipEndian = writer.FlipEndian;
foreach (var entry in Entries)
{
var data = inputDirectory.ReadFile(entry.FilePath);
entry.Offset = Convert.ToInt32(writer.BaseStream.Position - ftexHeaderPosition);
entry.Size = Convert.ToInt32(data.Length);
writer.Write(data);
}
long endPosition = writer.BaseStream.Position;
writer.BaseStream.Position = ftexHeaderPosition;
writer.FlipEndian = false;
writer.Write(Convert.ToUInt32(0x58455446)); // FTEX
writer.FlipEndian = flipEndian;
writer.Write(Convert.ToUInt32(endPosition - ftexHeaderPosition)); // Size
writer.Write(Hash);
writer.Write(Convert.ToUInt32(Entries.Count));
writer.Write(0U);
writer.Write(0U);
writer.Write(0U);
foreach (var entry in Entries)
{
entry.Write(writer);
}
writer.BaseStream.Position = endPosition;
}
示例7: WriteData
public void WriteData(X360Writer writer, IDirectory inputDirectory)
{
DataOffset = (uint) writer.BaseStream.Position;
byte[] data = inputDirectory.ReadFile(GetFpkEntryFileName());
DataSize = (ulong)data.Length;
writer.BaseStream.Write(data, 0, data.Length);
}