/// <summary> /// Creates and initializes an new instance. /// </summary> /// <param name="resourceAccessor">The resource accessor to the media item to be handled by the instance.</param> /// <returns>The new instance.</returns> public static BassMODFileInputSource Create(IFileSystemResourceAccessor resourceAccessor) { resourceAccessor.PrepareStreamAccess(); BassMODFileInputSource inputSource = new BassMODFileInputSource(resourceAccessor); inputSource.Initialize(); return inputSource; }
/// <summary> /// Gets a stream for the resource which is described by this file handle if the stream is already open or opens a new stream for it. /// </summary> /// <returns> /// This method returns the same stream for the same thread; it returns a new stream for a new thread. /// </returns> public Stream GetOrOpenStream() { Thread currentThread = Thread.CurrentThread; Stream stream; lock (_syncObj) if (_threadStreams.TryGetValue(currentThread, out stream)) { return(stream); } IFileSystemResourceAccessor resourceAccessor = _resource.ResourceAccessor; try { if (resourceAccessor != null) { resourceAccessor.PrepareStreamAccess(); lock (_syncObj) return(_threadStreams[currentThread] = resourceAccessor.OpenRead()); } } catch (Exception e) { ServiceRegistration.Get <ILogger>().Warn("Dokan FileHandle: Error creating stream for resource '{0}'", e, resourceAccessor); } return(null); }
/// <summary> /// Creates and initializes an new instance. /// </summary> /// <param name="resourceAccessor">The resource accessor to the media item to be handled by the instance.</param> /// <returns>The new instance.</returns> public static BassMODFileInputSource Create(IFileSystemResourceAccessor resourceAccessor) { resourceAccessor.PrepareStreamAccess(); BassMODFileInputSource inputSource = new BassMODFileInputSource(resourceAccessor); inputSource.Initialize(); return(inputSource); }