Allow empty relpath in stream_load
This commit is contained in:
parent
8727126551
commit
1ac276a220
@ -91,3 +91,12 @@ path_keep(char *path, int n)
|
||||
err("missing %d components", n);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
path_remove_trailing(char *path)
|
||||
{
|
||||
int n = strlen(path);
|
||||
for (int i = n - 1; path[i] == '/'; i--) {
|
||||
path[i] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ int path_count(const char *path, char c);
|
||||
int path_next(const char *path, char sep, const char (**next));
|
||||
int path_keep(char *path, int n);
|
||||
int path_strip(const char *path, int n, const char (**next));
|
||||
void path_remove_trailing(char *path);
|
||||
|
||||
#endif /* PATH_H */
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "stream.h"
|
||||
|
||||
#include "ovni.h"
|
||||
#include "path.h"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
@ -79,6 +80,9 @@ stream_load(struct stream *stream, const char *tracedir, const char *relpath)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Allow loading a trace with empty relpath */
|
||||
path_remove_trailing(stream->path);
|
||||
|
||||
if (snprintf(stream->relpath, PATH_MAX, "%s", relpath) >= PATH_MAX) {
|
||||
err("stream_load: path too long: %s\n", relpath);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user