Esempio n. 1
0
 static extern SafeFileHandle CreateFile(String fileName,
                                         int desiredAccess,
                                         System.IO.FileShare shareMode,
                                         IntPtr securityAttrs,
                                         System.IO.FileMode creationDisposition,
                                         int flagsAndAttributes,
                                         IntPtr templateFile);
Esempio n. 2
0
        public int CreateFile(string filename, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, DokanFileInfo info)
        {
            FileInformation fi = new FileInformation();

            GetFileInformation(filename, ref fi, info);

            switch (mode)
            {
            case FileMode.Append:
                return(DokanNet.DOKAN_SUCCESS);

            case FileMode.Create:
                AddToFileCache(filename, FillFileCache(filename));
                return(DokanNet.DOKAN_SUCCESS);

            case FileMode.CreateNew:
                AddToFileCache(filename, FillFileCache(filename));
                return(DokanNet.DOKAN_SUCCESS);

            case FileMode.Open:
                return(DokanNet.DOKAN_SUCCESS);

            case FileMode.Truncate:
                return(DokanNet.DOKAN_SUCCESS);
            }
            return(DokanNet.DOKAN_ERROR);
        }
Esempio n. 3
0
        internal static unsafe SafePipeHandle CreateNamedPipeClient(
            string lpFileName,
            int dwDesiredAccess,
            System.IO.FileShare dwShareMode,
            ref SECURITY_ATTRIBUTES secAttrs,
            FileMode dwCreationDisposition,
            int dwFlagsAndAttributes,
            IntPtr hTemplateFile)
        {
            Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS parameters;
            parameters.dwSize = (uint)Marshal.SizeOf <Interop.Kernel32.CREATEFILE2_EXTENDED_PARAMETERS>();

            // The dwFlagsAndAttributes is carrying a combination of flags that are mapped to different fields of the extended
            // parameters. The possible range of values for dwFileAttributes, dwSecurityQosFlags, and dwFileFlags cannot be fully
            // covered coming from a single int but are enough for correction creation of the named pipe client. The SECURITY_VALID_SQOS_FLAGS
            // needs to be all available for proper impersonation.
            const uint SECURITY_VALID_SQOS_FLAGS = 0x001F0000;

            parameters.dwFileAttributes   = (uint)dwFlagsAndAttributes & 0x0000FFFF;
            parameters.dwSecurityQosFlags = (uint)dwFlagsAndAttributes & SECURITY_VALID_SQOS_FLAGS;
            parameters.dwFileFlags        = (uint)dwFlagsAndAttributes & 0xFFF00000;

            parameters.hTemplateFile = hTemplateFile;
            fixed(Interop.Kernel32.SECURITY_ATTRIBUTES *lpSecurityAttributes = &secAttrs)
            {
                parameters.lpSecurityAttributes = lpSecurityAttributes;
                return(CreateNamedPipeClientPrivate(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref parameters));
            }
        }
Esempio n. 4
0
        //Windows System Error Codes @ http://www.hiteksoftware.com/knowledge/articles/049.htm
        public int CreateFile(string filename, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, DokanFileInfo info)
        {
            Console.WriteLine("crFile: " + filename);

            info.Context = count++;

            if (filename.Trim() == "\\")
            {
                info.IsDirectory = true;
                return(0);
            }
            else
            {
                RAFInMemoryFileSystemObject fso = rafManager.ResolveRAFPathTOFSO(filename);
                Console.WriteLine("-> FSO NULL? " + (fso == null));
                if (fso == null)
                {
                    return(-DokanNet.ERROR_ACCESS_DENIED);
                }
                else
                {
                    if (fso.GetFSOType() == RAFFSOType.DIRECTORY)
                    {
                        info.IsDirectory = true;
                    }
                    return(0);
                }
            }
            //return -82;
        }
            public Stream Open(string virtualPath, FileMode mode, FileAccess access, System.IO.FileShare share, IDictionary <string, string> properties = null)
            {
                Path path;
                var  service = FileSystem.GetFileProvider(virtualPath, out path);

                return(service.Open(path.FullPath, mode, access, share, properties));
            }
