//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void isEmptyMustFindFilesBothOnFileSystemAndPageCache() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void isEmptyMustFindFilesBothOnFileSystemAndPageCache() { File dir = BaseDir; File ignore = new File(dir, "ignore"); File a = new File(dir, "a"); File c = new File(dir, "c"); CreateOnFileSystem(a); CreateOnFileSystem(c); CreateOnFileSystem(ignore); FilenameFilter filter = (directory, name) => !name.StartsWith("ignore"); _storeFiles = new StoreFiles(_fs, _pageCache, filter); IList <File> filesOnFilesystem = new IList <File> { a, c }; IList <File> fileOnFilesystem = singletonList(a); IList <File> ignoredList = singletonList(ignore); assertFalse(_storeFiles.isEmpty(dir, filesOnFilesystem)); assertFalse(_storeFiles.isEmpty(dir, fileOnFilesystem)); assertTrue(_storeFiles.isEmpty(dir, Collections.emptyList())); assertTrue(_storeFiles.isEmpty(dir, ignoredList)); }
/// <summary> /// Returns a list of all files and subfolders found in the given folder. /// The search is recursive. /// </summary> /// <param name="basepath">The folder to look in.</param> /// <param name="filter">The filter to apply.</param> /// <returns>A list of the full filenames and foldernames. Foldernames ends with the directoryseparator char</returns> public static List <string> EnumerateFileSystemEntries(string basepath, FilenameFilter filter) { PathCollector c = new PathCollector(true, true, filter); EnumerateFileSystemEntries(basepath, new EnumerationCallbackDelegate(c.Callback)); return(c.Files); }
private List <ResultItem> DoTestSearchSelection(List <FilterDialog.FilterEntry> filters) { List <KeyValuePair <bool, string> > dyn_filters = new List <KeyValuePair <bool, string> >(); foreach (FilterDialog.FilterEntry fe in filters) { dyn_filters.Add(new KeyValuePair <bool, string>(fe.Include, fe.Filter)); } if (!string.IsNullOrEmpty(DynamicFilters)) { dyn_filters.AddRange(Library.Utility.FilenameFilter.DecodeFilter(DynamicFilters)); } FilenameFilter fn = new FilenameFilter(dyn_filters); try { CallbackHandler handler = new CallbackHandler(scanWorker, fn); foreach (string scanDir in Paths) { if (!scanWorker.CancellationPending) { Library.Utility.Utility.EnumerateFileSystemEntries(scanDir, handler.AddFileToList_Callback); } } return(handler.Results); } catch (AbortException) { return(null); } }
/// <summary> /// Calculates the size of files in a given folder /// </summary> /// <param name="folder">The folder to examine</param> /// <param name="filter">A filter to apply</param> /// <returns>The combined size of all files that match the filter</returns> public static long GetDirectorySize(string folder, FilenameFilter filter) { PathSizeCalculator c = new PathSizeCalculator(filter); EnumerateFileSystemEntries(folder, new EnumerationCallbackDelegate(c.Callback)); return(c.Size); }
public static string GetInfoFromFileName(string fileName, FilenameFilter filter) { // old convention // BlackMage_alpha_rmFF00FF.png // charactername_alpha_rmFF00FF.png // hazey_Trainer_alpha_rmFF00FF // artist_charactername_alpha_rmFF00FF.png // new convention // BlackMage_red_ARGB32 // %charactername%_%team%_ARGB32 // hazey_Trainer_red_ARGB32 // artist_%charactername%_%team%_ARGB32 string[] splitted = SplittFileName(fileName); if (splitted == null) { Debug.LogError(fileName + " SpittFileName == null"); } if (splitted.Length == 3 || splitted.Length == 4) { if (!string.IsNullOrEmpty(splitted[splitted.Length - (int)filter])) { return(splitted[splitted.Length - (int)filter]); } } Debug.LogError(fileName + " konnte Character namen nicht extrahieren"); return(null); }
private static string[] ListFiles(string directory, FilenameFilter filter) { List <string> list = new List <string>(); ListFiles(list, directory, filter); return(list.ToArray()); }
public PathCollector(bool includeFolders, bool includeFiles, FilenameFilter filter) { m_files = new List <string>(); m_filter = filter; m_includeFolders = includeFolders; m_includeFiles = includeFiles; }
private static List <User> ReadUsers(FileInfo dataDirectory, List <NetflixMovie> movies) { Dictionary <int, List <Preference> > userIDPrefMap = new Dictionary <int, List <Preference> >(104395301, 1.0f); //new HashMap<Integer, List<Preference>>(15485867, 1.0f); int counter = 0; FilenameFilter filenameFilter = new FilenameFilter( delegate(File dir, String filename) { return(filename.startsWith("mv_")); //return filename.startsWith("mv_000"); } ); foreach (FileInfo movieFile in new File(dataDirectory, "training_set").ListFiles(filenameFilter)) { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(movieFile))); String line = reader.readLine(); if (line == null) { throw new IOException("Can't read first line of file " + movieFile); } int movieID = int.parse(line.substring(0, line.length() - 1)); NetflixMovie movie = movies.get(movieID - 1); if (movie == null) { throw new ArgumentException("No such movie: " + movieID); } while ((line = reader.readLine()) != null) { counter++; if (counter % 100000 == 0) { log.Info("Processed " + counter + " prefs"); } int firstComma = line.indexOf((int)','); Int32 userID = Int32.Parse(line.Substring(0, firstComma)); int secondComma = line.IndexOf((int)',', firstComma + 1); double rating = Double.Parse(line.Substring(firstComma + 1, secondComma)); List <Preference> userPrefs = userIDPrefMap.get(userID); if (userPrefs == null) { userPrefs = new List <Preference>(); userIDPrefMap.Add(userID, userPrefs); } userPrefs.Add(new GenericPreference(null, movie, rating)); } IOUtils.quietClose(reader); } List <User> users = new List <User>(userIDPrefMap.Count); foreach (KeyValuePair <int, List <Preference> > entry in userIDPrefMap) { users.Add(new GenericUser <int>(entry.Key, entry.Value)); } return(users); }
/// <summary> /// Search the asset database for all files matching the specified filter. /// </summary> /// <returns>Array of matching files.</returns> /// <param name="assetsFilter">Filter used to query the /// AssetDatabase. If this isn't specified, all assets are searched. /// </param> /// <param name="filter">Optional delegate to filter the returned /// list.</param> public static string[] SearchAssetDatabase(string assetsFilter = null, FilenameFilter filter = null) { return(StringArrayFromObject(InvokeImplMethod("SearchAssetDatabase", null, namedArgs: new Dictionary <string, object> { { "assetsFilter", assetsFilter }, { "filter", filter } }))); }
private static List<User> ReadUsers(FileInfo dataDirectory, List<NetflixMovie> movies) { Dictionary<int, List<Preference>> userIDPrefMap = new Dictionary<int, List<Preference>>(104395301, 1.0f); //new HashMap<Integer, List<Preference>>(15485867, 1.0f); int counter = 0; FilenameFilter filenameFilter = new FilenameFilter( delegate(File dir, String filename) { return filename.startsWith("mv_"); //return filename.startsWith("mv_000"); } ); foreach (FileInfo movieFile in new File(dataDirectory, "training_set").ListFiles(filenameFilter)) { BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(movieFile))); String line = reader.readLine(); if (line == null) { throw new IOException("Can't read first line of file " + movieFile); } int movieID = int.parse(line.substring(0, line.length() - 1)); NetflixMovie movie = movies.get(movieID - 1); if (movie == null) { throw new ArgumentException("No such movie: " + movieID); } while ((line = reader.readLine()) != null) { counter++; if (counter % 100000 == 0) { log.Info("Processed " + counter + " prefs"); } int firstComma = line.indexOf((int) ','); Int32 userID = Int32.Parse(line.Substring(0, firstComma)); int secondComma = line.IndexOf((int) ',', firstComma + 1); double rating = Double.Parse(line.Substring(firstComma + 1, secondComma)); List<Preference> userPrefs = userIDPrefMap.get(userID); if (userPrefs == null) { userPrefs = new List<Preference>(); userIDPrefMap.Add(userID, userPrefs); } userPrefs.Add(new GenericPreference(null, movie, rating)); } IOUtils.quietClose(reader); } List<User> users = new List<User>(userIDPrefMap.Count); foreach (KeyValuePair<int, List<Preference>> entry in userIDPrefMap) { users.Add(new GenericUser<int>(entry.Key, entry.Value)); } return users; }
private void BlockedThreadRunner(object _args) { object[] args = (object[])_args; string roothpath = (string)args[0]; FilenameFilter filter = (FilenameFilter)args[1]; FileSystemInteraction folderList = (FileSystemInteraction)args[2]; FileSystemInteraction fileList = (FileSystemInteraction)args[3]; EnumerateFileSystemEntries(roothpath, Callback, folderList, fileList); m_queue.SetCompleted(); }
/// <summary> /// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの文字列の配列を返します。 /// </summary> public string[] list(FilenameFilter filter) { List <string> ret = new List <string>(); foreach (string s in list()) { if (filter.accept(this, s)) { ret.Add(s); } } return(ret.ToArray()); }
/// <summary> /// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。 /// </summary> public File[] listFiles(FilenameFilter filter) { List <File> ret = new List <File>(); foreach (string s in list()) { if (filter.accept(this, s)) { File f = new File(m_path + separator + s); ret.Add(f); } } return(ret.ToArray()); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public java.io.File[] listFiles(java.io.File directory, final java.io.FilenameFilter filter) public override File[] ListFiles(File directory, FilenameFilter filter) { try { using (Stream <Path> listing = Files.list(Path(directory))) { //JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter: return(listing.filter(entry => filter.accept(entry.Parent.toFile(), entry.FileName.ToString())).map(Path.toFile).toArray(File[] ::new)); } } catch (IOException) { return(null); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void deleteMustNotDeleteIgnoredFiles() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DeleteMustNotDeleteIgnoredFiles() { File dir = BaseDir; File a = new File(dir, "a"); File c = new File(dir, "c"); CreateOnFileSystem(a); CreateOnFileSystem(c); FilenameFilter filter = (directory, name) => !name.Equals("c") && !name.Equals("d"); _storeFiles = new StoreFiles(_fs, _pageCache, filter); _storeFiles.delete(dir, _logFiles); assertFalse(_fs.fileExists(a)); assertTrue(_fs.fileExists(c)); }
private static void ListFiles(List<string> list, string directory, FilenameFilter filter) { if (filter(directory)) { list.Add(directory); string[] directories = Directory.GetDirectories(directory); foreach (string child in directories) { ListFiles(list, child, filter); } string[] files = Directory.GetFiles(directory); foreach (string file in files) { if (filter(file)) { list.Add(file); } } } }
public File[] listFiles(FilenameFilter filter) { if (!this.isDirectory()) { return(null); } java.util.ArrayList <File> entries = new util.ArrayList <File>(); foreach (String next in System.IO.Directory.EnumerateFileSystemEntries(this.fullQualifiedFile)) { if (filter.accept(this, next)) { entries.add(new File(next)); } } File[] content = new File[entries.size()]; return(entries.toArray <File>(content)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void deleteMustNotDeleteFilesInIgnoredDirectories() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void DeleteMustNotDeleteFilesInIgnoredDirectories() { File dir = BaseDir; File ignore = new File(dir, "ignore"); File a = new File(dir, "a"); File c = new File(ignore, "c"); CreateOnFileSystem(a); CreateOnFileSystem(c); FilenameFilter filter = (directory, name) => !name.StartsWith("ignore"); _storeFiles = new StoreFiles(_fs, _pageCache, filter); _storeFiles.delete(dir, _logFiles); assertFalse(_fs.fileExists(a)); assertTrue(_fs.fileExists(c)); }
public FileHandle[] list(FilenameFilter filter) { var matchingChilds = new List <FileHandle>(); var childs = list(); //Not using foreach or LINQ query because they could be as much as 10x slower. // ReSharper disable once ForCanBeConvertedToForeach // ReSharper disable once LoopCanBeConvertedToQuery for (var i = 0; i < childs.Length; i++) { if (filter.accept(new java.io.File(pathWithPrefix()), childs[i].name())) { matchingChilds.Add(childs[i]); } } return(matchingChilds.ToArray()); }
public string[] List(FilenameFilter filter) { try { if (IsFile()) { return(null); } List <string> list = new List <string> (); foreach (string filePth in Directory.GetFileSystemEntries(path)) { string fileName = Path.GetFileName(filePth); if ((filter == null) || filter.Accept(this, fileName)) { list.Add(fileName); } } return(list.ToArray()); } catch { return(null); } }
private long SumIndexFiles(File file, FilenameFilter filter) { long total = 0; if (_outsideWorld.fileSystem().isDirectory(file)) { File[] children = _outsideWorld.fileSystem().listFiles(file, filter); if (children != null) { foreach (File child in children) { total += SumIndexFiles(child, filter); } } } else { total += _outsideWorld.fileSystem().getFileSize(file); } return(total); }
private static void ListFiles(List <string> list, string directory, FilenameFilter filter) { if (filter(directory)) { list.Add(directory); string[] directories = Directory.GetDirectories(directory); foreach (string child in directories) { ListFiles(list, child, filter); } string[] files = Directory.GetFiles(directory); foreach (string file in files) { if (filter(file)) { list.Add(file); } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void moveMustIgnoreFilesFilteredOut() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void MoveMustIgnoreFilesFilteredOut() { File @base = BaseDir; File src = new File(@base, "src"); File a = new File(src, "a"); File ignore = new File(src, "ignore"); File c = new File(ignore, "c"); File tgt = new File(@base, "tgt"); CreateOnFileSystem(a); CreateOnFileSystem(c); // Ensure the 'tgt' directory exists CreateOnFileSystem(new File(tgt, ".fs-ignore")); FilenameFilter filter = (directory, name) => !name.StartsWith("ignore"); _storeFiles = new StoreFiles(_fs, _pageCache, filter); _storeFiles.moveTo(src, tgt, _logFiles); assertFalse(_fs.fileExists(a)); assertTrue(_fs.fileExists(c)); assertTrue(_fs.fileExists(new File(tgt, "a"))); }
/// <summary> /// Return the complete list of files in a directory as strings.<p/> /// This is better than File#listDir because it does not ignore IOExceptions. /// </summary> /// <param name="dir">The directory to list.</param> /// <param name="filter"> /// If non-null, the filter to use when listing /// this directory. /// </param> /// <returns>The list of files in the directory.</returns> /// <exception cref="System.IO.IOException">On I/O error</exception> public static IList <string> ListDirectory(FilePath dir, FilenameFilter filter) { AList <string> list = new AList <string>(); try { using (DirectoryStream <Path> stream = Files.NewDirectoryStream(dir.ToPath())) { foreach (Path entry in stream) { string fileName = entry.GetFileName().ToString(); if ((filter == null) || filter.Accept(dir, fileName)) { list.AddItem(fileName); } } } } catch (DirectoryIteratorException e) { throw ((IOException)e.InnerException); } return(list); }
private IList <FilePath> FindAllFiles(FilePath top, FilenameFilter mask) { if (top == null) { return(null); } AList <FilePath> ret = new AList <FilePath>(); foreach (FilePath f in top.ListFiles()) { if (f.IsDirectory()) { Sharpen.Collections.AddAll(ret, FindAllFiles(f, mask)); } else { if (mask.Accept(f, f.GetName())) { ret.AddItem(f); } } } return(ret); }
/// <summary> /// Returns an array of strings naming the files and directories in the /// directory denoted by this abstract pathname that satisfy the specified /// filter. /// </summary> public string[] list(FilenameFilter @filter) { return default(string[]); }
public string[] List (FilenameFilter filter) { try { if (IsFile ()) return null; List<string> list = new List<string> (); foreach (string filePth in Directory.GetFileSystemEntries (path)) { string fileName = Path.GetFileName (filePth); if ((filter == null) || filter.Accept (this, fileName)) { list.Add (fileName); } } return list.ToArray (); } catch { return null; } }
public StoreFiles(FileSystemAbstraction fs, PageCache pageCache, FilenameFilter fileFilter) { this._fs = fs; this._pageCache = pageCache; this._fileFilter = fileFilter; }
/// <summary> /// Returns an array of abstract pathnames denoting the files and /// directories in the directory denoted by this abstract pathname that /// satisfy the specified filter. /// </summary> public File[] listFiles(FilenameFilter @filter) { return default(File[]); }
public virtual string GetScriptStackTrace(FilenameFilter filter) { return GetScriptStackTrace(); }
/// <summary> /// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの抽象パス名の配列を返します。 /// </summary> public File[] listFiles( FilenameFilter filter ) { List<File> ret = new List<File>(); foreach ( string s in list() ) { if ( filter.accept( this, s ) ) { File f = new File( m_path + separator + s ); ret.Add( f ); } } return ret.ToArray(); }
/// <summary> /// Search the asset database for all files matching the specified filter. /// </summary> /// <returns>Array of matching files.</returns> /// <param name="assetsFilter">Filter used to query the /// AssetDatabase. If this isn't specified, all assets are searched. /// </param> /// <param name="filter">Optional delegate to filter the returned /// list.</param> public static string[] SearchAssetDatabase(string assetsFilter = null, FilenameFilter filter = null) { HashSet<string> matchingEntries = new HashSet<string>(); assetsFilter = assetsFilter != null ? assetsFilter : "t:Object"; foreach (string assetGuid in AssetDatabase.FindAssets(assetsFilter)) { string filename = AssetDatabase.GUIDToAssetPath(assetGuid); if (filter == null || filter(filename)) { matchingEntries.Add(filename); } } string[] entries = new string[matchingEntries.Count]; matchingEntries.CopyTo(entries); return entries; }
public virtual File[] listFiles(FilenameFilter prm1) { return(default(File[])); }
public virtual global::java.lang.String[] list(FilenameFilter prm1) { return(default(global::java.lang.String[])); }
public override File[] ListFiles(File directory, FilenameFilter filter) { return(ChooseFileSystem(directory).listFiles(directory, filter)); }
private static string[] ListFiles(string directory, FilenameFilter filter) { List<string> list = new List<string>(); ListFiles(list, directory, filter); return list.ToArray(); }
public override File[] ListFiles(File directory, FilenameFilter filter) { return(Fs.listFiles(directory, filter)); }
/// <summary> /// Returns an array of strings naming the files and directories in the /// directory denoted by this abstract pathname that satisfy the specified /// filter. /// </summary> public string[] list(FilenameFilter @filter) { return(default(string[])); }
/// <summary> /// この抽象パス名が示すディレクトリにあるファイルおよびディレクトリの中で、指定されたフィルタの基準を満たすものの文字列の配列を返します。 /// </summary> public string[] list( FilenameFilter filter ) { List<string> ret = new List<string>(); foreach ( string s in list() ) { if ( filter.accept( this, s ) ) { ret.Add( s ); } } return ret.ToArray(); }
/// <summary> /// Returns an array of abstract pathnames denoting the files and /// directories in the directory denoted by this abstract pathname that /// satisfy the specified filter. /// </summary> public File[] listFiles(FilenameFilter @filter) { return(default(File[])); }