2006-03-05 21:11:59 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2006, Ingo Weinhold, bonefish@users.sf.net.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2004-10-28 01:41:16 +04:00
|
|
|
#ifndef _K_PATH_H
|
|
|
|
#define _K_PATH_H
|
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
|
2004-10-28 01:41:16 +04:00
|
|
|
#include <KernelExport.h>
|
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
|
2004-10-28 01:41:16 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
namespace DiskDevice {
|
|
|
|
|
|
|
|
class KPath {
|
2006-03-05 21:11:59 +03:00
|
|
|
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();
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
status_t SetTo(const char *path, bool normalize = false,
|
|
|
|
size_t bufferSize = B_PATH_NAME_LENGTH);
|
2008-05-08 20:45:29 +04:00
|
|
|
void Adopt(KPath& other);
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
status_t InitCheck() const;
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
status_t SetPath(const char *path, bool normalize = false);
|
|
|
|
const char *Path() const;
|
|
|
|
size_t Length() const { return fPathLength; }
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
size_t BufferSize() const { return fBufferSize; }
|
|
|
|
char *LockBuffer();
|
|
|
|
void UnlockBuffer();
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
const char *Leaf() const;
|
|
|
|
status_t ReplaceLeaf(const char *newLeaf);
|
2007-07-15 04:34:17 +04:00
|
|
|
bool RemoveLeaf();
|
|
|
|
// returns false, if nothing could be removed anymore
|
2004-10-28 19:09:48 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
status_t Append(const char *toAppend, bool isComponent = true);
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
KPath& operator=(const KPath& other);
|
|
|
|
KPath& operator=(const char* path);
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
bool operator==(const KPath& other) const;
|
|
|
|
bool operator==(const char* path) const;
|
|
|
|
bool operator!=(const KPath& other) const;
|
|
|
|
bool operator!=(const char* path) const;
|
2004-10-28 01:41:16 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
private:
|
|
|
|
void _ChopTrailingSlashes();
|
2004-10-28 19:09:48 +04:00
|
|
|
|
2006-03-05 21:11:59 +03:00
|
|
|
char* fBuffer;
|
|
|
|
size_t fBufferSize;
|
|
|
|
size_t fPathLength;
|
|
|
|
bool fLocked;
|
2004-10-28 01:41:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace DiskDevice
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
using BPrivate::DiskDevice::KPath;
|
|
|
|
|
2004-11-04 18:51:27 +03:00
|
|
|
#endif /* _K_PATH_H */
|