Esempio n. 6
0
        public static System.IO.FileShare ToFileShare(Alt.IO.FileShare src)
        {
            System.IO.FileShare dest = (System.IO.FileShare) 0;

            if ((src & Alt.IO.FileShare.None) == Alt.IO.FileShare.None)
            {
                dest |= System.IO.FileShare.None;
            }
            if ((src & Alt.IO.FileShare.Read) == Alt.IO.FileShare.Read)
            {
                dest |= System.IO.FileShare.Read;
            }
            if ((src & Alt.IO.FileShare.Write) == Alt.IO.FileShare.Write)
            {
                dest |= System.IO.FileShare.Write;
            }
            if ((src & Alt.IO.FileShare.ReadWrite) == Alt.IO.FileShare.ReadWrite)
            {
                dest |= System.IO.FileShare.ReadWrite;
            }
            if ((src & Alt.IO.FileShare.Delete) == Alt.IO.FileShare.Delete)
            {
                dest |= System.IO.FileShare.Delete;
            }
            if ((src & Alt.IO.FileShare.Inheritable) == Alt.IO.FileShare.Inheritable)
            {
                dest |= System.IO.FileShare.Inheritable;
            }

            return(dest);
        }
Esempio n. 7
0
        private static uint GetShare(IO.FileShare share)
        {
            uint ushare = 0;

            switch (share)
            {
            case IO.FileShare.Read:
                ushare = PathInternal.DllImport.FILE_SHARE_READ;
                break;

            case IO.FileShare.ReadWrite:
                ushare = PathInternal.DllImport.FILE_SHARE_READ | PathInternal.DllImport.FILE_SHARE_WRITE;
                break;

            case IO.FileShare.Write:
                ushare = PathInternal.DllImport.FILE_SHARE_WRITE;
                break;

            case IO.FileShare.Delete:
                ushare = PathInternal.DllImport.FILE_SHARE_DELETE;
                break;

            case IO.FileShare.None:
                ushare = 0;
                break;
            }
            return(ushare);
        }
Esempio n. 8
0
        public int CreateFile(
            string filename,
            System.IO.FileAccess access,
            System.IO.FileShare share,
            System.IO.FileMode mode,
            System.IO.FileOptions options,
            DokanFileInfo info)
        {
            Trace.WriteLine(string.Format("CreateFile {0}", filename));

            if (mode == FileMode.CreateNew)
            {
                var blob = this.GetBlob(filename, false);
                blobsWriting.TryAdd(filename, blob.OpenWrite());

                return(0);
            }

            if (GetFileInformation(filename, new FileInformation(), new DokanFileInfo(0)) == 0)
            {
                return(0);
            }
            else
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }
        }
