private void Extractor_FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
     _extractingfn = e.FileInfo.FileName;
     logger.Debug("Extracting " + _extractingfn);
 }
        public override NtStatus CreateFile(string fileName, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, IDokanFileInfo info)
        {
            var tid = Thread.CurrentThread.ManagedThreadId;

            logger.Debug(tid + " CreateFileProxy : {0}", fileName);

            /*   logger.Debug(tid + " \tCreationDisposition\t{0}", (FileMode)mode);
             * logger.Debug(tid + " \tFileAccess\t{0}", (DokanNet.FileAccess)access);
             * logger.Debug(tid + " \tFileShare\t{0}", (FileShare)share);
             * logger.Debug(tid + " \tFileOptions\t{0}", options);
             * logger.Debug(tid + " \tFileAttributes\t{0}", attributes);
             * logger.Debug(tid + " \tContext\t{0}", info);
             */
            if (IsBadName(fileName))
            {
                return(NtStatus.ObjectNameInvalid);
            }
            if ((access & ModificationAttributes) != 0)
            {
                return(NtStatus.DiskFull);
            }

            var item = GetFile(fileName);

            if (item == null)
            {
                return(DokanResult.FileNotFound);
            }
            if (item.Info.FullName != null && !isDirectory(item))
            {
                if ((access & (DokanNet.FileAccess.ReadData | DokanNet.FileAccess.GenericRead)) != 0)
                {
                    Console.WriteLine("MyMirror ReadData: " + fileName);

                    var archive = item.Tag as FsNode <RarArchiveEntry>;

                    if (archive != null)
                    {
                        var idx  = fileName.ToLower().IndexOf(archive.FullName?.ToLower() ?? archive.Name);
                        var file = fileName.Substring(0, idx - 1);

                        try
                        {
                            if (archive.FullName == null)
                            {
                                return(NtStatus.AccessDenied);
                            }

                            if (cache[path.ToLower() + file.ToLower()] == null)
                            {
                                GetFileInfo(path.ToLower() + file.ToLower());
                            }

                            var af = cache[path.ToLower() + file.ToLower()].CreateFile(archive.FullName, access, share, mode, options,
                                                                                       attributes,
                                                                                       info);

                            return(af);
                        }
                        catch (Exception ex)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine(ex);
                            Console.ForegroundColor = ConsoleColor.White;
                            return(NtStatus.AccessDenied);
                        }
                    }
                    else
                    {
                        info.Context =
                            File.Open(path +
                                      fileName, FileMode.Open, System.IO.FileAccess.Read, FileShare.Read);
                    }
                }
                return(NtStatus.Success);
            }
            else
            {
                info.IsDirectory = true;
                return(NtStatus.Success);
            }
        }