コード例 #1
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int FindFiles(String filename, ArrayList files, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (!(entry is MemFSDirectory))
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }

            FileInformation dots = entry.GetFileInfo();

            dots.FileName = ".";
            files.Add(dots);

            if (entry == root)
            {
                dots          = entry.GetFileInfo();
                dots.FileName = "..";
                files.Add(dots);
            }
            else
            {
                dots          = GetDirectoryForPath(filename).GetFileInfo();
                dots.FileName = "..";
                files.Add(dots);
            }

            foreach (MemFsEntry e in ((MemFSDirectory)entry).GetEntries())
            {
                files.Add(e.GetFileInfo());
            }

            return(0);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: jeagle/dokan-memfs-je
        public bool AddEntry(string name, MemFsEntry entry)
        {
            if (!this.IsValidName(name)) { return false; }

            if (contents.ContainsKey(name)) { return false; }
            contents.Add(name, entry);
            return true;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public MemFsEntry[] GetEntries()
        {
            MemFsEntry[] results = new MemFsEntry[contents.Count];
            int          x       = 0;

            foreach (object o in contents.Values)
            {
                results[x++] = (MemFsEntry)o;
            }
            return(results);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: jeagle/dokan-memfs-je
        public MemFsEntry[] GetEntries()
        {
            MemFsEntry[] results = new MemFsEntry[contents.Count];
            int x = 0;

            foreach (object o in contents.Values)
            {
                results[x++] = (MemFsEntry)o;
            }
            return results;
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int SetFileAttributes(String filename, FileAttributes attr, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (entry == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }
            if (entry.SetFileAttributes(attr))
            {
                return(0);
            }
            return(-1);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int CloseFile(String filename, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (entry is MemFSFile)
            {
                ((MemFSFile)entry).refcount--;
                if ((((MemFSFile)entry).deleteonclose) && (((MemFSFile)entry).refcount == 0))
                {
                    this.DeleteFile(filename, info);
                }
            }
            return(0);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public bool AddEntry(string name, MemFsEntry entry)
        {
            if (!this.IsValidName(name))
            {
                return(false);
            }

            if (contents.ContainsKey(name))
            {
                return(false);
            }
            contents.Add(name, entry);
            return(true);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int WriteFile(String filename, Byte[] buffer,
                             ref uint writtenBytes, long offset, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (!(entry is MemFSFile))
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }

            if (((MemFSFile)entry).Write(buffer, ref writtenBytes, offset))
            {
                return(0);
            }
            return(-1);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int SetEndOfFile(String filename, long length, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (entry == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }
            if (entry is MemFSFile)
            {
                if (((MemFSFile)entry).Resize(length))
                {
                    return(0);
                }
                // else fall through...
            }
            return(-1);
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int CreateDirectory(String filename, DokanFileInfo info)
        {
            MemFsEntry entry = GetDirectoryForPath(filename);

            if (entry == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }
            if (GetEntryForPath(filename) != null)
            {
                return(-DokanNet.ERROR_ALREADY_EXISTS);
            }
            if (((MemFSDirectory)entry).AddDirectory(GetFilenameFromPath(filename)))
            {
                return(0);
            }
            return(-1);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int DeleteDirectory(String filename, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (entry == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }
            if (!(entry is MemFSDirectory))
            {
                return(-1);
            }
            entry = GetDirectoryForPath(filename);
            if (((MemFSDirectory)entry).RemoveEntry(GetFilenameFromPath(filename)))
            {
                return(0);
            }
            return(-1);
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int GetFileInformation(String filename, FileInformation fileinfo, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (entry == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }

            FileInformation f = entry.GetFileInfo();

            fileinfo.Attributes     = f.Attributes;
            fileinfo.CreationTime   = f.CreationTime;
            fileinfo.LastAccessTime = f.LastAccessTime;
            fileinfo.LastWriteTime  = f.LastWriteTime;
            fileinfo.Length         = f.Length;
            fileinfo.FileName       = f.FileName;

            return(0);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        public int MoveFile(String filename, String newname, bool replace, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            if (entry == null)
            {
                return(-DokanNet.ERROR_FILE_NOT_FOUND);
            }

            MemFsEntry destentry   = GetEntryForPath(newname);
            string     newfilename = GetFilenameFromPath(newname);

            if (destentry != null)
            {
                if (replace)
                {
                    if (!GetDirectoryForPath(newname).RemoveEntry(newfilename))
                    {
                        return(-DokanNet.ERROR_ALREADY_EXISTS);
                    }
                }
                else
                {
                    return(-DokanNet.ERROR_ALREADY_EXISTS);
                }
            }

            if (!GetDirectoryForPath(newname).AddEntry(newfilename, entry))
            {
                return(-1);
            }
            if (!GetDirectoryForPath(filename).RemoveEntry(GetFilenameFromPath(filename)))
            {
                return(-1);
            }
            entry.SetName(newfilename);

            return(0);
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: je9000/dokan-memfs-je
        // Public methods follow...

        public int CreateFile(String filename, FileAccess access, FileShare share,
                              FileMode mode, FileOptions options, DokanFileInfo info)
        {
            MemFsEntry entry = GetEntryForPath(filename);

            // Not a lot to do for directories.
            if (entry != null && entry is MemFSDirectory)
            {
                info.IsDirectory = true;
                return(0);
            }

            // File exists and caller requests we overwrite.
            if ((entry != null) && (mode == FileMode.Create))
            {
                GetDirectoryForPath(filename).RemoveEntry(GetFilenameFromPath(filename));
                entry = null;
            }

            // File doesn't exist, do we create?
            if (entry == null)
            {
                if (mode == FileMode.Create || mode == FileMode.CreateNew || mode == FileMode.OpenOrCreate)
                {
                    if (GetDirectoryForPath(filename).AddFile(GetFilenameFromPath(filename)))
                    {
                        entry = GetEntryForPath(filename);
                        ((MemFSFile)entry).refcount = 1;
                        if ((options & FileOptions.DeleteOnClose) == FileOptions.DeleteOnClose)
                        {
                            ((MemFSFile)entry).deleteonclose = true;
                        }

                        return(0);
                    }
                    else
                    {
                        return(-1);
                    }
                }
                else
                {
                    return(-DokanNet.ERROR_FILE_NOT_FOUND);
                }
            }

            // File exists, do we open?
            if (mode == FileMode.CreateNew)
            {
                return(-DokanNet.ERROR_ALREADY_EXISTS);
            }

            // Okay, open it.

            if (!(entry is MemFSFile))
            {
                // We don't support anything other than files or directories
                // (which are opened above and created in another method).
                return(-1);
            }

            if ((options & FileOptions.DeleteOnClose) == FileOptions.DeleteOnClose)
            {
                // If they want delete-on-close, it must be opened that way
                // already.
                if ((((MemFSFile)entry).refcount > 0) &&
                    (!((MemFSFile)entry).deleteonclose)
                    )
                {
                    return(-1);
                }
            }

            if (mode == FileMode.Truncate)
            {
                ((MemFSFile)entry).Resize(0);
            }

            ((MemFSFile)entry).refcount++;
            return(0);
        }