1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-01 03:16:44 +02:00

send name instead of full path with file send request

This commit is contained in:
Jfreegman
2014-02-11 18:52:04 -05:00
parent 1f06606c5b
commit 16b8f85d95
5 changed files with 30 additions and 21 deletions

View File

@ -193,3 +193,26 @@ void mv_curs_end(WINDOW *w, size_t len, int max_y, int max_x)
int end_x = len % max_x;
wmove(w, end_y, end_x);
}
/* Returns base file name from path or original file name if no path is supplied */
uint8_t *get_file_name(uint8_t *pathname)
{
int idx = strlen(pathname) - 1;
while (idx >= 0 && pathname[idx] == '/')
pathname[idx--] = '\0';
uint8_t *filename = strrchr(pathname, '/'); // Try unix style paths
if (filename != NULL) {
if (!strlen(++filename))
filename = pathname;
} else {
filename = strrchr(pathname, '\\'); // Try windows style paths
if (filename == NULL)
filename = pathname;
}
return filename;
}