Пример #1
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, fi, GetFileInfo(ref rawFileInfo));

                if (ret == 0)
                {
                    rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes;

                    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.nFileSizeLow =
                        (uint)(fi.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh =
                        (uint)(fi.Length >> 32);
                }

                return(ret);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return(-1);
            }
        }
Пример #2
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);
            }
        }
Пример #3
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, GetFileInfo(ref rawFileInfo));

                if (ret == 0)
                {
                    rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes;

                    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.nFileSizeLow =
                        (uint)(fi.Length & 0xffffffff);
                    rawHandleFileInformation.nFileSizeHigh =
                        (uint)(fi.Length >> 32);
                }

                return ret;

            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return -1;
            }

        }
Пример #4
0
        public int GetFileInformationProxy(
            IntPtr rawFileName,
            ref BY_HANDLE_FILE_INFORMATION rawHandleFileInformation,
            ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string file = GetFileName(rawFileName);

                var fi = operations_.GetFileInformation(file, GetFileInfo(ref rawFileInfo));

                rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes;

                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.nFileSizeLow = (uint)(fi.Length & 0xffffffff);
                rawHandleFileInformation.nFileSizeHigh = (uint)(fi.Length >> 32);

                return 0;

            }
            catch (FileNotFoundException e)
            {
                return DokanNet.ERROR_FILE_NOT_FOUND;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return -1;
            }
        }