Example #1
0
        public int FindFilesProxy(IntPtr rawFileName, IntPtr rawFillFindData, // function pointer
                                  ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string            file = GetFileName(rawFileName);
                FileInformation[] files;
                int ret = operations.FindFiles(file, out files, ConvertFileInfo(ref rawFileInfo));

                FILL_FIND_DATA fill = (FILL_FIND_DATA)Marshal.GetDelegateForFunctionPointer(rawFillFindData, typeof(FILL_FIND_DATA));

                if ((ret == 0) &&
                    (files != null)
                    )
                {
                    // ReSharper disable ForCanBeConvertedToForeach
                    // Used a single entry call to speed up the "enumeration" of the list
                    for (int index = 0; index < files.Length; index++)
                    // ReSharper restore ForCanBeConvertedToForeach
                    {
                        Addto(fill, ref rawFileInfo, files[index]);
                    }
                }
                return(ret);
            }
            catch (Exception ex)
            {
                Log.ErrorException("FindFilesProxy threw: ", ex);
                return(-1);
            }
        }
Example #2
0
        ////



        public int FindFilesProxy(string rawFileName, IntPtr rawFillFindData,
                                  // function pointer
                                  DokanFileInfo rawFileInfo)
        {
            try
            {
                IList <FileInformation> files;


                int ret = (int)_operations.FindFiles(rawFileName, out files, rawFileInfo);


                Debug.Assert(files != null);
                if (ret == ERROR_SUCCESS && files.Count != 0)
                {
                    var fill =
                        (FILL_FIND_DATA)Marshal.GetDelegateForFunctionPointer(rawFillFindData, typeof(FILL_FIND_DATA));
                    // Used a single entry call to speed up the "enumeration" of the list
                    for (int index = 0; index < files.Count; index++)

                    {
                        Addto(fill, rawFileInfo, files[index]);
                    }
                }
                return(ret);
            }
            catch
            {
#if DEBUGDOKAN
                Log("FindFilesProxy: {0}\n", rawFileName);
                //throw;
#endif
                return(ERROR_INVALID_HANDLE);
            }
        }
Example #3
0
        public NtStatus FindFiles(string filename, out IList <FileInformation> files, DokanFileInfo info)
        {
            CacheEntry entry = cache_.Lookup(filename);

            NtStatus ret = 0;

            if (entry.FindFilesRet == NtStatus.MaximumNtStatus)
            {
                ret = ope_.FindFiles(filename, out files, info);
                entry.FindFilesRet   = ret;
                entry.FindFilesValue = files;
            }
            else
            {
                files = new List <FileInformation>();
                IList <FileInformation> cfiles = entry.FindFilesValue;
                foreach (FileInformation e in cfiles)
                {
                    files.Add(e);
                }

                ret = entry.FindFilesRet;
            }
            return(ret);
        }
Example #4
0
        public DokanError FindFiles(string filename, out IList <FileInformation> files, DokanFileInfo info)
        {
            CacheEntry entry = cache_.Lookup(filename);

            DokanError ret = 0;

            if (entry.FindFilesRet == DokanError.Undefined)
            {
                ret = ope_.FindFiles(filename, out files, info);
                entry.FindFilesRet   = ret;
                entry.FindFilesValue = files;
            }
            else
            {
                files = new List <FileInformation>();
                IList <FileInformation> cfiles = entry.FindFilesValue;
                foreach (FileInformation e in cfiles)
                {
                    files.Add(e);
                }

                ret = entry.FindFilesRet;
            }
            return(ret);
        }
        ////

        public NtStatus FindFilesProxy(string rawFileName,
                                       IntPtr rawFillFindData,
                                       DokanFileInfo rawFileInfo)
        {
            try
            {
                IList <FileInformation> files;

                Trace("\nFindFilesProxy : " + rawFileName);
                Trace("\tContext\t" + ToTrace(rawFileInfo));

                NtStatus result = operations.FindFiles(rawFileName, out files, rawFileInfo);

                Debug.Assert(files != null);
                if (result == DokanResult.Success && files.Count != 0)
                {
                    foreach (FileInformation fi in files)
                    {
                        Trace("\n\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);
                    }

                    var fill =
                        (FILL_FIND_FILE_DATA)Marshal.GetDelegateForFunctionPointer(rawFillFindData, typeof(FILL_FIND_FILE_DATA));
                    // used a single entry call to speed up the "enumeration" of the list
                    for (int index = 0; index < files.Count; index++)
                    {
                        Addto(fill, rawFileInfo, files[index]);
                    }
                }

                Trace("FindFilesProxy : " + rawFileName + " Return : " + result);
                return(result);
            }
#pragma warning disable 0168
            catch (Exception ex)
#pragma warning restore 0168
            {
                Trace("FindFilesProxy : " + rawFileName + " Throw : " + ex.Message);
                return(DokanResult.InvalidParameter);
            }
        }
Example #6
0
        ////

        public NtStatus FindFilesProxy(string rawFileName,
                                       IntPtr rawFillFindData,
                                       DokanFileInfo rawFileInfo)
        {
            try
            {
                IList <FileInformation> files;

                logger.Debug("FindFilesProxy : {0}", rawFileName);
                logger.Debug("\tContext\t{0}", rawFileInfo);

                var result = operations.FindFiles(rawFileName, out files, rawFileInfo);

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

                    var fill =
                        (FILL_FIND_FILE_DATA)
                        Marshal.GetDelegateForFunctionPointer(rawFillFindData, typeof(FILL_FIND_FILE_DATA));
                    // used a single entry call to speed up the "enumeration" of the list
                    foreach (var t in files)
                    {
                        Addto(fill, rawFileInfo, t);
                    }
                }

                logger.Debug("FindFilesProxy : {0} Return : {1}", rawFileName, result);
                return(result);
            }
            catch (Exception ex)
            {
                logger.Error("FindFilesProxy : {0} Throw : {1}", rawFileName, ex.Message);
                return(DokanResult.InvalidParameter);
            }
        }
Example #7
0
        ////

        internal NtStatus FindFilesProxy(string rawFileName, IntPtr rawFillFindData, DokanFileInfo rawFileInfo)
        {
            try
            {
                IList <FileInformation> files;
                NtStatus result = _operations.FindFiles(rawFileName, out files, rawFileInfo);

                if (result == DokanResult.Success && files.Count != 0)
                {
                    var fill = (FILL_FIND_FILE_DATA)Marshal.GetDelegateForFunctionPointer(rawFillFindData, typeof(FILL_FIND_FILE_DATA));
                    // used a single entry call to speed up the "enumeration" of the list
                    for (int index = 0; index < files.Count; index++)
                    {
                        Addto(fill, rawFileInfo, files[index]);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Warn("Dokan exception: ", ex);
                return(DokanResult.InvalidParameter);
            }
        }