public FileStream(File file, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, int bufferSize, object creator) : base(file.ToString(), mode, access, share, bufferSize, options) { _file = file; _mode = mode; _access = access; _share = share; _options = options; _bufferSize = bufferSize; _creator = creator; _createdTimestamp = System.DateTime.Now; // Gets the calling method and stores it in _lastAccess - this is used to help resolve concurrent access request issues. _lastAccess = new StackTrace(true).GetFrame(1); FileSystem.Instance.RegisterHandle(this); }
public NtStatus CreateFile(string fileName, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info) { lock (createFileLock) { try { FileHandle fileHandle = null; bool alreadyExists = false; string name = null; Directory parentDirectory = null; FileSystemObject fso = _fileSystem.GetFileSystemObject(fileName); if (fso == null) { parentDirectory = _fileSystem.GetParentDirectory(fileName, out name); if (parentDirectory == null) { Console.WriteLine($"PATH NOT FOUND CreateFile(\"{fileName}\", {access}, {share}, {mode})"); return(DokanResult.PathNotFound); } } if (fso is Directory) { info.IsDirectory = true; } if (info.IsDirectory) { Directory directory = null; DirectoryHandle handle = null; switch (mode) { case FileMode.CreateNew: if (fso != null) { return(DokanResult.FileExists); } DirectoryHandle parent = null; try { parent = Open(parentDirectory, FileAccess.GenericWrite, FileShare.ReadWrite); directory = _fileSystem.CreateDirectory(parentDirectory, name); handle = Open(directory, access, share); directory.Owner = WindowsIdentity.GetCurrent().User; directory.Group = WindowsIdentity.GetCurrent().User; } finally { if (parent != null) { parent.Close(); Handles.DeleteHandle(parent); } } break; case FileMode.Open: directory = fso as Directory; if (directory == null) { Console.WriteLine($"FILE NOT FOUND CreateFile(\"{fileName}\", {access}, {share}, {mode})"); return(DokanResult.FileNotFound); } handle = Open(directory, access, share); break; default: throw new System.IO.IOException($"Unsupported FileMode ({mode}) for a directory."); } // Assign the handle info.Context = handle; } else { DirectoryHandle parentHandle = null; File file; switch (mode) { case FileMode.Append: case FileMode.Truncate: case FileMode.Open: file = fso as File; if (file == null) { Console.WriteLine($"FILE NOT FOUND CreateFile(\"{fileName}\", {access}, {share}, {mode})"); return(DokanResult.FileNotFound); } fileHandle = Open(file); break; case FileMode.OpenOrCreate: case FileMode.Create: if (fso == null) { try { parentHandle = Open(parentDirectory, FileAccess.GenericWrite, FileShare.ReadWrite); file = _fileSystem.CreateFile(parentDirectory, name); fileHandle = Open(file); } finally { if (parentHandle != null) { parentHandle.Close(); Handles.DeleteHandle(parentHandle); } } } else { alreadyExists = true; } break; case FileMode.CreateNew: if (fso != null) { Console.WriteLine($"FILE EXISTS CreateFile(\"{fileName}\", {access}, {share}, {mode})"); return(DokanResult.FileExists); } try { parentHandle = Open(parentDirectory, FileAccess.GenericWrite, FileShare.ReadWrite); file = _fileSystem.CreateFile(parentDirectory, name); fileHandle = Open(file); } finally { if (parentHandle != null) { parentHandle.Close(); Handles.DeleteHandle(parentHandle); } } break; } // Assign the handle info.Context = fileHandle; } if (fileHandle != null && (mode == FileMode.Create || mode == FileMode.Truncate)) { fileHandle.File.SetEndOfFile(0); } if (access == FileAccess.Synchronize) { ((IHandle)info.Context).IsSynchronize = true; } if (info.Context is DirectoryHandle) { info.IsDirectory = true; } else { info.IsDirectory = false; } Console.WriteLine($"**CreateFile(\"{fileName}\", {access}, {share}, {mode}): {(info.Context as IHandle).ID}"); (info.Context as IHandle).Messages.Add($" CreateFile(\"{fileName}\", {access}, {share}, {mode})"); if (alreadyExists) { return(DokanResult.AlreadyExists); } else { return(DokanResult.Success); } } catch (SharingException) { Console.WriteLine($"SHARING VIOLATION CreateFile(\"{fileName}\", {access}, {share}, {mode})"); return(DokanResult.SharingViolation); } catch (Exception e) { Console.WriteLine($"ERROR CreateFile(\"{fileName}\", {access}, {share}, {mode})"); Console.WriteLine($"{e.Message}"); Console.WriteLine(e.StackTrace); return(DokanResult.Error); } } }
public System.IO.IsolatedStorage.IsolatedStorageFileStream OpenFile(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) => throw null;
public FileStream(string path, System.IO.FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) { Init(path, mode, access, share, bufferSize, options); }
public FileStream(string path, System.IO.FileMode mode, FileAccess access, FileShare share, int bufferSize) : this(path, mode, access, share, bufferSize, DefaultUseAsync) { }
public FileStream(string path, System.IO.FileMode mode) : this(path, mode, (mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite), DefaultShare, DefaultBufferSize, DefaultUseAsync) { }
public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, bool useAsync) { }
public FileStream(string path, System.IO.FileMode mode) { }
internal static extern unsafe SafeFileHandle CreateFile2( string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, System.IO.FileMode dwCreationDisposition, CREATEFILE2_EXTENDED_PARAMETERS *pCreateExParams);
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base(default(string), default(System.IO.FileMode)) { }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base(default(string), default(System.IO.FileMode)) { }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode) { return(default(IsolatedStorageFileStream)); }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, IsolatedStorageFile isf) { return(default(IsolatedStorageFileStream)); }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize) { return(default(IsolatedStorageFileStream)); }
public FileStream Open(FileMode mode, FileAccess access, FileShare share) { return File.Open(FullPath, mode, access, share, 4096, FileOptions.SequentialScan); }
public static System.IO.FileStream Open(string path, System.IO.FileMode mode, System.IO.FileAccess access) { return(default(System.IO.FileStream)); }
public FileStream Open(FileMode mode, FileAccess access) { return Open(mode, access, FileShare.None); }
public System.IO.IsolatedStorage.IsolatedStorageFileStream OpenFile(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) { return(default(System.IO.IsolatedStorage.IsolatedStorageFileStream)); }
public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) { }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile isf) { }
public FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options) { }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) { }
public FileStream(string path, System.IO.FileMode mode, FileAccess access) : this(path, mode, access, DefaultShare, DefaultBufferSize, DefaultUseAsync) { }
public Task <Stream> OpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share) { Stream stream = isolatedStorageFile.OpenFile(path, mode, access, share); return(Task.FromResult(stream)); }
public FileStream(string path, System.IO.FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync) : this(path, mode, access, share, bufferSize, useAsync ? FileOptions.Asynchronous : FileOptions.None) { }
public System.IO.Stream Open(string virtualPath, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, IDictionary <string, object> properties = null) { var physicalPath = this.EnsureDirecotry(virtualPath, mode); return(LocalFileSystem.Instance.File.Open(physicalPath, mode, access, share, properties)); }
public System.IO.IsolatedStorage.IsolatedStorageFileStream OpenFile(string path, System.IO.FileMode mode) => throw null;
public static System.IO.FileStream Open(string path, System.IO.FileMode mode) { throw null; }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode) : base(default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) => throw null;
public static System.IO.FileStream Open(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) { throw null; }
static Type[] ConstructorTypes = new Type[] { typeof(Microsoft.Win32.SafeHandles.SafeFileHandle), typeof(System.Uri), typeof(System.IO.FileAccess), typeof(bool), typeof(System.Action) }; //new Type[] { typeof(string), typeof(System.IO.FileAccess) }; public static MediaFileStream GetCompatbileImplementation(string fileName, AppDomain domain = null, System.IO.FileMode mode = System.IO.FileMode.Open, System.IO.FileAccess access = System.IO.FileAccess.ReadWrite) { if (string.IsNullOrWhiteSpace(fileName)) { throw new ArgumentNullException("fileName"); } //Determine if to use Extension first? //object[] args = new object[] { fileName }; System.IO.FileStream fs = new System.IO.FileStream(fileName, mode, access); object[] args = null; bool final = false; Action sharedFinalizer = null; sharedFinalizer = () => { if (false == final) { return; } if (fs != null) { fs.Dispose(); fs = null; } if (args != null) { args = null; } if (sharedFinalizer != null) { sharedFinalizer = null; } }; args = new object[] { fs, new System.Uri(fileName), access, false, sharedFinalizer }; //Get all loaded assemblies in the current application domain foreach (var assembly in (domain ?? AppDomain.CurrentDomain).GetAssemblies()) { //Iterate each derived type which is a SubClassOf RtcpPacket. foreach (var derivedType in assembly.GetTypes().Where(t => false == t.IsAbstract && t.IsSubclassOf(MediaFileStreamType))) { //OrderBy where the Type.Extensions has an element which corresponds to the extension of the fileName. //If the derivedType is an abstraction then add to the AbstractionBag and continue //if (derivedType.IsAbstract) continue; MediaFileStream created = (MediaFileStream)derivedType.GetConstructor(ConstructorTypes).Invoke(args); using (var rootNode = created.Root) if (rootNode != null && rootNode.IsComplete) { args = null; //Ensure the finalizer can now run. final = true; return(created); } //The created MediaFileStream is useless for this type of file. created.Dispose(); //Seek back fs.Seek(0, System.IO.SeekOrigin.Begin); } } fs.Dispose(); fs = null; args = null; return(null); }
public System.IO.FileStream Open(System.IO.FileMode mode) { throw null; }
public System.IO.FileStream Open(System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) { throw null; }
public FileStream Open(FileMode mode) { return Open(mode, FileAccess.ReadWrite, FileShare.None); }