Beispiel #1
0
        /// <summary>
        /// Populates the contents of the table from a binary stream.
        /// </summary>
        /// <param name="reader">The binary reader used to read the data.</param>
        /// <returns>The number of bytes read.</returns>
        public int Deserialize(INTV.Shared.Utility.ASCIIBinaryReader reader)
        {
            GlobalFileTable fileTable = this;

            byte[] header    = reader.ReadBytes(Header.Length);
            var    bytesRead = header.Length;

            ushort globalFileNumber = 0;
            ushort numEntries       = reader.ReadUInt16();

            bytesRead += sizeof(ushort);

            int numChunksToRead = (int)Math.Ceiling((double)numEntries / 8);

            for (int i = 0; i < numChunksToRead; ++i)
            {
                var validEntriesMask = reader.ReadByte();
                ++bytesRead;
                for (int e = 0; e < 8; ++e)
                {
                    byte mask = (byte)(1 << e);
                    if ((mask & validEntriesMask) == mask)
                    {
                        var file = LfsFileInfo.Inflate(reader);
                        file.FileSystem             = _fileSystem;
                        bytesRead                  += file.DeserializeByteCount;
                        file.GlobalFileNumber       = globalFileNumber;
                        fileTable[globalFileNumber] = file;
                    }
                    ++globalFileNumber;
                }
            }
            return(bytesRead);
        }
Beispiel #2
0
 /// <summary>
 /// Performs one-time initialization for the LfsFileInfo class.
 /// </summary>
 static LfsFileInfo()
 {
     INTV.Shared.Utility.ErrorReporting.ReportErrorIf <System.InvalidOperationException>(MaxForks != (int)ForkKind.NumberOfForkKinds, INTV.Shared.Utility.ReportMechanism.Default, "LfsFileInfo has incorrect number of forks.", "LfsFileInfo Sanity Check");
     InvalidFile = new LfsFileInfo()
     {
         Color = Core.Model.Stic.Color.NotAColor
     };
 }
Beispiel #3
0
        /// <summary>
        /// Creates a specific instance of a FileNode as appropriate for the given LfsFileInfo.
        /// </summary>
        /// <param name="fileInfo">A LfsFileInfo from which to create a FileNode.</param>
        /// <returns>A FileNode based upon the contents of the given directory entry.</returns>
        public static FileNode Create(LfsFileInfo fileInfo)
        {
            FileNode fileNode = null;

#if REPORT_PERFORMANCE
            var stopwatch = System.Diagnostics.Stopwatch.StartNew();
            try
            {
#endif // REPORT_PERFORMANCE
            if (fileInfo != null)
            {
                switch (fileInfo.FileType)
                {
                case FileType.File:
                    fileNode = new Program(fileInfo);
                    break;

                case FileType.Folder:
                    fileNode = new Folder(fileInfo);
                    break;

                default:
                    throw new INTV.Core.UnexpectedFileTypeException(fileInfo.FileType.ToString());
                }
            }
            else
            {
                throw new InconsistentFileSystemException(LfsEntityType.Unknown, 0xFFFFFFFF, string.Empty);
            }
#if REPORT_PERFORMANCE
        }

        finally
        {
            stopwatch.Stop();
            System.Diagnostics.Debug.WriteLine(">>FileNode creation took: + " + stopwatch.Elapsed.ToString());
        }
#endif // REPORT_PERFORMANCE
            return(fileNode);
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the Program class.
 /// </summary>
 /// <param name="file">The directory entry describing the program.</param>
 /// <remarks>This constructor is typically used to create a model for a user interface to operate on for
 /// the purpose of viewing the contents of a Locutus device.</remarks>
 public Program(LfsFileInfo file)
     : base(file)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of a Folder.
 /// </summary>
 /// <param name="directoryEntry">A directory entry from a Locutus device.</param>
 /// <remarks>This constructor is typically used to create a model for a user interface to operate on for
 /// the purpose of viewing the contents of a Locutus device.</remarks>
 public Folder(LfsFileInfo directoryEntry)
     : base(directoryEntry)
 {
     _globalDirectoryNumber = directoryEntry.GlobalDirectoryNumber;
     SetContents(new ObservableCollection <FileNode>());
 }