tweaks: rename two functions and a variable, and improve two comments
parent
808d0894f1
commit
cb1675dac7
|
@ -39,9 +39,9 @@ static size_t longest = 0;
|
||||||
static size_t selected = 0;
|
static size_t selected = 0;
|
||||||
/* The currently selected filename in the list; zero-based. */
|
/* The currently selected filename in the list; zero-based. */
|
||||||
|
|
||||||
/* Our main file browser function. path is the tilde-expanded path we
|
/* Allow the user to browse through the directories in the filesystem,
|
||||||
* start browsing from. */
|
* starting at the given path. */
|
||||||
char *do_browser(char *path)
|
char *browse(char *path)
|
||||||
{
|
{
|
||||||
char *present_name = NULL;
|
char *present_name = NULL;
|
||||||
/* The name of the currently selected file, or of the directory we
|
/* The name of the currently selected file, or of the directory we
|
||||||
|
@ -346,20 +346,19 @@ char *do_browser(char *path)
|
||||||
return chosen;
|
return chosen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The file browser front end. We check to see if inpath has a
|
/* Prepare to start browsing. If the given path has a directory part,
|
||||||
* directory in it. If it does, we start do_browser() from there.
|
* start browsing in that directory, otherwise in the current directory. */
|
||||||
* Otherwise, we start do_browser() from the current directory. */
|
char *browse_in(const char *inpath)
|
||||||
char *do_browse_from(const char *inpath)
|
|
||||||
{
|
{
|
||||||
char *path = real_dir_from_tilde(inpath);
|
char *path = real_dir_from_tilde(inpath);
|
||||||
struct stat st;
|
struct stat fileinfo;
|
||||||
|
|
||||||
/* If path is not a directory, try to strip a filename from it; if then
|
/* If path is not a directory, try to strip a filename from it; if then
|
||||||
* still not a directory, use the current working directory instead. */
|
* still not a directory, use the current working directory instead. */
|
||||||
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
|
||||||
path = free_and_assign(path, strip_last_component(path));
|
path = free_and_assign(path, strip_last_component(path));
|
||||||
|
|
||||||
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
|
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
|
||||||
char *currentdir = charalloc(PATH_MAX + 1);
|
char *currentdir = charalloc(PATH_MAX + 1);
|
||||||
|
|
||||||
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
|
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
|
||||||
|
@ -381,7 +380,7 @@ char *do_browse_from(const char *inpath)
|
||||||
path = mallocstrcpy(path, operating_dir);
|
path = mallocstrcpy(path, operating_dir);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return do_browser(path);
|
return browse(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set filelist to the list of files contained in the directory path,
|
/* Set filelist to the list of files contained in the directory path,
|
||||||
|
|
|
@ -1192,7 +1192,7 @@ void do_insertfile(bool execute)
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
if (func == to_files) {
|
if (func == to_files) {
|
||||||
char *chosen = do_browse_from(answer);
|
char *chosen = browse_in(answer);
|
||||||
|
|
||||||
/* If no file was chosen, go back to the prompt. */
|
/* If no file was chosen, go back to the prompt. */
|
||||||
if (chosen == NULL)
|
if (chosen == NULL)
|
||||||
|
@ -2105,7 +2105,7 @@ int do_writeout(bool exiting, bool withprompt)
|
||||||
|
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
if (func == to_files) {
|
if (func == to_files) {
|
||||||
char *chosen = do_browse_from(answer);
|
char *chosen = browse_in(answer);
|
||||||
|
|
||||||
if (chosen == NULL)
|
if (chosen == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -188,7 +188,7 @@ typedef void (*functionptrtype)(void);
|
||||||
|
|
||||||
/* Most functions in browser.c. */
|
/* Most functions in browser.c. */
|
||||||
#ifdef ENABLE_BROWSER
|
#ifdef ENABLE_BROWSER
|
||||||
char *do_browse_from(const char *inpath);
|
char *browse_in(const char *inpath);
|
||||||
void read_the_list(const char *path, DIR *dir);
|
void read_the_list(const char *path, DIR *dir);
|
||||||
void browser_refresh(void);
|
void browser_refresh(void);
|
||||||
void browser_select_dirname(const char *needle);
|
void browser_select_dirname(const char *needle);
|
||||||
|
|
Loading…
Reference in New Issue