Esempio n. 9
0
        public uint Def_CreateFile(string filename, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, IntPtr info)
        {
            //return 0;
            RegistryFileBlock rb = new RegistryFileBlock(filename);

            if (rb.ValueKind > 0)
            {
                if (mode == FileMode.CreateNew || mode == FileMode.OpenOrCreate)
                {
                    if (rb.level == 2)
                    {
                        GetRegistoryEntry(rb).CreateSubKey(rb.KeyPointer.Substring(rb.KeyPointer.LastIndexOf("\\") + 1));
                        return(0);
                    }
                    int check;

                    if (rb.level == 3 && filename.EndsWith(regtypes[rb.ValueKind], StringComparison.CurrentCultureIgnoreCase))
                    {
                        switch (rb.ValueKind)
                        {
                        case 1:
                            GetRegistoryEntry(rb).SetValue(rb.ValueName, 0, RegValueType[rb.ValueKind]);
                            break;

                        case 2:
                            GetRegistoryEntry(rb).SetValue(rb.ValueName, "", RegValueType[rb.ValueKind]);
                            break;

                        case 3:
                            GetRegistoryEntry(rb).SetValue(rb.ValueName, 0, RegValueType[rb.ValueKind]);
                            break;

                        case 4:
                            GetRegistoryEntry(rb).SetValue(rb.ValueName, "", RegValueType[rb.ValueKind]);
                            break;

                        default:
                            return(0xC000000F);
                        }
                        return(0);
                    }
                }
            }
            else
            {
                if (filename == "\\")
                {
                    return(0);
                }
                if (filename.EndsWith("dekstop.ini", StringComparison.CurrentCultureIgnoreCase) || filename.EndsWith("autorun.inf", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(0);
                }
                // else
                // Console.WriteLine("Invalid New File {0}",filename);
                return(0xC000000F);
            }
            return(0xC000000F);
        }
Esempio n. 10
0
 private static extern SafeFileHandle CreateFilePrivate(
     string lpFileName,
     int dwDesiredAccess,
     System.IO.FileShare dwShareMode,
     ref SECURITY_ATTRIBUTES securityAttrs,
     System.IO.FileMode dwCreationDisposition,
     int dwFlagsAndAttributes,
     IntPtr hTemplateFile);
Esempio n. 11
0
 public static extern SafeFileHandle CreateFile(
     string lpFileName,
     [MarshalAs(UnmanagedType.U4)] System.IO.FileAccess dwDesiredAccess,
     [MarshalAs(UnmanagedType.U4)] System.IO.FileShare dwShareMode,
     IntPtr lpSecurityAttributes,
     [MarshalAs(UnmanagedType.U4)] FileMode dwCreationDisposition,
     [MarshalAs(UnmanagedType.U4)] System.IO.FileAttributes dwFlagsAndAttributes,
     IntPtr hTemplateFile);
 internal static extern SafePipeHandle CreateNamedPipeClient(
     string lpFileName,
     int dwDesiredAccess,
     System.IO.FileShare dwShareMode,
     ref SECURITY_ATTRIBUTES secAttrs,
     FileMode dwCreationDisposition,
     int dwFlagsAndAttributes,
     IntPtr hTemplateFile);
Esempio n. 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IsolatedStorageFileStream"/> class giving access to the file designated by path,
        /// in the specified mode, with the specified file access, using the file sharing mode specified by share,
        /// and in the context of the <see cref="IsolatedStorageFile"/> specified by isf.
        /// </summary>
        /// <param name="path">The relative path of the file within isolated storage.</param>
        /// <param name="mode">One of the <see cref="FileMode"/> values.</param>
        /// <param name="access">A bitwise combination of the <see cref="FileAccess"/> values.</param>
        /// <param name="share">A bitwise combination of the <see cref="FileShare"/> values.</param>
        /// <param name="isf">The <see cref="IsolatedStorageFile"/> in which to open the <see cref="IsolatedStorageFileStream"/>.</param>
        public IsolatedStorageFileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access,
                                         System.IO.FileShare share, IsolatedStorage.IsolatedStorageFile isf)
            : base(Path.Combine(isf.BasePath, path), mode, access, share)
        {
            //also set the hidden attribute (just in case)
            System.IO.FileInfo fi = new System.IO.FileInfo(System.IO.Path.Combine(isf.BasePath, path));
            fi.Attributes |= System.IO.FileAttributes.Hidden;

            _isolatedStorageFile = isf;
        }
Esempio n. 14
0
 internal static unsafe SafeFileHandle CreateFile2(
     string lpFileName,
     int dwDesiredAccess,
     System.IO.FileShare dwShareMode,
     System.IO.FileMode dwCreationDisposition,
     CREATEFILE2_EXTENDED_PARAMETERS *pCreateExParams)
 {
     lpFileName = PathInternal.EnsureExtendedPrefixOverMaxPath(lpFileName);
     return(CreateFile2Private(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, pCreateExParams));
 }
Esempio n. 15
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static SafeFileHandle UnsafeCreateFile(String lpFileName,
                                                        int dwDesiredAccess, System.IO.FileShare dwShareMode,
                                                        ref SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
                                                        int dwFlagsAndAttributes, IntPtr hTemplateFile)
        {
            SafeFileHandle handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode,
                                               ref securityAttrs, dwCreationDisposition,
                                               dwFlagsAndAttributes, hTemplateFile);

            return(handle);
        }
