本文整理汇总了C#中FileEntry类的典型用法代码示例。如果您正苦于以下问题:C# FileEntry类的具体用法?C# FileEntry怎么用?C# FileEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileEntry类属于命名空间,在下文中一共展示了FileEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListingServiceReceiver
/// <summary>
/// Create an ls receiver/parser.
/// </summary>
/// <param name="parent">The list of current children. To prevent collapse during update, reusing the same
/// FileEntry objects for files that were already there is paramount.</param>
/// <param name="entries">the list of new children to be filled by the receiver.</param>
/// <param name="links">the list of link path to compute post ls, to figure out if the link
/// pointed to a file or to a directory.</param>
public ListingServiceReceiver( FileEntry parent, List<FileEntry> entries, List<String> links )
{
Parent = parent;
Entries = entries ?? new List<FileEntry>();
Links = links ?? new List<String> ( );
CurrentChildren = Parent.Children.ToArray ( );
}
示例2: LoadFile
/// <summary>
/// Load the specified file.
/// </summary>
public byte[] LoadFile(string fileName)
{
for (int i = 0; i < mSavedFiles.size; ++i)
{
FileEntry fi = mSavedFiles[i];
if (fi.fileName == fileName) return fi.data;
}
#if !UNITY_WEBPLAYER
string fn = CleanupFilename(fileName);
if (File.Exists(fn))
{
try
{
byte[] bytes = File.ReadAllBytes(fn);
if (bytes != null)
{
FileEntry fi = new FileEntry();
fi.fileName = fileName;
fi.data = bytes;
mSavedFiles.Add(fi);
return bytes;
}
}
catch (System.Exception ex)
{
Error(fileName + ": " + ex.Message);
}
}
#endif
return null;
}
示例3: Push
/// <include file='.\ISyncService.xml' path='/SyncService/Push/*'/>
public static SyncResult Push(this ISyncService syncService, IEnumerable<String> local, FileEntry remote, ISyncProgressMonitor monitor)
{
if (monitor == null)
{
throw new ArgumentNullException("monitor", "Monitor cannot be null");
}
if (!remote.IsDirectory)
{
return new SyncResult(ErrorCodeHelper.RESULT_REMOTE_IS_FILE);
}
// make a list of File from the list of String
List<FileSystemInfo> files = new List<FileSystemInfo>();
foreach (String path in local)
{
files.Add(path.GetFileSystemInfo());
}
// get the total count of the bytes to transfer
long total = syncService.GetTotalLocalFileSize(files);
monitor.Start(total);
SyncResult result = syncService.DoPush(files, remote.FullPath, monitor);
monitor.Stop();
return result;
}
示例4: IncludeFile
public void IncludeFile(FileEntry file)
{
// TODO: check for directory
ItsExcludedFileEntries.Remove(file);
ItsIncludedFileEntriesDict.Add(file.GetHashCode(), file);
ItsNewFileEntries.Remove(file);
// TODO: update xml
RaiseRegistryUpdateEvent();
ItsInstallerProjectManagementService.AddNewFile(file.FullPath);
}
示例5: CompoundFileReader
public CompoundFileReader(Directory dir, System.String name, int readBufferSize)
{
directory = dir;
fileName = name;
this.readBufferSize = readBufferSize;
bool success = false;
try
{
stream = dir.OpenInput(name, readBufferSize);
// read the directory and init files
int count = stream.ReadVInt();
FileEntry entry = null;
for (int i = 0; i < count; i++)
{
long offset = stream.ReadLong();
System.String id = stream.ReadString();
if (entry != null)
{
// set length of the previous entry
entry.length = offset - entry.offset;
}
entry = new FileEntry();
entry.offset = offset;
entries[id] = entry;
}
// set the length of the final entry
if (entry != null)
{
entry.length = stream.Length() - entry.offset;
}
success = true;
}
finally
{
if (!success && (stream != null))
{
try
{
stream.Close();
}
catch (System.IO.IOException)
{
}
}
}
}
示例6: CreateFromEntry
public static ITorrentFile CreateFromEntry(FileEntry entry, long progress, int priority)
{
using (entry)
{
return new TorrentFile
{
Path = entry.Path,
Priority = priority,
Progress = (progress / (float) entry.Size) * 100f,
Size = entry.Size
};
}
}
示例7: PullFile
/// <include file='.\ISyncService.xml' path='/SyncService/PullFile/*'/>
public static SyncResult PullFile(this ISyncService syncService, FileEntry remote, String localFilename, ISyncProgressMonitor monitor)
{
if (monitor == null)
{
throw new ArgumentNullException("monitor", "Monitor cannot be null");
}
long total = remote.Size;
monitor.Start(total);
SyncResult result = syncService.DoPullFile(remote.FullPath, localFilename, monitor);
monitor.Stop();
return result;
}
示例8: ensureFileEntry
public FileEntry ensureFileEntry( string path, byte[] data )
{
FileEntry fe = findFileEntry(path);
if(fe!=null) {
Debug.Log( "ensureFileEntry: found entry:" + path );
return fe;
}
for(int i=0;i<m_fents.Length;i++) {
if( m_fents[i] == null ) {
Debug.Log("allocated new fileentry:" + path + " len:" + data.Length + " at:" + i );
fe = new FileEntry(path, data);
m_fents[i] = fe;
return fe;
}
}
Debug.Log( "ensureFileEntry: full!");
return null;
}
示例9: Extract
public static List<WorkShopAddonFile> Extract(Stream gmaFile)
{
const UInt32 HEADER = 1145130311;
var binaryReader = new BinaryReader(gmaFile, Encoding.GetEncoding(1252));
binaryReader.BaseStream.Position = 0;
if (binaryReader.ReadUInt32() == HEADER)
{
gmaFile.Seek(18, SeekOrigin.Current);
string workshopFileName = ReadString(binaryReader);
string metadata = ReadString(binaryReader);
string authorname = ReadString(binaryReader);
gmaFile.Seek(4, SeekOrigin.Current);
var Files = new List<FileEntry>();
while (binaryReader.BaseStream.CanRead)
{
if (binaryReader.ReadUInt32() == 0)
{
break;
}
var file = new FileEntry {Filename = ReadString(binaryReader), Size = binaryReader.ReadUInt32()};
Files.Add(file);
gmaFile.Seek(8, SeekOrigin.Current);
}
if (Files.Count >= 1)
{
return (from fileEntry in Files
let fileName = Path.GetFileName(fileEntry.Filename)
let fileData = binaryReader.ReadBytes(Convert.ToInt32(fileEntry.Size))
let filePath = Path.GetDirectoryName(fileEntry.Filename)
select new WorkShopAddonFile
{
FileName = fileName, Path = filePath, Contents = fileData, Size = fileData.Length
}).ToList();
}
}
return null;
}
示例10: ParseFile
public static System.Windows.Forms.TreeNode ParseFile(string path)
{
// Read archive tree
uint nFiles, baseOffset;
System.Windows.Forms.TreeNode node = new System.Windows.Forms.TreeNode();
System.IO.BinaryReader stream = new System.IO.BinaryReader(System.IO.File.OpenRead(path));
stream.ReadUInt32();
nFiles = stream.ReadUInt32();
baseOffset = stream.ReadUInt32();
for (int i = 0; i < nFiles; i++)
{
char b;
FileEntry f = new FileEntry();
do
{
b = (char)stream.ReadByte();
if (b != 0)
f.name += b;
} while (b != 0);
f.length = stream.ReadUInt32();
stream.ReadUInt32();
f.offset = baseOffset;
baseOffset += f.length;
f.idx = (uint)i;
System.Windows.Forms.TreeNode n = new System.Windows.Forms.TreeNode(f.name);
n.Tag = f;
node.Nodes.Add(n);
}
return node;
}
示例11: FileEntry
public FileEntry(string[] fparts)
{
if (fparts[0].StartsWith("/")) fparts[0] = fparts[0].Substring(1);
string fullname = fparts[0];
if (fparts.Length > 1)
size = fparts[1];
string[] parts = fullname.Split('/');
isDirectory = fullname.EndsWith("/");
if (isDirectory)
{
name = parts[parts.Length - 2];
folder = string.Join("/", parts, 0, parts.Length - 2);
if(parts.Length>2) folder+="/";
if (name != "..")
{
SDCard.f.allDirs.Add(fullname, this);
SDCard.f.allFiles.AddLast(new FileEntry(new string[] { fullname.ToLower() + "../", "" }));
}
}
else
{
name = parts[parts.Length - 1];
if (parts.Length == 1)
folder = "";
else
{
folder = string.Join("/", parts, 0, parts.Length - 1) + "/";
if (name!=".." && !SDCard.f.allDirs.Keys.Contains(folder))
{
FileEntry ent = new FileEntry(folder);
SDCard.f.allDirs.Add(folder,ent );
SDCard.f.allFiles.AddLast(ent);
SDCard.f.allFiles.AddLast(new FileEntry(new string[] { folder.ToLower() + "../", "" }));
}
}
}
}
示例12: Load
public void Load(X360IO io)
{
IO = io;
IO.Stream.Position = 0x0;
Magic = IO.Reader.ReadInt64();
if (Magic != 0x5343455546000000)
return;
Version = IO.Reader.ReadInt64();
ImageVersion = IO.Reader.ReadInt64();
FileCount = IO.Reader.ReadInt64();
HeaderSize = IO.Reader.ReadInt64();
DataSize = IO.Reader.ReadInt64();
Files = new List<FileEntry>();
for(int i = 0; i < FileCount; i++)
{
FileEntry entry = new FileEntry
{
ID = IO.Reader.ReadInt64(),
Offset = IO.Reader.ReadInt64(),
Size = IO.Reader.ReadInt64(),
Padding = IO.Reader.ReadInt64()
};
Files.Add(entry);
}
Hashes = new List<HashEntry>();
for(int i = 0; i < FileCount; i++)
{
HashEntry entry = new HashEntry();
entry.FileID = IO.Reader.ReadInt64();
entry.HMACSHA1 = IO.Reader.ReadBytes(0x14);
entry.Padding = IO.Reader.ReadInt32();
Hashes.Add(entry);
Files[(int) entry.FileID].Hash = entry;
}
HeaderHash = IO.Reader.ReadBytes(0x14);
Padding = IO.Reader.ReadBytes(0xC);
}
示例13: LoadFile
public void LoadFile(string path)
{
initfs = new TOCFile(path);
list = new List<FileEntry>();
foreach (BJSON.Entry e in initfs.lines)
if (e.fields != null && e.fields.Count != 0)
{
BJSON.Field file = e.fields[0];
List<BJSON.Field> data = (List<BJSON.Field>)file.data;
FileEntry entry = new FileEntry();
foreach (BJSON.Field f in data)
switch (f.fieldname)
{
case "name":
entry.name = (string)f.data;
break;
case "payload":
entry.data = (byte[])f.data;
break;
}
list.Add(entry);
}
RefreshList();
}
示例14: GetEntry
public static FileEntry GetEntry(string filePath)
{
FileEntry entry = null;
try
{
entry = new FileEntry(filePath);
}
catch (Exception ex)
{
Debug.WriteLine("Exception in GetEntry for filePath :: " + filePath + " " + ex.Message);
}
return entry;
}
示例15: InsertDirOperatorEntries
private void InsertDirOperatorEntries(VirtualFilesystemDirectory currentDir, VirtualFilesystemDirectory parentDir)
{
FileEntry dot1;
FileEntry dot2;
// Working dir reference
dot1 = new FileEntry
{
ID = ushort.MaxValue,
NameHashcode = HashName("."),
Type = 0x02,
Name = ".",
Data = new byte[] { (byte)(exportNodes.IndexOf(exportNodes.Find(i => i.Name == currentDir.Name))) },
};
if (parentDir != null)
{
// Parent dir reference. This isn't the root, so we get the parent
dot2 = new FileEntry
{
ID = ushort.MaxValue,
NameHashcode = HashName(".."),
Type = 0x02,
Name = "..",
Data = new byte[] { (byte)(exportNodes.IndexOf(exportNodes.Find(i => i.Name == parentDir.Name))) },
};
}
else
{
// Parent dir reference. This IS the root, so we say the parent dir is null
dot2 = new FileEntry
{
ID = ushort.MaxValue,
NameHashcode = HashName(".."),
Type = 0x02,
Name = "..",
Data = new byte[] { (byte)(255) },
};
}
exportFileEntries.Add(dot1);
exportFileEntries.Add(dot2);
}