示例#1
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;
        }
示例#2
0
        public int GetFileInformation(string filename, FileInformation fileinfo, DokanFileInfo info)
        {
            Console.WriteLine("GFI: " + filename);
            if (filename.Trim() == "\\")
            {
                Console.WriteLine("->Root");
                fileinfo.FileName       = filename;
                fileinfo.Attributes     = System.IO.FileAttributes.Directory | FileAttributes.ReadOnly | FileAttributes.NotContentIndexed;
                fileinfo.CreationTime   = DateTime.Now;
                fileinfo.LastAccessTime = DateTime.Now;
                fileinfo.LastWriteTime  = DateTime.Now;
                fileinfo.Length         = 0;

                info.IsDirectory = true;
            }
            else
            {
                RAFInMemoryFileSystemObject fso = rafManager.ResolveRAFPathTOFSO(filename);
                if (fso == null)
                {
                    return(-DokanNet.ERROR_FILE_NOT_FOUND);
                }

                fileinfo.FileName = filename;
                if (fso.GetFSOType() == RAFFSOType.FILE)
                {
                    fileinfo.Attributes = System.IO.FileAttributes.Normal;
                    fileinfo.Length     = rafManager.ResolveRAFPathToEntry(fso.GetRAFPath(true)).GetContent().Length;
                }
                else
                {
                    fileinfo.Attributes = System.IO.FileAttributes.Directory;
                    fileinfo.Length     = 0;

                    info.IsDirectory = true;
                }
                fileinfo.CreationTime   = DateTime.Now;
                fileinfo.LastAccessTime = DateTime.Now;
                fileinfo.LastWriteTime  = DateTime.Now;
            }
            return(0);
        }
示例#3
0
        public int ReadFile(string filename, byte[] buffer, ref uint readBytes, long offset, DokanFileInfo info)
        {
            Console.WriteLine("RF: " + filename + ", off" + offset + ", len" + buffer.Length);

            RAFInMemoryFileSystemObject fso = rafManager.ResolveRAFPathTOFSO(filename);

            Console.WriteLine("->FSO NULL: " + (fso == null));
            if (fso == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }
            else
            {
                RAFFileListEntry entry   = rafManager.ResolveRAFPathToEntry(fso.GetRAFPath(true));
                byte[]           content = entry.GetContent();

                readBytes = Math.Min((uint)(content.Length - offset), (uint)buffer.Length);

                Array.Copy(content, offset, buffer, 0, readBytes);
                Console.WriteLine("-> " + readBytes + " bytes read");
                return(0);
            }
            //throw new NotImplementedException();
        }
示例#4
0
        public int FindFiles(string filename, System.Collections.ArrayList files, DokanFileInfo info)
        {
            Console.WriteLine("FF: " + filename);
            switch (filename)
            {
            case "\\":
            {
                Console.WriteLine("! " + rafManager.ArchiveFSOs.Count);
                for (int i = 0; i < rafManager.ArchiveFSOs.Count; i++)
                {
                    files.Add(
                        new FileInformation()
                        {
                            FileName       = rafManager.ArchiveFSOs[i].Text,
                            Attributes     = System.IO.FileAttributes.Directory,
                            CreationTime   = DateTime.Now,
                            LastAccessTime = DateTime.Now,
                            LastWriteTime  = DateTime.Now,
                            Length         = 0
                        }
                        );
                }
                break;
            }

            default:
            {
                RAFInMemoryFileSystemObject fso = rafManager.ResolveRAFPathTOFSO(filename);     //Get rid of the first \ in path
                Console.WriteLine("FSO IS NULL?: " + (fso == null));
                if (fso == null)
                {
                    return(-DokanNet.ERROR_FILE_NOT_FOUND);
                }
                else
                {
                    for (int i = 0; i < fso.Nodes.Count; i++)
                    {
                        RAFInMemoryFileSystemObject cFSO = (RAFInMemoryFileSystemObject)fso.Nodes[i];
                        FileAttributes attributes        = FileAttributes.Normal;
                        long           length            = 0;
                        if (cFSO.GetFSOType() == RAFFSOType.DIRECTORY)
                        {
                            attributes = FileAttributes.Directory;
                        }
                        else if (cFSO.GetFSOType() == RAFFSOType.FILE)
                        {
                            attributes = FileAttributes.Normal;
                            length     = rafManager.ResolveRAFPathToEntry(cFSO.GetRAFPath(true)).FileSize;
                        }

                        files.Add(
                            new FileInformation()
                            {
                                FileName       = cFSO.Text,
                                Attributes     = attributes,
                                CreationTime   = DateTime.Now,
                                LastAccessTime = DateTime.Now,
                                LastWriteTime  = DateTime.Now,
                                Length         = length
                            }
                            );
                    }
                }
                break;
            }
            }
            return(0);
            //throw new NotImplementedException();
        }