Esempio n. 1
0
        /// <summary>
        /// As with <see cref="SetLength(string, long, LVFSContextInfo)"/>, but for the predecessor source.
        /// </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>
        protected NtStatus PredecessorSetLength(string path, long length, LVFSContextInfo info)
        {
            WritableSource predecessor = mPredecessor as WritableSource;

            if (predecessor != null)
            {
                return(predecessor.SetLength(path, length, info));
            }
            else
            {
                return(PredecessorHasFile(path) ? DokanResult.AccessDenied : DokanResult.FileNotFound);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// As with <see cref="FlushBuffers(string, LVFSContextInfo)"/>, but for the predecessor source.
        /// </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>
        protected NtStatus PredecessorFlushBuffers(string path, LVFSContextInfo info)
        {
            WritableSource predecessor = mPredecessor as WritableSource;

            if (predecessor != null)
            {
                return(predecessor.FlushBuffers(path, info));
            }
            else
            {
                return(DokanResult.Success);
            }
        }
Esempio n. 3
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 abstract NtStatus SetLength(string path, long length, LVFSContextInfo info);
Esempio n. 4
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 abstract NtStatus SetFileSecurity(string path, FileSystemSecurity security, AccessControlSections sections, LVFSContextInfo info);
Esempio n. 5
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 abstract NtStatus MoveFile(string currentPath, string newPath, bool replace, LVFSContextInfo info);
Esempio n. 6
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 abstract NtStatus SetAllocatedSize(string path, long allocationSize, LVFSContextInfo info);
Esempio n. 7
0
        /// <summary>
        /// As with <see cref="WriteFile(string, byte[], out int, long, LVFSContextInfo)"/>, but for the predecessor source.
        /// </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>
        protected NtStatus PredecessorWriteFile(string path, byte[] buffer, out int bytesWritten, long offset, LVFSContextInfo info)
        {
            WritableSource predecessor = mPredecessor as WritableSource;

            if (predecessor != null)
            {
                return(predecessor.WriteFile(path, buffer, out bytesWritten, offset, info));
            }
            else
            {
                bytesWritten = 0;
                return(PredecessorHasFile(path) ? DokanResult.AccessDenied : DokanResult.FileNotFound);
            }
        }
Esempio n. 8
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 abstract NtStatus FlushBuffers(string path, LVFSContextInfo info);
Esempio n. 9
0
 /// <summary>
 /// As with CloseFileHandle, but for the predecessor source.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="info">The information for the context</param>
 /// <returns>True if the operation is successful</returns>
 protected bool PredecessorCloseFileHandle(string path, LVFSContextInfo info)
 {
     return(mPredecessor?.CloseFileHandle(path, info) ?? true);
 }
Esempio n. 10
0
 /// <summary>
 /// As with TryUnlockFileRegion, but for the predecessor source.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="startOffset">The offset at which the region to unlock starts</param>
 /// <param name="length">The length of the region to unlock</param>
 /// <param name="info">Holds the context for the operation and relevant information</param>
 /// <returns>True if the operation was successful, false if access was denied</returns>
 protected bool PredecessorTryUnlockFileRegion(string path, long startOffset, long length, LVFSContextInfo info)
 {
     return(mPredecessor?.TryUnlockFileRegion(path, startOffset, length, info) ?? false);
 }
Esempio n. 11
0
 /// <summary>
 /// Unlocks a region of the specified file from the specified offset with the specified length if possible. If this is an inappropriate action for this source, the request is passed on to the predecessor.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="startOffset">The offset at which the region to unlock starts</param>
 /// <param name="length">The length of the region to unlock</param>
 /// <param name="info">Holds the context for the operation and relevant information</param>
 /// <returns>True if the operation was successful, false if access was denied</returns>
 public abstract bool TryUnlockFileRegion(string path, long startOffset, long length, LVFSContextInfo info);
Esempio n. 12
0
        /// <summary>
        /// As with <see cref="MoveFile(string, string, bool, LVFSContextInfo)"/>, but for the predecessor source.
        /// </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>
        protected NtStatus PredecessorMoveFile(string currentPath, string newPath, bool replace, LVFSContextInfo info)
        {
            WritableSource predecessor = mPredecessor as WritableSource;

            if (predecessor != null)
            {
                return(predecessor.MoveFile(currentPath, newPath, replace, info));
            }
            else
            {
                return(PredecessorHasFile(currentPath) ? DokanResult.AccessDenied : DokanResult.FileNotFound);
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Gets the contents of the specified file starting at the specified offset and attempts to fill the buffer. If this is an inappropriate action for this source, the request is passed on to the predecessor.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="buffer">The buffer to fill with the file contents</param>
 /// <param name="bytesRead">The actual number of bytes read from the file. This may be less than the length of the buffer if not enough data is available.</param>
 /// <param name="offset">The byte at which to start reading.</param>
 /// <param name="info">Holds the context for the operation and relevant information</param>
 /// <returns>A bool indicating whether the operation was successful</returns>
 public abstract bool ReadFile(string path, byte[] buffer, out int bytesRead, long offset, LVFSContextInfo info);
Esempio n. 14
0
 /// <summary>
 /// Called once the last handle for a file has been closed and released. <paramref name="info"/>.Context will be lost after this method returns, so must be ready for this. This must recursively call the predecessor version if the predecessor source may have been invloved in any operations with this context.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="info">The information for the context</param>
 /// <returns>True if the operation was successful</returns>
 public abstract bool CloseFileHandle(string path, LVFSContextInfo info);
Esempio n. 15
0
 /// <summary>
 /// Called when a file handle is requested. If this is an inappropriate action for this source, the request is passed on to the predecessor.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="access">The type of access required</param>
 /// <param name="share">The kind of access other filestreams can have</param>
 /// <param name="mode">The mode to open the file in</param>
 /// <param name="options">Advanced options for creating a FileStream</param>
 /// <param name="attributes">The attributes of the file</param>
 /// <param name="info">A LVFSInfo containing the context for the file handle and information on the file.</param>
 /// <returns>An NtStatus explaining the success level of the operation. If mode is OpenOrCreate and Create, and the operation is successful opening an existing file, DokanResult.AlreadyExists must be returned.</returns>
 public abstract NtStatus CreateFileHandle(string path, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, LVFSContextInfo info);
Esempio n. 16
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 abstract NtStatus WriteFile(string path, byte[] buffer, out int bytesWritten, long offset, LVFSContextInfo info);
Esempio n. 17
0
        /// <summary>
        /// As with <see cref="SetFileSecurity(string, FileSystemSecurity, AccessControlSections, LVFSContextInfo)"/>, but for the predecessor source.
        /// </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>
        protected NtStatus PredecessorSetFileSecurity(string path, FileSystemSecurity security, AccessControlSections sections, LVFSContextInfo info)
        {
            WritableSource predecessor = mPredecessor as WritableSource;

            if (predecessor != null)
            {
                return(predecessor.SetFileSecurity(path, security, sections, info));
            }
            else
            {
                return(PredecessorHasFile(path) ? DokanResult.AccessDenied : DokanResult.FileNotFound);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// As with CreateFileHandle, but for the predecessor source.
        /// </summary>
        /// <param name="path">The path to the file</param>
        /// <param name="access">The type of access required</param>
        /// <param name="share">The kind of access other filestreams can have</param>
        /// <param name="mode">The mode to open the file in</param>
        /// <param name="options">Advanced options for creating a FileStream</param>
        /// <param name="attributes">The attributes of the file</param>
        /// <param name="info">A LVFSInfo containing the context for the file handle and information on the file.</param>
        /// <returns>An NtStatus explaining the success level of the operation. If mode is OpenOrCreate and Create, and the operation is successful opening an existing file, DokanResult.AlreadyExists must be returned.</returns>
        protected NtStatus PredecessorCreateFileHandle(string path, DokanNet.FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, LVFSContextInfo info)
        {
            if (mPredecessor != null)
            {
                return(mPredecessor.CreateFileHandle(path, access, share, mode, options, attributes, info));
            }
            else
            {
                switch (mode)
                {
                case FileMode.Create:
                case FileMode.CreateNew:
                case FileMode.OpenOrCreate:
                    return(DokanResult.AccessDenied);

                default:
                    return(DokanResult.FileNotFound);
                }
            }
        }
Esempio n. 19
0
 /// <summary>
 /// As with ReadFile, but for the predecessor source.
 /// </summary>
 /// <param name="path">The path to the file</param>
 /// <param name="buffer">The buffer to fill with the file contents</param>
 /// <param name="bytesRead">The actual number of bytes read from the file. This may be less than the length of the buffer if not enough data is available.</param>
 /// <param name="offset">The byte at which to start reading.</param>
 /// <param name="info">Holds the context for the operation and relevant information</param>
 /// <returns>A bool indicating whether the operation was successful</returns>
 protected bool PredecessorReadFile(string path, byte[] buffer, out int bytesRead, long offset, LVFSContextInfo info)
 {
     if (IsFirst)
     {
         bytesRead = 0;
         return(false);
     }
     else
     {
         return(mPredecessor.ReadFile(path, buffer, out bytesRead, offset, info));
     }
 }