public override async Task <Stream> OpenStreamAsync(CancellationToken ct, FileAccessMode accessMode, StorageOpenOptions options) { Func <Stream> streamBuilder = () => File.Open(Path, FileMode.Open, ToFileAccess(accessMode), ToFileShare(options)); var streamWrapper = new SecurityScopeStreamWrapper(_nsUrl, streamBuilder); return(streamWrapper); }
public override IOutputStream GetOutputStreamAt(ulong position) { if (!CanWrite) { throw new NotSupportedException("The file has not been opened for write."); } Func <Stream> streamBuilder = () => File.Open(_url.Path, FileMode.OpenOrCreate, FileAccess.Write, _share); var securityScopedStream = new SecurityScopeStreamWrapper(_url, streamBuilder); securityScopedStream.Seek((long)position, SeekOrigin.Begin); return(new FileOutputStream(securityScopedStream)); }
public static SecurityScoped Create(NSUrl url, FileAccess access, FileShare share) { // In order to be able to CloneStream() and Get<Input|Output>Stream(), // no matter the provided share, we enforce to 'share' the 'access'. var readWriteAccess = (FileShare)(access & FileAccess.ReadWrite); share &= ~readWriteAccess; share |= readWriteAccess; Func <Stream> streamBuilder = () => File.Open(url.Path, FileMode.OpenOrCreate, access, share); var securityScopedStream = new SecurityScopeStreamWrapper(url, streamBuilder); return(new SecurityScoped(securityScopedStream, url, access, share)); }