AdvancedLauncher.SDK.Management.FileSystemManager.ReadFile C# (CSharp) Method

ReadFile() private method

Reads file by entry index
private ReadFile ( int entryIndex ) : Stream
entryIndex int File entry index
return Stream
        private Stream ReadFile(int entryIndex)
        {
            if (LogManager != null) {
                LogManager.DebugFormat("Reading file: entryIndex={0}", entryIndex);
            }
            if (!_IsOpened && !(Access == FileAccess.Read || Access == FileAccess.ReadWrite)) {
                if (LogManager != null) {
                    LogManager.Error("Reading file failed: Archieve not opened or no read access");
                }
                return null;
            }

            if (entryIndex < 0) {
                if (LogManager != null) {
                    LogManager.ErrorFormat("Reading file failed: Wrong entryIndex={0}", entryIndex);
                }
                return null;
            }

            string mapName = Path.GetFileNameWithoutExtension(PackageFile);
            MemoryMappedFile mmf;

            try {
                mmf = MemoryMappedFile.OpenExisting(mapName);
            } //check if exists
            catch {
                try {
                    mmf = MemoryMappedFile.CreateFromFile(ArchiveStream, mapName, 0, MemoryMappedFileAccess.Read, null, HandleInheritability.None, true);
                } catch (Exception e) {
                    if (LogManager != null) {
                        LogManager.Error("Reading file failed: Unable to create MemoryMappedFile", e);
                    }
                    return null;
                }
            } // or not - open*/

            MemoryMappedViewStream outStream;
            try {
                outStream = mmf.CreateViewStream(ArchiveEntries[entryIndex].Offset, ArchiveEntries[entryIndex].SizeCurrent, MemoryMappedFileAccess.Read);
            } catch (Exception e) {
                if (LogManager != null) {
                    LogManager.Error("Reading file failed: Unable to create MemoryMappedViewStream", e);
                }
                return null;
            }

            return outStream;
        }

Same methods

FileSystemManager::ReadFile ( string name ) : Stream
FileSystemManager::ReadFile ( uint id ) : Stream