コード例 #1
0
        async Task Init()
        {
            Stream fs = await fileSystem.OpenFile(fileName);

            this.stream.SetStream(fs, true);
            this.fsInfo = (IFileStreamInfo)fs;
        }
コード例 #2
0
        public async Task Update()
        {
            CheckDisposed();

            if (fsInfo == null)
            {
                Stream fs;
                try
                {
                    fs = await fileSystem.OpenFile(fileName);
                }
                catch
                {
                    return;
                }
                this.stream.SetStream(fs, true);
                this.fsInfo = (IFileStreamInfo)fs;
            }

            if (fsInfo.IsDeleted)
            {
                size         = 0;
                lastModified = new DateTime();
                stream.SetStream(emptyMemoryStream, false);
                fsInfo = null;
                return;
            }

            size         = stream.Length;
            lastModified = fsInfo.LastWriteTime;
        }
コード例 #3
0
ファイル: SimpleFileMedia.cs プロジェクト: sabrogden/logjoint
        public SimpleFileMedia(IFileSystem fileSystem, IConnectionParams connectParams)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            this.fileSystem = fileSystem;
            this.fileName   = connectParams[fileNameParam];
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Invalid or incomplete connection params");
            }

            try
            {
                Stream fs = fileSystem.OpenFile(fileName);
                this.stream.SetStream(fs, true);
                this.fsInfo = (IFileStreamInfo)fs;
                Update();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }