* Added Adopt() method that steals the other path's buffer.

* Fixed operator=(): the second argument of SetTo() is a boolean (normalize),
  not the length of the buffer.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25382 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-05-08 16:45:29 +00:00
parent b1429e2a05
commit 56bbbbc9ca
2 changed files with 14 additions and 1 deletions

View File

@ -22,6 +22,7 @@ class KPath {
status_t SetTo(const char *path, bool normalize = false,
size_t bufferSize = B_PATH_NAME_LENGTH);
void Adopt(KPath& other);
status_t InitCheck() const;

View File

@ -86,6 +86,18 @@ KPath::SetTo(const char* path, bool normalize, size_t bufferSize)
}
void
KPath::Adopt(KPath& other)
{
free(fBuffer);
fBuffer = other.fBuffer;
fBufferSize = other.fBufferSize;
other.fBuffer = NULL;
}
status_t
KPath::InitCheck() const
{
@ -257,7 +269,7 @@ KPath::Append(const char *component, bool isComponent)
KPath&
KPath::operator=(const KPath& other)
{
SetTo(other.fBuffer, other.fBufferSize);
SetTo(other.fBuffer, false, other.fBufferSize);
return *this;
}