Esempio n. 16
0
 internal static SafeFileHandle CreateFile(
     string lpFileName,
     int dwDesiredAccess,
     System.IO.FileShare dwShareMode,
     ref SECURITY_ATTRIBUTES securityAttrs,
     System.IO.FileMode dwCreationDisposition,
     int dwFlagsAndAttributes,
     IntPtr hTemplateFile)
 {
     lpFileName = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName) !; // TODO-NULLABLE: Remove ! when nullable attributes are respected
     return(CreateFilePrivate(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile));
 }
Esempio n. 17
0
 internal static SafeFileHandle CreateFile(
     string lpFileName,
     int dwDesiredAccess,
     System.IO.FileShare dwShareMode,
     [In] ref SECURITY_ATTRIBUTES securityAttrs,
     System.IO.FileMode dwCreationDisposition,
     int dwFlagsAndAttributes,
     IntPtr hTemplateFile)
 {
     lpFileName = PathInternal.EnsureExtendedPrefixOverMaxPath(lpFileName);
     return(CreateFilePrivate(lpFileName, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile));
 }
Esempio n. 18
0
        public int CreateFile(string filename, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, DokanFileInfo info)
        {
            if (KeepStats)
            {
                Stats.count();
            }
            debug("...create file request for " + filename + " with access " + access + " with mode " + mode);
            if (filename.Equals(ROOT_PATH))
            {
                return(0);
            }
            else if (filename.StartsWith("\\autorun", StringComparison.CurrentCultureIgnoreCase))
            {
                return(0);
            }
            else if (filename.StartsWith(ROOT_PATH) && MySubDirs.ContainsKey(filename.Substring(1)))
            {
                List <Chunk> lst;
                MySubDirs.TryGetValue(filename.Substring(1), out lst);
                info.Context = (ulong)this.getNextId();
                openChunks.Add((ulong)info.Context, new OpenChunk(filename.Substring(1), lst));
                return(0);
            }
            string fn = (filename.StartsWith("\\")) ? filename.Substring(filename.LastIndexOf("\\") + 1) : filename;

            if (this.MyDirectory.ContainsKey(fn))
            {
                if (mode != FileMode.Open)
                {
                    return(-1);
                }
                if (access != FileAccess.Read)
                {
                    return(-1);
                }
                Chunk c;
                MyDirectory.TryGetValue(fn, out c);

                info.Context = (ulong)this.getNextId();
                debug("...create file request ****CTX*** is " + (ulong)info.Context);
                //FileStream fs = File.Open(c.ActualPath, FileMode.Open, FileAccess.Read, FileShare.Read);
                FileStream fs = new FileStream(c.ActualPath, FileMode.Open, FileAccess.Read, FileShare.Read, BufferSize, FileOptions.SequentialScan);
                openChunks.Add((ulong)info.Context, new OpenChunk(c, fs));
                return(0);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 19
0
        internal static SafeFileHandle CreateFile(
            string lpFileName,
            int dwDesiredAccess,
            System.IO.FileShare dwShareMode,
            ref SECURITY_ATTRIBUTES securityAttrs,
            System.IO.FileMode dwCreationDisposition,
            int dwFlagsAndAttributes,
            IntPtr hTemplateFile)
        {
            string?lpFileNameWithPrefix = PathInternal.EnsureExtendedPrefixIfNeeded(lpFileName);

            Debug.Assert(lpFileNameWithPrefix != null, "null not expected when non-null passed"); // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
            return(CreateFilePrivate(lpFileNameWithPrefix, dwDesiredAccess, dwShareMode, ref securityAttrs, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile));
        }
Esempio n. 20
0
        /// <summary>
        ///		<see cref="IFileProvider.Open"/>
        /// </summary>
        public System.IO.FileStream Open(
            string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options)
        {
            if (bufferSize == 0)
            {
                bufferSize = 1024;
            }

            var longPath = new LongPath(path);

            SafeFileHandle handle = GetFileHandle(longPath, mode, access, share, options);

            return(new FileStream(handle, access, bufferSize, (options & FileOptions.Asynchronous) == FileOptions.Asynchronous));
        }
Esempio n. 21
0
        public WriteStream(string filename, long index, System.IO.FileMode mode, System.IO.FileShare share)
        {
            this.stream = System.IO.File.Open(filename, mode, FileAccess.Write, share);

            this.index = (index > this.stream.Length) ? this.stream.Length : index;

            this.stream.Seek(this.index, SeekOrigin.Begin);

            this.commands = new Queue <Command>();

            this.ended = false;

            this.writing = false;
        }
Esempio n. 22
0
 private static Database Getdb(string sourceFileName, System.IO.FileShare rwType, bool isCloseFile)
 {
     try
     {
         Database databaseFromFile = new Database(false, true);
         databaseFromFile.ReadDwgFile(sourceFileName, rwType, false, "");
         databaseFromFile.CloseInput(isCloseFile);
         return(databaseFromFile);
     }
     catch
     {
         return(null);
     }
 }
    static bool File_Open__String__FileMode__FileAccess__FileShare(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 4)
        {
            System.String        arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            System.IO.FileMode   arg1 = (System.IO.FileMode)JSApi.getEnum((int)JSApi.GetType.Arg);
            System.IO.FileAccess arg2 = (System.IO.FileAccess)JSApi.getEnum((int)JSApi.GetType.Arg);
            System.IO.FileShare  arg3 = (System.IO.FileShare)JSApi.getEnum((int)JSApi.GetType.Arg);
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, System.IO.File.Open(arg0, arg1, arg2, arg3));
        }

        return(true);
    }
