예제 #1
0
        private long _appendStart; // When appending, prevent overwriting file.

        internal OSFileStreamStrategy(SafeFileHandle handle, FileAccess access)
        {
            _access = access;

            handle.EnsureThreadPoolBindingInitialized();

            if (handle.CanSeek)
            {
                // given strategy was created out of existing handle, so we have to perform
                // a syscall to get the current handle offset
                _filePosition = FileStreamHelpers.Seek(handle, 0, SeekOrigin.Current);
            }
            else
            {
                _filePosition = 0;
            }

            _fileHandle = handle;
        }
예제 #2
0
        private bool _exposedHandle; // created from handle, or SafeFileHandle was used and the handle got exposed

        internal WindowsFileStreamStrategy(SafeFileHandle handle, FileAccess access, FileShare share)
        {
            _access        = access;
            _share         = share;
            _exposedHandle = true;

            handle.InitThreadPoolBindingIfNeeded();

            if (handle.CanSeek)
            {
                // given strategy was created out of existing handle, so we have to perform
                // a syscall to get the current handle offset
                _filePosition = FileStreamHelpers.Seek(handle, _path, 0, SeekOrigin.Current);
            }
            else
            {
                _filePosition = 0;
            }

            _fileHandle = handle;
        }
예제 #3
0
        // This doesn't do argument checking.  Necessary for SetLength, which must
        // set the file pointer beyond the end of the file. This will update the
        // internal position
        private long SeekCore(SafeFileHandle fileHandle, long offset, SeekOrigin origin, bool closeInvalidHandle = false)
        {
            Debug.Assert(fileHandle.CanSeek, "fileHandle.CanSeek");

            return(_filePosition = FileStreamHelpers.Seek(fileHandle, offset, origin, closeInvalidHandle));
        }
예제 #4
0
        // This doesn't do argument checking.  Necessary for SetLength, which must
        // set the file pointer beyond the end of the file. This will update the
        // internal position
        protected long SeekCore(SafeFileHandle fileHandle, long offset, SeekOrigin origin, bool closeInvalidHandle = false)
        {
            Debug.Assert(!fileHandle.IsClosed && _canSeek, "!fileHandle.IsClosed && _canSeek");

            return(_filePosition = FileStreamHelpers.Seek(fileHandle, _path, offset, origin, closeInvalidHandle));
        }