public DokanResult CreateFile( string filename, FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, System.IO.FileAttributes attributes, DokanFileInfo info) { return(DokanResult.Success); }
internal static SafeFileHandle CreateFile( string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, [In] ref Interop.mincore.SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile) { return(Interop.mincore.CreateFile(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)); }
internal static SafeFileHandle UnsafeCreateFile(String lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile) { SafeFileHandle handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); return(handle); }
public static extern SafeFileHandle CreateFileTransacted( [MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] FileSystemDesiredAccess dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] FileShare dwShareMode, [MarshalAs(UnmanagedType.LPStruct)] SecurityAttributes lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] FileSystemDesiredAccess dwFlagsAndAttributes, IntPtr hTemplateFile, SafeHandle hTransaction, IntPtr pusMiniVersion, IntPtr pExtendedParameter);
private unsafe static extern int NtCreateFile( out IntPtr FileHandle, DesiredAccess DesiredAccess, ref OBJECT_ATTRIBUTES ObjectAttributes, out IO_STATUS_BLOCK IoStatusBlock, long *AllocationSize, System.IO.FileAttributes FileAttributes, System.IO.FileShare ShareAccess, CreateDisposition CreateDisposition, CreateOptions CreateOptions, void *EaBuffer, uint EaLength);
internal static extern UInt32 NtCreateFile ( out Microsoft.Win32.SafeHandles.SafeFileHandle fileHandle, Int32 desiredAccess, ref OBJECT_ATTRIBUTES objectAttributes, out IO_STATUS_BLOCK ioStatusBlock, ref Int64 allocationSize, UInt32 fileAttributes, System.IO.FileShare shareAccess, UInt32 createDisposition, UInt32 createOptions, SafeHandle eaBuffer, UInt32 eaLength );
internal static unsafe SafeFileHandle CreateFile( string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, ref SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile) { fixed(SECURITY_ATTRIBUTES *lpSecurityAttributes = &securityAttrs) { return(CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile)); } }
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, FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, System.IO.FileAttributes attributes, DokanFileInfo info) { if (info.IsDirectory && mode == System.IO.FileMode.CreateNew) { return(DokanResult.AccessDenied); } return(DokanResult.Success); }
static private SafeFileHandle OpenHandle(string file, System.IO.FileShare share) { if (file == null || file.Length == 0) { throw new ArgumentNullException("file"); } SafeFileHandle handle = NativeMethods.CreateFile(file, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, share, NativeMethods.NULL, System.IO.FileMode.Open, NativeMethods.FILE_FLAG_OVERLAPPED, NativeMethods.NULL); if (handle.IsInvalid) { throw new InvalidOperationException(String.Format("Cannot open {0}", file)); } return(handle); }
static internal lib.File Open(string name, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options, out MonoIOError error) { if (Program.Vfs == null) { error = MonoIOError.ERROR_GEN_FAILURE; return(null); } //tysos.lib.File ret = (tysos.lib.File)Program.Vfs.Invoke("OpenFile", // new object[] { name, mode, access, share, options }, // File.sig_vfs_OpenFile); File ret = Program.Vfs.OpenFile(name, mode, access, share, options).Sync(); error = ret.Error; return(ret); }
/// <summary> /// Wrapper that allows using System.IO defines where available. Calls CreateFile2 if available. /// </summary> public static SafeFileHandle CreateFileSystemIo( StringSpan path, System.IO.FileAccess fileAccess, System.IO.FileShare fileShare, System.IO.FileMode fileMode, System.IO.FileAttributes fileAttributes = 0, FileFlags fileFlags = FileFlags.None, SecurityQosFlags securityFlags = SecurityQosFlags.None) { return(CreateFile( path: path, desiredAccess: Conversion.FileAccessToDesiredAccess(fileAccess), shareMode: Conversion.FileShareToShareMode(fileShare), creationDisposition: Conversion.FileModeToCreationDisposition(fileMode), fileAttributes: (FileAttributes)fileAttributes, fileFlags: fileFlags, securityQosFlags: securityFlags)); }
/// <summary> /// Wrapper that allows getting a file stream using System.IO defines. /// </summary> public static System.IO.Stream CreateFileStream( string path, System.IO.FileAccess fileAccess, System.IO.FileShare fileShare, System.IO.FileMode fileMode, System.IO.FileAttributes fileAttributes = 0, FileFlags fileFlags = FileFlags.NONE, SecurityQosFlags securityFlags = SecurityQosFlags.NONE) { return(CreateFileStream( path: path, desiredAccess: Conversion.FileAccessToDesiredAccess(fileAccess), shareMode: Conversion.FileShareToShareMode(fileShare), creationDisposition: Conversion.FileModeToCreationDisposition(fileMode), fileAttributes: (FileAttributes)fileAttributes, fileFlags: fileFlags, securityQosFlags: securityFlags)); }
public FailoverFileStream(string[] fullnames, System.IO.FileMode fmode, System.IO.FileAccess faccess, System.IO.FileShare fshare, int fbuffersize, DiskCheck diskcheck) { if (null == fullnames || string.IsNullOrEmpty(fullnames[0])) { throw new FailoverFileStreamIOException("Invalid input fullnames paths"); } this.fullnames = fullnames; fcount = fullnames.Length; this.fmode = fmode; this.faccess = faccess; this.fshare = fshare; this.fbuffersize = fbuffersize; this.diskcheck = diskcheck; _firstopen(); }
public static bool _Open_System_String_System_IO_FileMode_System_IO_FileAccess_System_IO_FileShare( ) { //Parameters System.String path = null; System.IO.FileMode mode = null; System.IO.FileAccess access = null; System.IO.FileShare share = null; //ReturnType/Value System.IO.FileStream returnVal_Real = null; System.IO.FileStream returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.IO.File.Open(path, mode, access, share); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.IO.File.Open(path, mode, access, share); } catch (Exception e) { exception_Intercepted = e; } Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted)); }
static int Open(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(System.IO.FileMode))) { string arg0 = ToLua.ToString(L, 1); System.IO.FileMode arg1 = (System.IO.FileMode)ToLua.ToObject(L, 2); System.IO.FileStream o = System.IO.File.Open(arg0, arg1); ToLua.PushObject(L, o); return(1); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(System.IO.FileMode), typeof(System.IO.FileAccess))) { string arg0 = ToLua.ToString(L, 1); System.IO.FileMode arg1 = (System.IO.FileMode)ToLua.ToObject(L, 2); System.IO.FileAccess arg2 = (System.IO.FileAccess)ToLua.ToObject(L, 3); System.IO.FileStream o = System.IO.File.Open(arg0, arg1, arg2); ToLua.PushObject(L, o); return(1); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(string), typeof(System.IO.FileMode), typeof(System.IO.FileAccess), typeof(System.IO.FileShare))) { string arg0 = ToLua.ToString(L, 1); System.IO.FileMode arg1 = (System.IO.FileMode)ToLua.ToObject(L, 2); System.IO.FileAccess arg2 = (System.IO.FileAccess)ToLua.ToObject(L, 3); System.IO.FileShare arg3 = (System.IO.FileShare)ToLua.ToObject(L, 4); System.IO.FileStream o = System.IO.File.Open(arg0, arg1, arg2, arg3); ToLua.PushObject(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.IO.File.Open")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="access"></param> /// <param name="share"></param> /// <returns></returns> public static object Open(string path, System.IO.FileAccess access, System.IO.FileShare share) { DirectoryEntry entry = PathResolver.Resolve(rootNode, ref path); /* HINT: * * 1. Do we really need to pass the FileShare flags down to the inode? * 2. Shouldn't we have some sort of lock deamon governing shared access? * * Ansers: * 1. Yes. * 2. Yes and no. A lock deamon would only work for local filesystems. For imported * ones we need to notify the server of the sharing lock anyway, so that the IVfsNode * (acting as a client to the server) is the best place to do it without giving the * lock deamon knowledge of all file sharing protocols (afp, smb, ftp, name it.) * 3. The inode may reject the file sharing requests. We do want to represent devices * and sync objects in the VFS, which means *they* need to decide if the flags are * applicable. * */ // FIXME: Perform access checks on the DirectoryEntry/IVfsNode. AccessMode modeFlags = AccessMode.Exists; switch (access) { case System.IO.FileAccess.Read: modeFlags = AccessMode.Read; break; case System.IO.FileAccess.Write: modeFlags = AccessMode.Write; break; case System.IO.FileAccess.ReadWrite: modeFlags = AccessMode.Read | AccessMode.Write; break; } AccessCheck.Perform(entry, modeFlags, AccessCheckFlags.None); return(entry.Node.Open(access, share)); }
public static NTSTATUS NtCreateFile10(out Microsoft.Win32.SafeHandles.SafeFileHandle fileHandle, Int32 desiredAccess, ref OBJECT_ATTRIBUTES objectAttributes, out IO_STATUS_BLOCK ioStatusBlock, ref Int64 allocationSize, UInt32 fileAttributes, System.IO.FileShare shareAccess, UInt32 createDisposition, UInt32 createOptions, IntPtr eaBuffer, UInt32 eaLength) { byte[] syscall = bNtCreateFile10; unsafe { fixed(byte *ptr = syscall) { IntPtr memoryAddress = (IntPtr)ptr; if (!VirtualProtectEx(Process.GetCurrentProcess().Handle, memoryAddress, (UIntPtr)syscall.Length, 0x40, out uint oldprotect)) { throw new Win32Exception(); } Delegates.NtCreateFile myAssemblyFunction = (Delegates.NtCreateFile)Marshal.GetDelegateForFunctionPointer(memoryAddress, typeof(Delegates.NtCreateFile)); return((NTSTATUS)myAssemblyFunction(out fileHandle, desiredAccess, ref objectAttributes, out ioStatusBlock, ref allocationSize, fileAttributes, shareAccess, createDisposition, createOptions, eaBuffer, eaLength)); } } }
public DirectoryHandle Open(FileAccess access, FileShare share) { lock (Lock) { if ((access & READ_ACCESS) != 0 && _openShares.Values.Any(s => (s & FileShare.Read) == 0)) { throw new SharingException(); } if ((access & WRITE_ACCESS) != 0 && _openShares.Values.Any(s => (s & FileShare.Write) == 0)) { throw new SharingException(); } if ((access & FileAccess.Delete) != 0 && _openShares.Values.Any(s => (s & FileShare.Delete) == 0)) { throw new SharingException(); } FileAccess totalAccess = 0; foreach (var a in _openAccesses.Values) { totalAccess |= a; } if ((totalAccess & READ_ACCESS) != 0 && (share & FileShare.Read) == 0) { throw new SharingException(); } if ((totalAccess & WRITE_ACCESS) != 0 && (share & FileShare.Write) == 0) { throw new SharingException(); } if ((totalAccess & FileAccess.Delete) != 0 && (share & FileShare.Delete) == 0) { throw new SharingException(); } DirectoryHandle h = Handles.CreateNewDirectoryHandle(this, access); _openAccesses.Add(h.ID, access); _openShares.Add(h.ID, share); return(h); } }
internal unsafe static (int status, IntPtr handle) CreateFile( ReadOnlySpan <char> path, IntPtr rootDirectory, CreateDisposition createDisposition, DesiredAccess desiredAccess = DesiredAccess.FILE_GENERIC_READ | DesiredAccess.SYNCHRONIZE, System.IO.FileShare shareAccess = System.IO.FileShare.ReadWrite | System.IO.FileShare.Delete, System.IO.FileAttributes fileAttributes = 0, CreateOptions createOptions = CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT, ObjectAttributes objectAttributes = ObjectAttributes.OBJ_CASE_INSENSITIVE, void *eaBuffer = null, uint eaLength = 0) { fixed(char *c = &MemoryMarshal.GetReference(path)) { UNICODE_STRING name = new UNICODE_STRING { Length = checked ((ushort)(path.Length * sizeof(char))), MaximumLength = checked ((ushort)(path.Length * sizeof(char))), Buffer = (IntPtr)c }; OBJECT_ATTRIBUTES attributes = new OBJECT_ATTRIBUTES( &name, objectAttributes, rootDirectory); int status = NtCreateFile( out IntPtr handle, desiredAccess, ref attributes, out IO_STATUS_BLOCK statusBlock, AllocationSize: null, fileAttributes, shareAccess, createDisposition, createOptions, eaBuffer, eaLength); return(status, handle); } }
internal static IntPtr SafeCreateFile(String lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile) { IntPtr handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); if (handle != Win32Native.INVALID_HANDLE_VALUE) { int fileType = Win32Native.GetFileType(handle); if (fileType != Win32Native.FILE_TYPE_DISK) { Win32Native.CloseHandle(handle); throw new NotSupportedException(Environment.GetResourceString("NotSupported_FileStreamOnNonFiles")); } } return(handle); }
public static bool _ctor_System_IO_FileStream_System_String_System_IO_FileMode_System_IO_FileAccess_System_IO_FileShare_System_Int32_System_Boolean( ) { //Parameters System.String path = null; System.IO.FileMode mode = null; System.IO.FileAccess access = null; System.IO.FileShare share = null; System.Int32 bufferSize = null; System.Boolean useAsync = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.IO.FileStream.ctor(path, mode, access, share, bufferSize, useAsync); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.IO.FileStream.ctor(path, mode, access, share, bufferSize, useAsync); } catch (Exception e) { exception_Intercepted = e; } }
private static unsafe SafeFileHandle CreateFile( string lpFileName, int dwDesiredAccess, System.IO.FileShare dwShareMode, SECURITY_ATTRIBUTES *securityAttrs, System.IO.FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile) { CREATEFILE2_EXTENDED_PARAMETERS parameters; parameters.dwSize = (uint)Marshal.SizeOf <CREATEFILE2_EXTENDED_PARAMETERS>(); parameters.dwFileAttributes = (uint)dwFlagsAndAttributes & 0x0000FFFF; parameters.dwSecurityQosFlags = (uint)dwFlagsAndAttributes & 0x000F0000; parameters.dwFileFlags = (uint)dwFlagsAndAttributes & 0xFFF00000; parameters.hTemplateFile = hTemplateFile; parameters.lpSecurityAttributes = securityAttrs; return(CreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref parameters)); }
public static bool _ctor_System_IO_IsolatedStorage_IsolatedStorageFileStream_System_String_System_IO_FileMode_System_IO_FileAccess_System_IO_FileShare( ) { //Parameters System.String path = null; System.IO.FileMode mode = null; System.IO.FileAccess access = null; System.IO.FileShare share = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.IO.IsolatedStorage.IsolatedStorageFileStream.ctor(path, mode, access, share); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.IO.IsolatedStorage.IsolatedStorageFileStream.ctor(path, mode, access, share); } catch (Exception e) { exception_Intercepted = e; } }
public RPCResult <tysos.lib.File> Open(IList <string> path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileOptions options) { if (path.Count == 0) { var ret = new tysos.lib.VirtualDirectory(this, "", children, new tysos.lib.File.Property[] { new tysos.lib.File.Property { Name = "class", Value = "fs" } }); } // modfs has only one level if (path.Count != 1) { return(new tysos.lib.ErrorFile(tysos.lib.MonoIOError.ERROR_FILE_NOT_FOUND)); } foreach (tysos.lib.File.Property p in mods) { if (p.Name == path[0]) { modfs_File f = new modfs_File(this); f.name = p.Name; f.mem = p.Value as tysos.VirtualMemoryResource64; f.Error = tysos.lib.MonoIOError.ERROR_SUCCESS; System.Diagnostics.Debugger.Log(0, "modfs", "Request for " + path[0] + " returning " + f.mem.ToString()); return(f); } } return(new tysos.lib.ErrorFile(tysos.lib.MonoIOError.ERROR_FILE_NOT_FOUND)); }
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 IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile isf) : base(default(Microsoft.Win32.SafeHandles.SafeFileHandle), default(System.IO.FileAccess)) { }
public System.IO.IsolatedStorage.IsolatedStorageFileStream OpenFile(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) { throw null; }
public FileStream Open(FileMode mode, FileAccess access, FileShare share) { return File.Open(FullPath, mode, access, share, 4096, FileOptions.SequentialScan); }
/// <summary> /// Opens the IVfsNode and returns an object capable of doing something smart with the IVfsNode. /// </summary> /// <param name="access"></param> /// <param name="share"></param> /// <returns> /// An object instance, which represents the node. /// </returns> /// <remarks> /// This method is central to the entire VFS. It allows for interaction with filesystem entries in a way not possible /// with classical operating systems. The result of this function is heavily dependant on the item represented by the node, e.g. /// for a classic file (stream of bytes) the result of this method call would be a System.IO.Stream. For a device the result would /// be the driver object, for a directory it would be a System.IO.DirectoryInfo object, for kernel objects the respective object such /// as System.Threading.EventWaitHandle, System.Threading.Mutex, System.Threading.Thread, System.Diagnostics.Process etc. Note: The object /// retrieved can be closed by the respective methods on the returned object. There's no close functionality on the IVfsNode itself. /// </remarks> public override object Open(System.IO.FileAccess access, System.IO.FileShare share) { return(null); }
public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.IO.IsolatedStorage.IsolatedStorageFile isf) { }