Esempio n. 24
0
    private async Task <bool> LockFile(System.IO.FileShare fshare = FileShare.Read, System.Security.AccessControl.FileSystemRights fSysRights = FileSystemRights.Read, System.IO.FileAccess fAccess = FileAccess.Read, System.IO.FileMode fMode = FileMode.Open, System.IO.FileOptions fOptions = FileOptions.None)
    {
        int       num  = 0;
        bool      flag = false;
        Stopwatch SW   = new Stopwatch();

        SW.Start();
        while (!flag && (num < 2000) && (SW.ElapsedMilliseconds < 30000))
        {
            //Try
            if (!this.IsFileInUse(fshare, fSysRights, fAccess, fMode, fOptions))
            {
                if (fMode == FileMode.OpenOrCreate || fAccess == FileAccess.ReadWrite || fAccess == FileAccess.Write)
                {
                    try
                    {
                        this.m_fileStream.Lock(this.m_fileStream.Length, 0xFFFF);
                        this.m_WasLocked = true;
                        this.FileExists  = true;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("  LockFile Error: " + ex.Message);
                    }
                }
            }
            else
            {
                num += 1;
                await Task.Delay(10); //'Thread.Sleep(10)

                continue;
            }
            //Catch exception1 As Exception
            //    num += 1
            //    Thread.Sleep(10)
            //    Continue Do
            //End Try
            flag = true;
        }
        SW.Stop();
        if (num > 0)
        {
            Console.WriteLine("  Lockfile lock time: " + SW.ElapsedMilliseconds + "ms, errcount=" + num);
        }

        return(flag);
    }
Esempio n. 25
0
        static private SafeFileHandle OpenHandle(string file, System.IO.FileShare share)
        {
            if (file == null || file.Length == 0)
            {
                throw new ArgumentNullException("file");
            }

            SafeFileHandle handle = Native.CreateFile(file, Native.GENERIC_READ | Native.GENERIC_WRITE, share, Native.NULL, System.IO.FileMode.Open, Native.FILE_FLAG_OVERLAPPED, Native.NULL);

            if (handle.IsInvalid)
            {
                Native.ThrowIOException(String.Format("Cannot open {0}", file));
            }

            return(handle);
        }
Esempio n. 26
0
            public FileInfoLock LockStream(DriveService.Stream stream,
                                           string filePath,
                                           System.IO.FileMode fileMode,
                                           System.IO.FileAccess fileAccess,
                                           System.IO.FileShare fileShare)
            {
                try
                {
                    return(LockFile(stream, stream.FileId, filePath, fileMode, fileAccess, fileShare));
                }
                catch (Exception exception)
                {
                    Log.Error(exception);

                    return(null);
                }
            }
