haiku/headers/private/kernel/fs/KPath.h
Axel Dörfler 56bbbbc9ca * 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
2008-05-08 16:45:29 +00:00

67 lines
1.5 KiB
C++

/*
* Copyright 2004-2006, Ingo Weinhold, bonefish@users.sf.net.
* Distributed under the terms of the MIT License.
*/
#ifndef _K_PATH_H
#define _K_PATH_H
#include <KernelExport.h>
namespace BPrivate {
namespace DiskDevice {
class KPath {
public:
KPath(size_t bufferSize = B_PATH_NAME_LENGTH);
KPath(const char* path, bool normalize = false,
size_t bufferSize = B_PATH_NAME_LENGTH);
KPath(const KPath& other);
~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;
status_t SetPath(const char *path, bool normalize = false);
const char *Path() const;
size_t Length() const { return fPathLength; }
size_t BufferSize() const { return fBufferSize; }
char *LockBuffer();
void UnlockBuffer();
const char *Leaf() const;
status_t ReplaceLeaf(const char *newLeaf);
bool RemoveLeaf();
// returns false, if nothing could be removed anymore
status_t Append(const char *toAppend, bool isComponent = true);
KPath& operator=(const KPath& other);
KPath& operator=(const char* path);
bool operator==(const KPath& other) const;
bool operator==(const char* path) const;
bool operator!=(const KPath& other) const;
bool operator!=(const char* path) const;
private:
void _ChopTrailingSlashes();
char* fBuffer;
size_t fBufferSize;
size_t fPathLength;
bool fLocked;
};
} // namespace DiskDevice
} // namespace BPrivate
using BPrivate::DiskDevice::KPath;
#endif /* _K_PATH_H */