Finalise pull from ikasty to show relative filenames in --watchfd

This commit is contained in:
Andrew Wood
2023-07-16 00:28:58 +01:00
parent e228b3397d
commit 8fb3aecde5
3 changed files with 10 additions and 3 deletions
+1
View File
@@ -1,4 +1,5 @@
UNRELEASED
* The "`--watchfd`" option will now show relative filenames, if they are under the current directory (patch supplied by [ikasty](https://github.com/ikasty))
* support for Red Hat Enterprise Linux and its derivatives has been dropped; removed the RPM spec file, and will no longer build binaries
* docs: moved all open issues into GitHub and updated the TODO list
* docs: renamed README to README.md and altered it to Markdown format
+6 -3
View File
@@ -37,13 +37,16 @@ pvstate_t pv_state_alloc(const char *program_name)
#endif /* HAVE_SPLICE */
state->display_visible = false;
//get cwd from system and set to state
/*
* Get the current working directory, if possible, as a base for
* showing relative filenames with --watchfd.
*/
if (NULL == getcwd(state->cwd, sizeof(state->cwd))) {
// ignore error, using full path
/* failed - will always show full path */
state->cwd[0] = '\0';
}
if ('\0' == state->cwd[1]) {
// ignore when current working directory is root directory
/* CWD is root directory - always show full path */
state->cwd[0] = '\0';
}
+3
View File
@@ -363,6 +363,9 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
/*
* Set the display name for the given watched file descriptor, truncating at
* the relevant places according to the current screen width.
*
* If the file descriptor is pointing to a file under the current working
* directory, show its relative path, not the full path.
*/
void pv_watchpid_setname(pvstate_t state, pvwatchfd_t info)
{