path-util: rework file_in_same_dir() on top of path_extract_directory()
Let's port one more over. Note that this changes behaviour of file_in_same_dir() in some regards. Specifically, a trailing slash of the input path will be treated differently: previously we'd operate below that dir then, instead of the parent. I think that makes little sense however, and I think the code using this function doesn't expect that either. Moroever, addresses some corner cases if the path is specified as "/" or ".", i.e. where e cannot extract a parent. These will now be treated as error, which I think is much cleaner.
This commit is contained in:
@@ -170,7 +170,7 @@ static inline bool path_is_safe(const char *p) {
|
||||
}
|
||||
bool path_is_normalized(const char *p) _pure_;
|
||||
|
||||
char *file_in_same_dir(const char *path, const char *filename);
|
||||
int file_in_same_dir(const char *path, const char *filename, char **ret);
|
||||
|
||||
bool hidden_or_backup_file(const char *filename) _pure_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user