internal NtStatus FindFilesWithPatternProxy(string rawFileName, string rawSearchPattern, IntPtr rawFillFindData, DokanFileInfo rawFileInfo) { try { IList <FileInformation> files; NtStatus result = _operations.FindFilesWithPattern(rawFileName, rawSearchPattern, 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); } }
public int FindFilesWithPatternProxy(string rawFileName, string searchPattern, IntPtr rawFillFindData, // function pointer DokanFileInfo rawFileInfo) { try { IList <FileInformation> files; int ret = (int)_operations.FindFilesWithPattern(rawFileName, searchPattern, 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("FindFilesProxyWithPattern: {0}\n", rawFileName); //throw; #endif return(ERROR_INVALID_HANDLE); } }
public NtStatus FindFilesWithPattern(string filename, string searchPattern, out IList <FileInformation> files, DokanFileInfo info) { // TODO : not cached, since searchPattern may change // alternatively, call FileFiles and search using searchPattern over cached result. // however, first we need to expose the DokanIsNameInExpression API function // or implement it ourselves in DokanNet return(ope_.FindFilesWithPattern(filename, searchPattern, out files, info)); }
public NtStatus FindFilesWithPatternProxy(string rawFileName, string rawSearchPattern, IntPtr rawFillFindData, DokanFileInfo rawFileInfo) { try { IList <FileInformation> files; logger.Debug("FindFilesWithPatternProxy : {0}", rawFileName); logger.Debug("\trawSearchPattern\t{0}", rawSearchPattern); logger.Debug("\tContext\t{0}", rawFileInfo); var result = operations.FindFilesWithPattern(rawFileName, rawSearchPattern, 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("FindFilesWithPatternProxy : {0} Return : {1}", rawFileName, result); return(result); } catch (Exception ex) { logger.Error("FindFilesWithPatternProxy : {0} Throw : {1}", rawFileName, ex.Message); return(DokanResult.InvalidParameter); } }
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); } }