Пример #1
0
        /// <summary>
        /// Sets the creation, last access, and last modification times for a file if they are specified. Any null values mean the value will not be changed.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="creationTime">The new creation time for the file, or <c>null</c> if it is not to be changed.</param>
        /// <param name="lastAccessTime">The new last access time for the file, or <c>null</c> if it is not to be changed.</param>
        /// <param name="lastWriteTime">The new last write time for the file, or <c>null</c> if it is not to be changed.</param>
        /// <returns><see cref="DokanResult.Success"/> if the operation was successful. If not, an appropriate error status.</returns>
        public NtStatus SetFileTimes(string path, DateTime?creationTime, DateTime?lastAccessTime, DateTime?lastWriteTime)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.SetFileTimes(path, creationTime, lastAccessTime, lastWriteTime));
            }
            else
            {
                return(DokanResult.AccessDenied);
            }
        }
Пример #2
0
        /// <summary>
        /// Sets the attributes of a file or directory.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="attributes">The attributes to set</param>
        /// <returns><see cref="DokanResult.Success"/> if the operation was successful. If not, an appropriate error status.</returns>
        public NtStatus SetFileAttributes(string path, System.IO.FileAttributes attributes)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.SetFileAttributes(path, attributes));
            }
            else
            {
                return(DokanResult.AccessDenied);
            }
        }
Пример #3
0
        /// <summary>
        /// Sets the security attributes for the specified sections of the specified file or directory.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="security">The security to set</param>
        /// <param name="sections">The access control sections to change</param>
        /// <param name="info">Information concerning the context of this operation.</param>
        /// <returns><see cref="DokanResult.Success"/> if the operation was successful. If not, an appropriate error status.</returns>
        public NtStatus SetFileSecurity(string path, FileSystemSecurity security, AccessControlSections sections, LVFSContextInfo info)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.SetFileSecurity(path, security, sections, info));
            }
            else
            {
                return(DokanResult.AccessDenied);
            }
        }
Пример #4
0
        /// <summary>
        /// Sets the length of the file.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="length">The new length of the file</param>
        /// <param name="info">Information concerning the context of this operation</param>
        /// <returns><see cref="DokanResult.Success"/> if the requested length is now the length of the file. If not, an appropriate error status.</returns>
        public NtStatus SetLength(string path, long length, LVFSContextInfo info)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.SetLength(path, length, info));
            }
            else
            {
                return(DokanResult.AccessDenied);
            }
        }
Пример #5
0
        /// <summary>
        /// Sets the allocated size for the file. If this is less than the current length, trucate the file. If the file does not grow to fill this space before the handle is released, it may be freed.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="allocationSize">The new size to allocate</param>
        /// <param name="info">Information concerning the context for this operation</param>
        /// <returns><see cref="DokanResult.Success"/> if the allocation size was changed or already the correct value. If not, an appropriate error status.</returns>
        public NtStatus SetAllocatedSize(string path, long allocationSize, LVFSContextInfo info)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.SetAllocatedSize(path, allocationSize, info));
            }
            else
            {
                return(DokanResult.AccessDenied);
            }
        }
Пример #6
0
        /// <summary>
        /// Moves the file/directory from its current path to a new one, replacing any existing files only if replace is set.
        /// </summary>
        /// <param name="currentPath">The current path of the file/directory</param>
        /// <param name="newPath">The new path of the file/directory</param>
        /// <param name="replace">Whether to replace any existing file occupying the new path</param>
        /// <param name="info">Information concerning the context for this operation.</param>
        /// <returns><see cref="DokanResult.Success"/> if the file was moved. Otherwise, an appropriate error status.</returns>
        public NtStatus MoveFile(string currentPath, string newPath, bool replace, LVFSContextInfo info)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.MoveFile(currentPath, newPath, replace, info));
            }
            else
            {
                return(DokanResult.AccessDenied);
            }
        }
Пример #7
0
        /// <summary>
        /// Clears any buffers for the context, and ensures any buffered data is written to the actual file.
        /// </summary>
        /// <param name="path">The path to the file whose buffers to flush</param>
        /// <param name="info">Information concerning the context for the operation</param>
        /// <returns><see cref="DokanResult.Success"/> if all buffers were flushed, If not, an appropriate error status.</returns>
        public NtStatus FlushBuffers(string path, LVFSContextInfo info)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.FlushBuffers(path, info));
            }
            else
            {
                return(DokanResult.NotImplemented);
            }
        }
Пример #8
0
        /// <summary>
        /// Writes the contents of the buffer to the requested file, starting at the requested offset, and sets the bytes written value to the number of bytes successfully written to the file.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="buffer">A buffer containing the data to write</param>
        /// <param name="bytesWritten">The number of bytes transferred from the buffer to the file</param>
        /// <param name="offset">The offset at which to start the write</param>
        /// <param name="info">Information concerning the context of this operation.</param>
        /// <returns><see cref="DokanResult.Success"/> if the operation was successful. If not, an appropriate error status.</returns>
        public NtStatus WriteFile(string path, byte[] buffer, out int bytesWritten, long offset, LVFSContextInfo info)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.WriteFile(path, buffer, out bytesWritten, offset, info));
            }
            else
            {
                bytesWritten = 0;
                return(DokanResult.AccessDenied);
            }
        }
Пример #9
0
        /// <summary>
        /// Checks if a file can be deleted, but doesn't actually do so. For the purpose of this method, directories do not count as files.
        /// </summary>
        /// <param name="path">The path to the file to check</param>
        /// <returns><see cref="DokanResult.Success"/> if the file can be delted. If not, an appropriate error status.</returns>
        public NtStatus CheckFileDeletable(string path)
        {
            WritableSource writable = Last as WritableSource;

            if (writable != null)
            {
                return(writable.CheckFileDeletable(path));
            }
            else if (Last != null && Last.GetFileInformation(path) != null)
            {
                return(DokanResult.AccessDenied);
            }
            else
            {
                return(DokanResult.FileNotFound);
            }
        }