Exemplo n.º 1
0
        private static void Addto(FILL_FIND_DATA fill, DokanFileInfo rawFileInfo, FileInformation fi)
        {
            Debug.Assert(!String.IsNullOrEmpty(fi.FileName));
            long ctime = fi.CreationTime.ToFileTime();
            long atime = fi.LastAccessTime.ToFileTime();
            long mtime = fi.LastWriteTime.ToFileTime();
            var  data  = new WIN32_FIND_DATA
            {
                dwFileAttributes = fi.Attributes,
                ftCreationTime   =
                {
                    dwHighDateTime = (int)(ctime >> 32),
                    dwLowDateTime  = (int)(ctime & 0xffffffff)
                },
                ftLastAccessTime =
                {
                    dwHighDateTime = (int)(atime >> 32),
                    dwLowDateTime  = (int)(atime & 0xffffffff)
                },
                ftLastWriteTime =
                {
                    dwHighDateTime = (int)(mtime >> 32),
                    dwLowDateTime  = (int)(mtime & 0xffffffff)
                },
                nFileSizeLow  = (uint)(fi.Length & 0xffffffff),
                nFileSizeHigh = (uint)(fi.Length >> 32),
                cFileName     = fi.FileName
            };

            //ZeroMemory(&data, sizeof(WIN32_FIND_DATAW));

            fill(ref data, rawFileInfo);
        }
Exemplo n.º 2
0
        private void Addto(FILL_FIND_DATA fill, ref DOKAN_FILE_INFO rawFileInfo, FileInformation fi)
        {
            WIN32_FIND_DATA data = new WIN32_FIND_DATA
            {
                dwFileAttributes = fi.Attributes,
                ftCreationTime   =
                {
                    dwHighDateTime = (int)(fi.CreationTime.ToFileTime() >> 32),
                    dwLowDateTime  = (int)(fi.CreationTime.ToFileTime() & 0xffffffff)
                },
                ftLastAccessTime =
                {
                    dwHighDateTime = (int)(fi.LastAccessTime.ToFileTime() >> 32),
                    dwLowDateTime  = (int)(fi.LastAccessTime.ToFileTime() & 0xffffffff)
                },
                ftLastWriteTime =
                {
                    dwHighDateTime = (int)(fi.LastWriteTime.ToFileTime() >> 32),
                    dwLowDateTime  = (int)(fi.LastWriteTime.ToFileTime() & 0xffffffff)
                },
                nFileSizeLow  = (uint)(fi.Length & 0xffffffff),
                nFileSizeHigh = (uint)(fi.Length >> 32),
                cFileName     = fi.FileName
            };

            //ZeroMemory(&data, sizeof(WIN32_FIND_DATAW));

            fill(ref data, ref rawFileInfo);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        public int FindFilesProxy(
            IntPtr rawFileName,
            IntPtr rawFillFindData, // function pointer
            ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string file = GetFileName(rawFileName);

                ArrayList files = new ArrayList();
                int       ret   = operations_.FindFiles(file, files, GetFileInfo(ref rawFileInfo));

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

                if (ret == 0)
                {
                    IEnumerator entry = files.GetEnumerator();
                    while (entry.MoveNext())
                    {
                        FileInformation fi   = (FileInformation)(entry.Current);
                        WIN32_FIND_DATA data = new WIN32_FIND_DATA();
                        //ZeroMemory(&data, sizeof(WIN32_FIND_DATAW));

                        data.dwFileAttributes = fi.Attributes;

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

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

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

                        data.nFileSizeLow =
                            (uint)(fi.Length & 0xffffffff);
                        data.nFileSizeHigh =
                            (uint)(fi.Length >> 32);

                        data.cFileName = fi.FileName;

                        fill(ref data, ref rawFileInfo);
                    }
                }
                return(ret);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e.ToString());
                return(-1);
            }
        }
