Exemplo n.º 1
0
        public int GetFileInformation(IntPtr rawFilename, ref FuserDefinition.BY_HANDLE_FILE_INFORMATION rawHandleFileInformation, ref FuserDefinition.FUSER_FILE_INFO rawHFile)
        {
            try {
                FuserFileInformation fi = new FuserFileInformation();

                Win32Returncode ret = this.fsDevice.GetFileInformation(this.hManager.GetFileHandler(GetFilename(rawFilename), ref rawHFile), fi);

                if (ret == Win32Returncode.SUCCESS)
                {
                    if (fi.CreationTime == DateTime.MinValue || fi.LastAccessTime == DateTime.MinValue || fi.LastWriteTime == DateTime.MinValue)
                    {
                        ret = Win32Returncode.DEFAULT_UNKNOWN_ERROR;
                    }
                }

                if (ret == Win32Returncode.SUCCESS)
                {
                    ConvertFileInfoToRAW(fi, ref rawHandleFileInformation);
                }

                return(ConvReturnCodeToInt(ret));
            } catch (Exception e) {
                this.fsDevice.LogErrorMessage("GetFileInformation", e.Message);
                return(ConvReturnCodeToInt(Win32Returncode.DEFAULT_UNKNOWN_ERROR));
            }
        }
Exemplo n.º 2
0
        private void ConvertFileInfoToRAW(FuserFileInformation fi, ref FuserDefinition.BY_HANDLE_FILE_INFORMATION rawHandleFileInformation)
        {
            // TODO: boundary values and behaviour testing
            rawHandleFileInformation.dwFileAttributes = (uint)fi.Attributes;

            rawHandleFileInformation.ftCreationTime   = ConvLongToFILETIME(fi.CreationTime.ToFileTime());
            rawHandleFileInformation.ftLastAccessTime = ConvLongToFILETIME(fi.LastAccessTime.ToFileTime());
            rawHandleFileInformation.ftLastWriteTime  = ConvLongToFILETIME(fi.LastWriteTime.ToFileTime());

            //ConvLongToRAW(fi.Length, out rawHandleFileInformation.nFileSizeHigh, out rawHandleFileInformation.nFileSizeLow);
            // TODO: Check if the parameter nFileSizeHigh/nFileSizeLow also works as INT, then only the above line leave it.
            int h;
            int l;

            ConvLongToRAW(fi.Length, out h, out l);
            rawHandleFileInformation.nFileSizeHigh = (uint)h;
            rawHandleFileInformation.nFileSizeLow  = (uint)l;
        }
Exemplo n.º 3
0
        public int FindFiles(IntPtr rawFilename, IntPtr FunctionFillFindData, ref FuserDefinition.FUSER_FILE_INFO rawHFile)
        {
            try {
                FuserDefinition.BY_HANDLE_FILE_INFORMATION rawFI = new FuserDefinition.BY_HANDLE_FILE_INFORMATION();

                List <FuserFileInformation> files = new List <FuserFileInformation>();
                Win32Returncode             ret   = this.fsDevice.FindFiles(this.hManager.GetFileHandler(GetFilename(rawFilename), ref rawHFile), files);

                FuserDefinition.FILL_FIND_DATA rawListAdd = (FuserDefinition.FILL_FIND_DATA)Marshal.GetDelegateForFunctionPointer(FunctionFillFindData, typeof(FuserDefinition.FILL_FIND_DATA)); // Function pointer

                if (ret == Win32Returncode.SUCCESS)
                {
                    foreach (FuserFileInformation fi in files)
                    {
                        if (!(fi.CreationTime == DateTime.MinValue || fi.LastAccessTime == DateTime.MinValue || fi.LastWriteTime == DateTime.MinValue))
                        {
                            FuserDefinition.WIN32_FIND_DATA data = new FuserDefinition.WIN32_FIND_DATA();

                            ConvertFileInfoToRAW(fi, ref rawFI);

                            data.ftCreationTime   = rawFI.ftCreationTime;
                            data.ftLastAccessTime = rawFI.ftLastAccessTime;
                            data.ftLastWriteTime  = rawFI.ftLastWriteTime;
                            data.nFileSizeLow     = rawFI.nFileSizeLow;
                            data.nFileSizeHigh    = rawFI.nFileSizeHigh;
                            data.dwFileAttributes = fi.Attributes;

                            data.cFileName = fi.Filename;

                            rawListAdd(ref data, ref rawHFile);
                        }
                    }
                }
                return(ConvReturnCodeToInt(ret));
            } catch (Exception e) {
                this.fsDevice.LogErrorMessage("FindFiles", e.Message);
                return(ConvReturnCodeToInt(Win32Returncode.DEFAULT_UNKNOWN_ERROR));
            }
        }