aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libpts/pts/pts_database.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/libpts/pts/pts_database.c b/src/libpts/pts/pts_database.c
index e9a0e5faa..f2e2c9c74 100644
--- a/src/libpts/pts/pts_database.c
+++ b/src/libpts/pts/pts_database.c
@@ -48,7 +48,7 @@ METHOD(pts_database_t, get_pathname, char*,
private_pts_database_t *this, bool is_dir, int id)
{
enumerator_t *e;
- char *path, *name, *pathname;
+ char *path, *name, *sep, *pathname = NULL;
if (is_dir)
{
@@ -70,11 +70,21 @@ METHOD(pts_database_t, get_pathname, char*,
"SELECT d.path, f.name FROM files AS f "
"JOIN directories AS d ON d.id = f.dir WHERE f.id = ?",
DB_INT, id, DB_TEXT, DB_TEXT);
- if (!e || !e->enumerate(e, &path, &name) ||
- asprintf(&pathname, "%s%s%s",
- path, streq(path, "/") ? "" : "/", name) == -1)
+ if (e && e->enumerate(e, &path, &name))
{
- pathname = NULL;
+ if (path[0] == '/')
+ { /* Unix style absolute path */
+ sep = "/";
+ }
+ else
+ { /* Windows absolute path */
+ sep = "\\";
+ }
+ if (asprintf(&pathname, "%s%s%s",
+ path, streq(path, "/") ? "" : sep, name) == -1)
+ {
+ pathname = NULL;
+ }
}
}
DESTROY_IF(e);
@@ -420,4 +430,3 @@ pts_database_t *pts_database_create(imv_database_t *imv_db)
return &this->public;
}
-