Exemplo n.º 1
0
        /// <summary>
        /// if dir is not empty it can't be deleted
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public NtStatus DeleteDirectory(string fileName, IDokanFileInfo info)
        {
            var e = info.GetFSEntryPointer();

            if (e == null)
            {
                e = Storage.GetFileInfo(fileName);
            }
            if (e != null && !e.IsFile())
            {
                return(Storage.DeleteDirectory(e as IFSDirectory).GetNtStatus());
            }
            return(NtStatus.ObjectNameNotFound);
        }
Exemplo n.º 2
0
        /// <summary>
        /// we just check here if we could delete the file - the true deletion is in Cleanup
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public NtStatus DeleteFile(string fileName, IDokanFileInfo info)
        {
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            if (e?.IsFile() == false)
            {
                return(NtStatus.AccessDenied);
            }
            return(NtStatus.Success);
        }
Exemplo n.º 3
0
        public NtStatus ReadFile(string fileName, byte[] buffer, out int bytesRead, long offset, IDokanFileInfo info)
        {
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            if (e?.IsFile() == true)
            {
                return((e as IFSFile).Read(buffer, out bytesRead, offset).GetNtStatus());
            }
            bytesRead = 0;
            return(NtStatus.Success);
        }
Exemplo n.º 4
0
        public void Cleanup(string fileName, IDokanFileInfo info)
        {
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            ;
            if (e != null)
            {
                e.Cleanup(info.DeleteOnClose);
            }
            info.Context = null;
        }
Exemplo n.º 5
0
        public NtStatus GetFileInformation(string fileName, out FileInformation fileInfo, IDokanFileInfo info)
        {
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            if (e != null)
            {
                fileInfo = e.ToFileInformation();
                return(NtStatus.Success);
            }
            fileInfo = default;
            return(NtStatus.ObjectNameNotFound);
        }
Exemplo n.º 6
0
        public NtStatus SetFileSecurity(string fileName, FileSystemSecurity security, AccessControlSections sections, IDokanFileInfo info)
        {
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            if (e.IsFile())
            {
                return((e as IFSFile).SetAccessControl((FileSecurity)security).GetNtStatus());
            }
            else
            {
                return((e as IFSDirectory).SetAccessControl((DirectorySecurity)security).GetNtStatus());
            }
        }
Exemplo n.º 7
0
 public NtStatus SetEndOfFile(string fileName, long length, IDokanFileInfo info)
 {
     try {
         if (info.Context == null)
         {
             info.Context = Storage.GetFileInfo(fileName);
         }
         var e = info.GetFSEntryPointer();
         if (e?.IsFile() == true)
         {
             (e as IFSFile).SetLength(length);
         }
         return(NtStatus.Success);
     } catch (IOException) {
         return(NtStatus.DiskFull);
     }
 }
Exemplo n.º 8
0
        public NtStatus SetFileAttributes(string fileName, FileAttributes attributes, IDokanFileInfo info)
        {
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            if (e?.IsFile() == true)
            {
                return((e as IFSFile).SetAttributes(attributes).GetNtStatus());
            }
            else
            {
                return(NtStatus.ObjectTypeMismatch);
            }
        }
Exemplo n.º 9
0
        public NtStatus FindFilesWithPattern(string fileName, string searchPattern, out IList <FileInformation> files, IDokanFileInfo info)
        {
            files = new List <FileInformation>();
            if (info.Context == null)
            {
                info.Context = Storage.GetFileInfo(fileName);
            }
            var e = info.GetFSEntryPointer();

            if (e?.IsFile() == false)
            {
                foreach (var i in (e as IFSDirectory).GetContent(searchPattern))
                {
                    files.Add(i.ToFileInformation());
                }
            }
            return(NtStatus.Success);
        }
Exemplo n.º 10
0
 public NtStatus UnlockFile(string fileName, long offset, long length, IDokanFileInfo info)
 {
     try {
         if (info.Context == null)
         {
             info.Context = Storage.GetFileInfo(fileName);
         }
         var e = info.GetFSEntryPointer();
         if (e?.IsFile() == true)
         {
             (e as IFSFile).UnLock(offset, length);
             return(NtStatus.Success);
         }
         return(NtStatus.ObjectTypeMismatch);
     } catch (IOException) {
         return(NtStatus.AccessDenied);
     }
 }