Exemplo n.º 5
0
        private static void Addto(FILL_FIND_DATA fill, DokanFileInfo rawFileInfo, FileInformation fi)
        {
            Debug.Assert(!String.IsNullOrEmpty(fi.FileName));
            long ctime = fi.CreationTime.ToFileTime();
            long atime = fi.LastAccessTime.ToFileTime();
            long mtime = fi.LastWriteTime.ToFileTime();
            var data = new WIN32_FIND_DATA
            {
                dwFileAttributes = fi.Attributes,
                ftCreationTime =
                                   {
                                       dwHighDateTime = (int) (ctime >> 32),
                                       dwLowDateTime = (int) (ctime & 0xffffffff)
                                   },
                ftLastAccessTime =
                                   {
                                       dwHighDateTime = (int) (atime >> 32),
                                       dwLowDateTime = (int) (atime & 0xffffffff)
                                   },
                ftLastWriteTime =
                                   {
                                       dwHighDateTime = (int) (mtime >> 32),
                                       dwLowDateTime = (int) (mtime & 0xffffffff)
                                   },
                nFileSizeLow = (uint)(fi.Length & 0xffffffff),
                nFileSizeHigh = (uint)(fi.Length >> 32),
                cFileName = fi.FileName
            };
            //ZeroMemory(&data, sizeof(WIN32_FIND_DATAW));

            fill(ref data, rawFileInfo);
        }
Exemplo n.º 6
0
        public int FindFilesWithPatternProxy(IntPtr rawFileName, IntPtr rawSearchPattern, IntPtr rawFillFindData, // function pointer
                                             ref DOKAN_FILE_INFO rawFileInfo)
        {
            try
            {
                string            file    = GetFileName(rawFileName);
                string            pattern = GetFileName(rawSearchPattern);
                int               ret;
                FileInformation[] files    = null;
                char[]            matchDOS = ("\"<>?").ToCharArray();
                if (-1 != pattern.IndexOfAny(matchDOS)) // See http://liquesce.codeplex.com/workitem/7556
                {
                    Log.Info("An Application is using DOS_STAR style pattern matching[{0}], Will switch to compatible mode matching", pattern);
                    // PureSync (And maybe others) use the following to get this and / or the subdir contents
                    // DirName<"*
                    // But there is an issue with the code inside dokan see http://code.google.com/p/dokan/issues/detail?id=192
                    FileInformation[] nonPatternFiles;
                    ret = operations.FindFiles(file, out nonPatternFiles, ConvertFileInfo(ref rawFileInfo));
                    if (ret == Dokan.DOKAN_SUCCESS)
                    {
                        List <FileInformation> matchedFiles = new List <FileInformation>();
                        matchedFiles.AddRange(nonPatternFiles.Where(patternFile => DokanDll.DokanIsNameInExpression(pattern, patternFile.FileName, false)));
                        files = matchedFiles.ToArray();
                    }
                    // * (asterisk) Matches zero or more characters.
                    // ? (question mark) Matches a single character.
                    // #define DOS_DOT (L'"') -  Matches either a period or zero characters beyond the name string.
                    // #define DOS_QM (L'>') - Matches any single character or, upon encountering a period or end of name string,
                    // advances the expression to the end of the set of contiguous DOS_QMs.
                    // #define DOS_STAR (L'<') - Matches zero or more characters until encountering and matching the final . in the name.
                    Log.Debug("DOS_STAR style pattern OUT [found {0}]", (files != null) ? files.Length : 0);
                    if (Log.IsTraceEnabled)
                    {
                        if (files != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine();
                            for (int index = 0; index < files.Length; index++)
                            {
                                FileInformation fileInformation = files[index];
                                sb.AppendLine(fileInformation.FileName);
                            }
                            Log.Trace(sb.ToString());
                        }
                    }
                }
                else
                {
                    ret = operations.FindFilesWithPattern(file, pattern, 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);
            }
        }