Esempio n. 1
0
 private FileLoader(StreamReader rd, CompressedStorage storage, string fileId, string title)
 {
     m_reader  = rd;
     m_storage = storage;
     m_fileId  = fileId;
     Title     = title;
 }
Esempio n. 2
0
        private static FileLoader[] LoadStandardFile(string path, CompressedStorage storage)
        {
            var rd     = File.OpenText(path);
            var fileId = storage.AddFile(path);
            var title  = Path.GetFileName(path);

            return(new[] { new FileLoader(rd, storage, fileId, title) });
        }
Esempio n. 3
0
        private static FileLoader[] LoadBzip(string path, CompressedStorage storage)
        {
            var uncompressor = new BZip2InputStream(File.OpenRead(path));
            var rd           = new StreamReader(uncompressor);
            var fileId       = storage.AddFile(path);
            var title        = Path.GetFileName(path);

            return(new[] { new FileLoader(rd, storage, fileId, title) });
        }
Esempio n. 4
0
        // Can return an array if path is a zip with multiple files
        public static FileLoader[] Load(string path, CompressedStorage storage)
        {
            var extension = Path.GetExtension(path).ToLower();

            if (extension == ".bz2")
            {
                return(LoadBzip(path, storage));
            }
            if (extension == ".zip")
            {
                return(LoadZip(path, storage));
            }

            return(LoadStandardFile(path, storage));
        }
Esempio n. 5
0
        // Can return an array if path is a zip with multiple files
        public static FileLoader[] Load(string path, CompressedStorage storage)
        {
            var extension = Path.GetExtension(path).ToLower();

            if (extension == ".bz2")
            {
                return LoadBzip(path, storage);
            }
            if (extension == ".zip")
            {
                return LoadZip(path, storage);
            }

            return LoadStandardFile(path, storage);
        }
Esempio n. 6
0
        private static FileLoader[] LoadZip(string path, CompressedStorage storage)
        {
            var zip    = new ZipFile(path);
            var result = new List <FileLoader>();

            for (int i = 0; i < zip.Count; i++)
            {
                var entry = zip[i];
                if (entry.IsFile)
                {
                    var uncompressor = zip.GetInputStream(i);
                    var rd           = new StreamReader(uncompressor);
                    var fileId       = storage.AddFile(path);
                    var title        = string.Format("{0}:{1}", Path.GetFileNameWithoutExtension(path), zip[i].Name);

                    result.Add(new FileLoader(rd, storage, fileId, title));
                }
            }

            return(result.ToArray());
        }
Esempio n. 7
0
 public CompressedFileSearcher(CompressedStorage contents, string fileId)
 {
     m_contents = contents;
     m_fileId   = fileId;
 }
Esempio n. 8
0
        private static FileLoader[] LoadZip(string path, CompressedStorage storage)
        {
            var zip = new ZipFile(path);
            var result = new List<FileLoader>();
            for (int i = 0; i < zip.Count; i++)
            {
                var entry = zip[i];
                if (entry.IsFile)
                {
                    var uncompressor = zip.GetInputStream(i);
                    var rd = new StreamReader(uncompressor);
                    var fileId = storage.AddFile(path);
                    var title = string.Format("{0}:{1}", Path.GetFileNameWithoutExtension(path), zip[i].Name);

                    result.Add(new FileLoader(rd, storage, fileId, title));
                }
            }

            return result.ToArray();
        }
Esempio n. 9
0
        private static FileLoader[] LoadStandardFile(string path, CompressedStorage storage)
        {
            var rd = File.OpenText(path);
            var fileId = storage.AddFile(path);
            var title = Path.GetFileName(path);

            return new[] {new FileLoader(rd, storage, fileId, title)};
        }
Esempio n. 10
0
        private static FileLoader[] LoadBzip(string path, CompressedStorage storage)
        {
            var uncompressor = new BZip2InputStream(File.OpenRead(path));
            var rd = new StreamReader(uncompressor);
            var fileId = storage.AddFile(path);
            var title = Path.GetFileName(path);

            return new[] { new FileLoader(rd, storage, fileId, title) };
        }
Esempio n. 11
0
 private FileLoader(StreamReader rd, CompressedStorage storage, string fileId, string title)
 {
     m_reader = rd;
     m_storage = storage;
     m_fileId = fileId;
     Title = title;
 }
Esempio n. 12
0
 public StoredFile(CompressedStorage storage, string id)
 {
     m_storage = storage;
     m_id = id;
     m_asyncOp = AsyncOperationManager.CreateOperation(null);
 }
 public CompressedFileSearcher(CompressedStorage contents, string fileId)
 {
     m_contents = contents;
     m_fileId = fileId;
 }
 public SpanSearchState(CompressedStorage.Span s)
 {
     Span = s;
 }
Esempio n. 15
0
        public TextModel()
        {
            var settings = new AppSettingsReader();
            MaxMemoryMb = GetIntConfig(settings, "MaxMemoryMb", 1024);
            MaxFilesPerZip = GetIntConfig(settings, "MaxFilesPerZip", 25);
            int maxConcurrency = GetIntConfig(settings, "MaxCompressConcurrency", 4);

            m_storage = new CompressedStorage(MaxMemoryMb, maxConcurrency);

            m_timer = new Timer(OnTick, null, TickPeriod, Timeout.Infinite);
            m_storage.OnNewData += OnNewData;
        }