Exemple #1
0
        protected override Stream GetStreamInternal(Uri uri, FileMode mode, FileAccess access)
        {
            string path = GetPath(uri);

            long offset;

            if (!String.IsNullOrEmpty(uri.Fragment) && Int64.TryParse(HttpUtility.UrlDecode(uri.Fragment.Substring(1)), out offset))
            {
                DeviceStream stream;
                switch (mode)
                {
                case FileMode.Create:
                    stream = new DeviceStream(path, FileMode.OpenOrCreate, access);
                    stream.SetLength(offset);
                    break;

                case FileMode.Truncate:
                    stream = new DeviceStream(path, FileMode.Open, access);
                    stream.SetLength(offset);
                    break;

                default:
                    stream = new DeviceStream(path, mode, access);
                    break;
                }
                stream.Seek(offset, SeekOrigin.Begin);
                return(stream);
            }
            else
            {
                return(new DeviceStream(path, mode, access));
            }
        }
Exemple #2
0
 protected override void When()
 {
     DeviceStream.SetLength(9876L);
 }