FileBrowser(3I)

πŸ’– FileBrowser(3I) β€” like, the whole vibe πŸ’–

okay bestie, grab your iced coffee because we're diving into FileBrowser from the InterViews Reference Manual and honestly? she's iconic. πŸ¦‹


✨ NAME ✨

FileBrowser β€” browse and/or select file names. that's it, that's the girl. πŸ’…


🌸 SYNOPSIS 🌸

#include <InterViews/filebrowser.h>

πŸŽ€ DESCRIPTION πŸŽ€

okay so FileBrowser is a StringBrowser that displays file names. like, a StringBrowser but make it files. πŸ“βœ¨

here's the tea: on top of the standard StringBrowser constructor parameters, the FileBrowser constructor also takes a directory name as an argument. then FileBrowser scans that directory and appends all the file names to its list of strings. slay.

FileBrowser lets the user choose a file name, and then the application can go ask the FileBrowser which file got chosen. main character energy fr fr. πŸ‘‘


πŸ‘‘ PUBLIC OPERATIONS πŸ‘‘

  • FileBrowser(ButtonState*, const char* dir, int rows, int cols, boolean uniqueSel, int highlight, const char* done)
  • FileBrowser(const char* name, ButtonState*, const char*, int, int, boolean, int, const char*)

β€” make a brand new FileBrowser object, no cap. the ButtonState, rows, cols, uniqueSel, highlight, done, and name parameters have semantics identical to those of the corresponding StringBrowser parameters. the dir parameter is the one that says which directory to search for file names. internally, FileBrowser prepends dir to relative path specifications in operations that require them, which is how she avoids a chdir(2). clever girlie. πŸ’…

  • boolean IsADirectory(const char*) β€” returns whether or not the given relative path corresponds to a valid directory. yes or no, bestie, that's all. 🫢
  • boolean SetDirectory(const char* newdir) β€” change the search directory to newdir if that directory is accessible. returns true if it worked. lowkey the glow-up function. ✨
  • const char* GetDirectory() β€” returns the name of the search directory. πŸ—‚οΈ
  • const char* ValidDirectories(const char* path) β€” give her a path string and she returns the largest substring (starting from the beginning of path) that represents a valid path. ⚠️ heads up: the substring comes back in a static buffer, so you gotta copy it before you use it. don't get caught lacking.
  • const char* Normalize(const char* path) β€” returns a normalized version of path with all the spurious slashes, dots, and tildes interpreted. so ~/./foo// type nonsense gets sorted out. ⚠️ same warning bestie: the normalized path is returned in a static buffer, so copy it before use. πŸ™ˆ
  • const char* Path(int i) β€” returns the ith string as it appears in the FileBrowser. what she does: prepends the search directory to the string, normalizes the concatenation, and returns the result. iconic behavior honestly. 🌈
  • void RereadDirectory() β€” rescan the current directory without updating the FileBrowser's appearance. she's looking but not telling anyone. πŸ‘€
  • virtual void Update() β€” rescan the current directory and update the FileBrowser's appearance so it reflects any changes in the set of files it should display. full refresh, periodt. πŸ”₯
  • void SetTextFilter(const char*)
  • void SetDirectoryTextFilter(const char*)
  • void SetModeFilter(int)
  • void SetDirectoryModeFilter(int)

β€” okay so by default, FileBrowser displays all the files and directories it finds in the search directory. these four functions give you some control over which entries she shows.

  • SetTextFilter specifies a regular expression (see Regexp(3I)) to match against file names.
  • SetDirectoryTextFilter does the same job but for directory names.
  • SetModeFilter and SetDirectoryModeFilter specify the mode (see chmod(1)) that displayed files and directories should have.

only files and directories that match both the regular expression and the mode will show up in the FileBrowser. passing nil for the regular expression or 0 for the mode restores the default behavior. 🧚


πŸ¦‹ PROTECTED OPERATIONS πŸ¦‹

  • void UpdateStrings() β€” explicitly update the FileBrowser's appearance to reflect any changes in the set of files it should display, without rescanning the directory. like refreshing the vibe without redoing the whole photo shoot. πŸ“Έ
  • virtual boolean Acceptable(const char*) β€” returns whether the given file name is an acceptable name. by default, files that conform to the text or mode filter specifications are acceptable. and only acceptable files will be displayed by UpdateStrings. she's picky and honestly? respect. πŸ’…

πŸ’œ SEE ALSO πŸ’œ

Interactor(2I), Button(3I), StringBrowser(3I), Regexp(3I), chmod(1)


and that's the whole page bestie!! this one came from the InterViews crew, dated 30 November 1989 β€” yeah she's vintage and she still ate. go forth and browse those files. πŸŽ€βœ¨πŸ«Ά