Use BPath to normalise paths so [un]trash foo/ actually works

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10490 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2004-12-19 00:35:16 +00:00
parent 8c0d307dcb
commit 03136b8b3c

View File

@ -35,6 +35,7 @@ status_t untrash(const char *f)
{
status_t err;
char original_path[B_PATH_NAME_LENGTH];
BPath path(f);
BNode node(f);
err = node.InitCheck();
if (err)
@ -42,7 +43,7 @@ status_t untrash(const char *f)
err = node.ReadAttr(kAttrOriginalPath, B_STRING_TYPE, 0LL, original_path, B_PATH_NAME_LENGTH);
if (err < 0)
return err;
err = rename(f, original_path);
err = rename(path.Path(), original_path);
if (err < 0)
return err;
node.RemoveAttr(kAttrOriginalPath);
@ -92,7 +93,7 @@ status_t trash(const char *f)
if (!trashDir.Contains(trashed_file))
break;
}
err = rename(f, trashed_file);
err = rename(original_path, trashed_file);
if (err < 0)
return err;