Пример #1
0
        public NtStatus GetFileInformation(string filename, out FileInformation fileinfo, DokanFileInfo info)
        {
            CacheEntry entry = cache_.Lookup(filename);

            NtStatus ret = 0;

            if (entry.GetFileInfoRet == NtStatus.MaximumNtStatus)
            {
                ret = ope_.GetFileInformation(filename, out fileinfo, info);
                entry.GetFileInfoRet   = ret;
                entry.GetFileInfoValue = fileinfo;
            }
            else
            {
                FileInformation finfo = entry.GetFileInfoValue;

                fileinfo                = new FileInformation();
                fileinfo.Attributes     = finfo.Attributes;
                fileinfo.CreationTime   = finfo.CreationTime;
                fileinfo.FileName       = finfo.FileName;
                fileinfo.LastAccessTime = finfo.LastAccessTime;
                fileinfo.LastWriteTime  = finfo.LastWriteTime;
                fileinfo.Length         = finfo.Length;

                ret = entry.GetFileInfoRet;
            }

            return(ret);
        }
        ////

        public NtStatus GetFileInformationProxy(string rawFileName,
                                                ref BY_HANDLE_FILE_INFORMATION rawHandleFileInformation,
                                                DokanFileInfo rawFileInfo)
        {
            FileInformation fi;

            try
            {
                Trace("\nGetFileInformationProxy : " + rawFileName);
                Trace("\tContext\t" + ToTrace(rawFileInfo));

                NtStatus result = operations.GetFileInformation(rawFileName, out fi, rawFileInfo);

                if (result == DokanResult.Success)
                {
                    Debug.Assert(fi.FileName != null);
                    Trace("\tFileName\t" + fi.FileName);
                    Trace("\tAttributes\t" + fi.Attributes);
                    Trace("\tCreationTime\t" + fi.CreationTime);
                    Trace("\tLastAccessTime\t" + fi.LastAccessTime);
                    Trace("\tLastWriteTime\t" + fi.LastWriteTime);
                    Trace("\tLength\t" + fi.Length);

                    rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes /* + FILE_ATTRIBUTE_VIRTUAL*/;

                    long ctime = fi.CreationTime.ToFileTime();
                    long atime = fi.LastAccessTime.ToFileTime();
                    long mtime = fi.LastWriteTime.ToFileTime();
                    rawHandleFileInformation.ftCreationTime.dwHighDateTime = (int)(ctime >> 32);
                    rawHandleFileInformation.ftCreationTime.dwLowDateTime  = (int)(ctime & 0xffffffff);

                    rawHandleFileInformation.ftLastAccessTime.dwHighDateTime = (int)(atime >> 32);
                    rawHandleFileInformation.ftLastAccessTime.dwLowDateTime  = (int)(atime & 0xffffffff);

                    rawHandleFileInformation.ftLastWriteTime.dwHighDateTime = (int)(mtime >> 32);
                    rawHandleFileInformation.ftLastWriteTime.dwLowDateTime  = (int)(mtime & 0xffffffff);

                    rawHandleFileInformation.dwVolumeSerialNumber = serialNumber;

                    rawHandleFileInformation.nFileSizeLow    = (uint)(fi.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh   = (uint)(fi.Length >> 32);
                    rawHandleFileInformation.dwNumberOfLinks = 1;
                    rawHandleFileInformation.nFileIndexHigh  = 0;
                    rawHandleFileInformation.nFileIndexLow   = (uint)fi.FileName.GetHashCode();
                }

                Trace("GetFileInformationProxy : " + rawFileName + " Return : " + result);
                return(result);
            }
#pragma warning disable 0168
            catch (Exception ex)
#pragma warning restore 0168
            {
                Trace("GetFileInformationProxy : " + rawFileName + " Throw : " + ex.Message);
                return(DokanResult.InvalidParameter);
            }
        }
Пример #3
0
        ////

        public NtStatus GetFileInformationProxy(string rawFileName,
                                                ref BY_HANDLE_FILE_INFORMATION rawHandleFileInformation,
                                                DokanFileInfo rawFileInfo)
        {
            try
            {
                logger.Debug("GetFileInformationProxy : {0}", rawFileName);
                logger.Debug("\tContext\t{0}", rawFileInfo);

                FileInformation fi;
                var             result = operations.GetFileInformation(rawFileName, out fi, rawFileInfo);

                if (result == DokanResult.Success)
                {
                    Debug.Assert(fi.FileName != null);
                    logger.Debug("\tFileName\t{0}", fi.FileName);
                    logger.Debug("\tAttributes\t{0}", fi.Attributes);
                    logger.Debug("\tCreationTime\t{0}", fi.CreationTime);
                    logger.Debug("\tLastAccessTime\t{0}", fi.LastAccessTime);
                    logger.Debug("\tLastWriteTime\t{0}", fi.LastWriteTime);
                    logger.Debug("\tLength\t{0}", fi.Length);

                    rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes /* + FILE_ATTRIBUTE_VIRTUAL*/;

                    var ctime = ToFileTime(fi.CreationTime);
                    var atime = ToFileTime(fi.LastAccessTime);
                    var mtime = ToFileTime(fi.LastWriteTime);
                    rawHandleFileInformation.ftCreationTime.dwHighDateTime = (int)(ctime >> 32);
                    rawHandleFileInformation.ftCreationTime.dwLowDateTime  = (int)(ctime & 0xffffffff);

                    rawHandleFileInformation.ftLastAccessTime.dwHighDateTime = (int)(atime >> 32);
                    rawHandleFileInformation.ftLastAccessTime.dwLowDateTime  = (int)(atime & 0xffffffff);

                    rawHandleFileInformation.ftLastWriteTime.dwHighDateTime = (int)(mtime >> 32);
                    rawHandleFileInformation.ftLastWriteTime.dwLowDateTime  = (int)(mtime & 0xffffffff);

                    rawHandleFileInformation.dwVolumeSerialNumber = serialNumber;

                    rawHandleFileInformation.nFileSizeLow    = (uint)(fi.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh   = (uint)(fi.Length >> 32);
                    rawHandleFileInformation.dwNumberOfLinks = 1;
                    rawHandleFileInformation.nFileIndexHigh  = 0;
                    rawHandleFileInformation.nFileIndexLow   = (uint)fi.FileName.GetHashCode();
                }

                logger.Debug("GetFileInformationProxy : {0} Return : {1}", rawFileName, result);
                return(result);
            }
            catch (Exception ex)
            {
                logger.Error("GetFileInformationProxy : {0} Throw : {1}", rawFileName, ex.Message);
                return(DokanResult.InvalidParameter);
            }
        }
Пример #4
0
        ////

        public int GetFileInformationProxy(string rawFileName,
                                           ref BY_HANDLE_FILE_INFORMATION rawHandleFileInformation,
                                           DokanFileInfo rawFileInfo)
        {
            FileInformation fi;

            try
            {
                int ret = (int)_operations.GetFileInformation(rawFileName, out fi, rawFileInfo);

                if (ret == ERROR_SUCCESS)
                {
                    Debug.Assert(fi.FileName != null);
                    rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes /* + FILE_ATTRIBUTE_VIRTUAL*/;

                    long ctime = fi.CreationTime.ToFileTime();
                    long atime = fi.LastAccessTime.ToFileTime();
                    long mtime = fi.LastWriteTime.ToFileTime();
                    rawHandleFileInformation.ftCreationTime.dwHighDateTime = (int)(ctime >> 32);
                    rawHandleFileInformation.ftCreationTime.dwLowDateTime  =
                        (int)(ctime & 0xffffffff);

                    rawHandleFileInformation.ftLastAccessTime.dwHighDateTime =
                        (int)(atime >> 32);
                    rawHandleFileInformation.ftLastAccessTime.dwLowDateTime =
                        (int)(atime & 0xffffffff);

                    rawHandleFileInformation.ftLastWriteTime.dwHighDateTime =
                        (int)(mtime >> 32);
                    rawHandleFileInformation.ftLastWriteTime.dwLowDateTime =
                        (int)(mtime & 0xffffffff);

                    rawHandleFileInformation.dwVolumeSerialNumber = _serialNumber;

                    rawHandleFileInformation.nFileSizeLow    = (uint)(fi.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh   = (uint)(fi.Length >> 32);
                    rawHandleFileInformation.dwNumberOfLinks = 1;
                    rawHandleFileInformation.nFileIndexHigh  = 0;
                    rawHandleFileInformation.nFileIndexLow   = (uint)fi.FileName.GetHashCode();
                }

                return(ret);
            }
            catch
            {
#if DEBUGDOKAN
                Log("GetFileInformationProxy: {0}\n", rawFileName);
                //throw;
#endif
                return(ERROR_INVALID_FUNCTION);
            }
        }
Пример #5
0
        ////

        internal NtStatus GetFileInformationProxy(string rawFileName, ref BY_HANDLE_FILE_INFORMATION rawHandleFileInformation, DokanFileInfo rawFileInfo)
        {
            FileInformation fileInformation;

            try
            {
                NtStatus result = _operations.GetFileInformation(rawFileName, out fileInformation, rawFileInfo);

                if (result == DokanResult.Success)
                {
                    rawHandleFileInformation.dwFileAttributes = (uint)fileInformation.Attributes;

                    long ctime = fileInformation.CreationTime.ToFileTime();
                    long atime = fileInformation.LastAccessTime.ToFileTime();
                    long mtime = fileInformation.LastWriteTime.ToFileTime();
                    rawHandleFileInformation.ftCreationTime.dwHighDateTime = (int)(ctime >> 32);
                    rawHandleFileInformation.ftCreationTime.dwLowDateTime  = (int)(ctime & 0xffffffff);

                    rawHandleFileInformation.ftLastAccessTime.dwHighDateTime = (int)(atime >> 32);
                    rawHandleFileInformation.ftLastAccessTime.dwLowDateTime  = (int)(atime & 0xffffffff);

                    rawHandleFileInformation.ftLastWriteTime.dwHighDateTime = (int)(mtime >> 32);
                    rawHandleFileInformation.ftLastWriteTime.dwLowDateTime  = (int)(mtime & 0xffffffff);

                    rawHandleFileInformation.dwVolumeSerialNumber = _serialNumber;

                    rawHandleFileInformation.nFileSizeLow    = (uint)(fileInformation.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh   = (uint)(fileInformation.Length >> 32);
                    rawHandleFileInformation.dwNumberOfLinks = 1;
                    rawHandleFileInformation.nFileIndexHigh  = 0;
                    rawHandleFileInformation.nFileIndexLow   = (uint)fileInformation.FileName.GetHashCode();
                }
                return(result);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Warn("Dokan exception: ", ex);
                return(DokanResult.InvalidParameter);
            }
        }
Пример #6
0
        public int GetFileInformationProxy(IntPtr rawFileName, ref BY_HANDLE_FILE_INFORMATION rawHandleFileInformation, ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string file = GetFileName(rawFileName);

                FileInformation fi = new FileInformation();

                int ret = operations.GetFileInformation(file, ref fi, ConvertFileInfo(ref rawFileInfo));

                if (ret == 0)
                {
                    rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes /* + FILE_ATTRIBUTE_VIRTUAL*/;

                    rawHandleFileInformation.ftCreationTime.dwHighDateTime = (int)(fi.CreationTime.ToFileTime() >> 32);
                    rawHandleFileInformation.ftCreationTime.dwLowDateTime  = (int)(fi.CreationTime.ToFileTime() & 0xffffffff);

                    rawHandleFileInformation.ftLastAccessTime.dwHighDateTime = (int)(fi.LastAccessTime.ToFileTime() >> 32);
                    rawHandleFileInformation.ftLastAccessTime.dwLowDateTime  = (int)(fi.LastAccessTime.ToFileTime() & 0xffffffff);

                    rawHandleFileInformation.ftLastWriteTime.dwHighDateTime = (int)(fi.LastWriteTime.ToFileTime() >> 32);
                    rawHandleFileInformation.ftLastWriteTime.dwLowDateTime  = (int)(fi.LastWriteTime.ToFileTime() & 0xffffffff);

                    rawHandleFileInformation.dwVolumeSerialNumber = volumeSerialNumber;

                    rawHandleFileInformation.nFileSizeLow    = (uint)(fi.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh   = (uint)(fi.Length >> 32);
                    rawHandleFileInformation.dwNumberOfLinks = 1;
                    rawHandleFileInformation.nFileIndexHigh  = 0;
                    rawHandleFileInformation.nFileIndexLow   = (uint)fi.FileName.GetHashCode();
                }

                return(ret);
            }
            catch (Exception ex)
            {
                Log.ErrorException("GetFileInformationProxy threw: ", ex);
                return(-1);
            }
        }