1/*
2 * Copyright 2004-2007, Ingo Weinhold, bonefish@users.sf.net.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _K_PATH_H
6#define _K_PATH_H
7
8
9#include "fssh_defs.h"
10#include "fssh_kernel_export.h"
11
12
13namespace FSShell {
14
15class KPath {
16	public:
17		KPath(fssh_size_t bufferSize = FSSH_B_PATH_NAME_LENGTH);
18		KPath(const char* path, bool normalize = false,
19			fssh_size_t bufferSize = FSSH_B_PATH_NAME_LENGTH);
20		KPath(const KPath& other);
21		~KPath();
22
23		fssh_status_t SetTo(const char *path, bool normalize = false,
24			fssh_size_t bufferSize = FSSH_B_PATH_NAME_LENGTH);
25
26		fssh_status_t InitCheck() const;
27
28		fssh_status_t SetPath(const char *path, bool normalize = false);
29		const char *Path() const;
30		fssh_size_t Length() const { return fPathLength; }
31
32		fssh_size_t BufferSize() const { return fBufferSize; }
33		char *LockBuffer();
34		void UnlockBuffer();
35
36		const char *Leaf() const;
37		fssh_status_t ReplaceLeaf(const char *newLeaf);
38
39		fssh_status_t Append(const char *toAppend, bool isComponent = true);
40
41		KPath& operator=(const KPath& other);
42		KPath& operator=(const char* path);
43
44		bool operator==(const KPath& other) const;
45		bool operator==(const char* path) const;
46		bool operator!=(const KPath& other) const;
47		bool operator!=(const char* path) const;
48
49	private:
50		void _ChopTrailingSlashes();
51
52		char*		fBuffer;
53		fssh_size_t	fBufferSize;
54		fssh_size_t	fPathLength;
55		bool		fLocked;
56};
57
58} // namespace FSShell
59
60using FSShell::KPath;
61
62#endif	/* _K_PATH_H */
63