////

        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;
            }
        }
Пример #2
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 DEBUG
                throw;
            #else
                return ERROR_INVALID_FUNCTION;
            #endif
            }
        }
        ////
        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;
            }
        }