Example #1
0
        public FSItem GetItem(string name)
        {
            if (name == "\\" || name == "")
            {
                return(this);
            }

            if (name.StartsWith("\\"))
            {
                name = name.Remove(0, 1);
            }

            string[] nameparts = name.Split(new char[] { '\\' }, 2);

            FSItem child = Children.FirstOrDefault(c => nameparts[0] == c.Name);

            if (child != null)
            {
                if (nameparts.Length > 1)
                {
                    return(child.GetItem("\\" + nameparts[1]));
                }
                else
                {
                    return(child);
                }
            }

            return(null);
        }
Example #2
0
 public override NT_STATUS Close(FileContext FileObject)
 {
     lock (this)
     {
         FSItem item = ((MTPFileContext)FileObject).FSItem;
         return(item.Close());
     }
 }
Example #3
0
 public override NT_STATUS GetAttributes(UserContext UserContext, FileContext FileObject, out DirectoryContext Attr)
 {
     lock (this)
     {
         FSItem item = ((MTPFileContext)FileObject).FSItem;
         return(item.GetAttributes(UserContext, out Attr));
     }
 }
Example #4
0
 public override NT_STATUS Write(UserContext UserContext, FileContext FileObject, long Offset, ref int Count, ref byte[] Buffer, int BufferStart)
 {
     lock (this)
     {
         FSItem item = ((MTPFileContext)FileObject).FSItem;
         return(item.Write(UserContext, Offset, ref Count, ref Buffer, BufferStart));
     }
 }
Example #5
0
 public override NT_STATUS Flush(UserContext UserContext, FileContext FileObject)
 {
     lock (this)
     {
         FSItem item = ((MTPFileContext)FileObject).FSItem;
         return(item.Flush(UserContext));
     }
 }
Example #6
0
 public override NT_STATUS ReadDirectory(UserContext UserContext, FileContext FileObject)
 {
     lock (this)
     {
         FSItem item = ((MTPFileContext)FileObject).FSItem;
         return(item.ReadDirectory(UserContext, (MTPFileContext)FileObject));
     }
 }
Example #7
0
        public override NT_STATUS Delete(UserContext UserContext, string FileName)
        {
            lock (this)
            {
                FSItem item = _topItem.GetItem(Name);

                if (item != null)
                {
                    return(item.Delete(UserContext));
                }

                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #8
0
        public override NT_STATUS Rename(UserContext UserContext, string OldName, string NewName)
        {
            lock (this)
            {
                FSItem item = GetItem(OldName);

                if (item != null)
                {
                    return(item.Rename(UserContext, NewName));
                }

                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #9
0
        public override NT_STATUS DeleteDirectory(UserContext UserContext, string DirName)
        {
            lock (this)
            {
                FSItem item = GetItem(DirName);

                if (item != null)
                {
                    return(item.DeleteDirectory(UserContext));
                }

                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #10
0
        public override NT_STATUS GetAttributes(UserContext UserContext, string Name, out DirectoryContext Attr)
        {
            lock (this)
            {
                FSItem item = _topItem.GetItem(Name);

                if (item != null)
                {
                    return(item.GetAttributes(UserContext, out Attr));
                }

                Attr = null;
                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #11
0
        public override NT_STATUS CreateDirectory(UserContext UserContext, string DirName, FileAttributes Attributes)
        {
            lock (this)
            {
                string parent = Path.GetDirectoryName(DirName);
                string name   = Path.GetFileName(parent);
                FSItem item   = GetItem(DirName);

                if (item != null)
                {
                    return(item.CreateChildDirectory(UserContext, name, Attributes));
                }

                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #12
0
        public override NT_STATUS GetStreamInfo(UserContext UserContext, string Name, out List <DirectoryContext> StreamInfo)
        {
            lock (this)
            {
                FSItem item = GetItem(Name);

                if (item != null)
                {
                    StreamInfo = new List <DirectoryContext>();
                    return(NT_STATUS.OK);
                }

                StreamInfo = null;
                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #13
0
        public override NT_STATUS Create(UserContext UserContext, string Name, SearchFlag SearchFlags, FileMode Mode, FileAccess Access, FileShare Share, FileAttributes Attributes, out FileContext fileContext)
        {
            lock (this)
            {
                FSItem item = _topItem.GetItem(Name);

                if (item != null)
                {
                    MTPFileContext mtpFileContext;
                    NT_STATUS      status = item.Create(UserContext, Name, SearchFlags, Mode, Access, Share, Attributes, out mtpFileContext);
                    fileContext = mtpFileContext;
                    return(status);
                }

                fileContext = null;
                return(NT_STATUS.NO_SUCH_FILE);
            }
        }
Example #14
0
 public MTPFileContext(FSItem fsItem) : base(fsItem.Name, fsItem.IsDirectory)
 {
     FSItem = fsItem;
 }