Esempio n. 27
0
    private bool IsFileInUse(System.IO.FileShare fshare = FileShare.Read, System.Security.AccessControl.FileSystemRights fSysRights = FileSystemRights.Read, System.IO.FileAccess fAccess = FileAccess.Read, System.IO.FileMode fMode = FileMode.Open, System.IO.FileOptions fOptions = FileOptions.None)
    {
        bool inUse = false;


        try
        {
            do
            {
                this.m_fileHandle = CreateFile(this.m_path, fSysRights, fshare, IntPtr.Zero, fMode, FileOptions.None, IntPtr.Zero);

                if (this.m_fileHandle.IsInvalid)
                {
                    int LastErr = Marshal.GetLastWin32Error();
                    //Console.WriteLine("IsFileInUse LastErr: " & LastErr & ", " & New Win32Exception(LastErr).Message, , , False)
                    inUse = true;
                    if (LastErr == ERROR_SHARING_VIOLATION || LastErr == ERROR_LOCK_VIOLATION)
                    {
                        if (!this.m_fileHandle.IsClosed)
                        {
                            this.m_fileHandle.Close();
                        }
                    }
                    else
                    {
                        //Me.m_fileStream = New FileStream(m_fileHandle, fAccess)
                    }
                }
                else
                {
                    this.m_fileStream = new FileStream(this.m_fileHandle, fAccess);
                }
                break;
            } while (true);
        }
        catch (Exception ex)
        {
            Console.WriteLine("IsFileInUse Error: " + ex.Msg());
            inUse = true;
        }
        finally
        {
        }

        return(inUse);
    }
Esempio n. 28
0
        private static unsafe SafeFileHandle CreateFile(String lpFileName,
                                                        int dwDesiredAccess, System.IO.FileShare dwShareMode,
                                                        ref SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
                                                        int dwFlagsAndAttributes, IntPtr hTemplateFile)
        {
            Interop.CREATEFILE2_EXTENDED_PARAMETERS parameters;
            parameters.dwSize = (uint)Marshal.SizeOf <Interop.CREATEFILE2_EXTENDED_PARAMETERS>();

            parameters.dwFileAttributes   = (uint)dwFlagsAndAttributes & 0x0000FFFF;
            parameters.dwSecurityQosFlags = (uint)dwFlagsAndAttributes & 0x000F0000;
            parameters.dwFileFlags        = (uint)dwFlagsAndAttributes & 0xFFF00000;

            parameters.hTemplateFile = hTemplateFile;
            fixed(SECURITY_ATTRIBUTES *lpSecurityAttributes = &securityAttrs)
            {
                parameters.lpSecurityAttributes = (IntPtr)lpSecurityAttributes;
                return(CreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref parameters));
            }
        }
 public int CreateFile(string filename, System.IO.FileAccess access, System.IO.FileShare share, System.IO.FileMode mode, System.IO.FileOptions options, Dokan.DokanFileInfo info)
 {
     try
     {
         info.Context = FileSystem.OpenFile(filename, mode);
         return(0);
     }
     catch (Exception e)
     {
         Console.WriteLine(" -- CreateFile Error: " + e.Message);
         info.Context = null;
         //return -1;
         return(0);
     }
     finally
     {
         NotImplemented(filename, info.Context);
     }
     //info.Context = FileSystem.OpenFile(filename, mode);
 }
Esempio n. 30
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static SafeFileHandle SafeCreateFile(String lpFileName,
                                                      int dwDesiredAccess, System.IO.FileShare dwShareMode,
                                                      ref SECURITY_ATTRIBUTES securityAttrs, System.IO.FileMode dwCreationDisposition,
                                                      int dwFlagsAndAttributes, IntPtr hTemplateFile)
        {
            SafeFileHandle handle = CreateFile(lpFileName, dwDesiredAccess, dwShareMode,
                                               ref securityAttrs, dwCreationDisposition,
                                               dwFlagsAndAttributes, hTemplateFile);

            if (!handle.IsInvalid)
            {
                int fileType = Interop.mincore.GetFileType(handle);
                if (fileType != Interop.FILE_TYPE_DISK)
                {
                    handle.Dispose();
                    throw new NotSupportedException(SR.NotSupported_FileStreamOnNonFiles);
                }
            }

            return(handle);
        }