* Reduced the stack usage of most of the I/O paths - there were several places

that put one or more full paths on the stack before, which could cause some
  problems under certain conditions.
* Cleaned up KPath, ie. use size_t instead of int32 where appropriate, added
  license.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16585 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2006-03-05 18:11:59 +00:00
parent 5d13c758d1
commit 0d4c16e0c0
3 changed files with 334 additions and 273 deletions
+36 -34
View File
@@ -1,56 +1,58 @@
// KPath.h
//
// A simple class wrapping a path. Has a fixed-sized buffer.
/*
* Copyright 2004-2006, Ingo Weinhold, [email protected].
* 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(int32 bufferSize = B_PATH_NAME_LENGTH);
KPath(const char* path, bool normalize = false,
int32 bufferSize = B_PATH_NAME_LENGTH);
KPath(const KPath& other);
~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,
int32 bufferSize = B_PATH_NAME_LENGTH);
status_t SetTo(const char *path, bool normalize = false,
size_t bufferSize = B_PATH_NAME_LENGTH);
status_t InitCheck() const;
status_t InitCheck() const;
status_t SetPath(const char *path, bool normalize = false);
const char *Path() const;
int32 Length() const;
status_t SetPath(const char *path, bool normalize = false);
const char *Path() const;
size_t Length() const { return fPathLength; }
int32 BufferSize() const;
char *LockBuffer();
void UnlockBuffer();
size_t BufferSize() const { return fBufferSize; }
char *LockBuffer();
void UnlockBuffer();
const char *Leaf() const;
status_t ReplaceLeaf(const char *newLeaf);
const char *Leaf() const;
status_t ReplaceLeaf(const char *newLeaf);
status_t Append(const char *toAppend, bool isComponent = true);
status_t Append(const char *toAppend, bool isComponent = true);
KPath& operator=(const KPath& other);
KPath& operator=(const char* path);
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;
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();
private:
void _ChopTrailingSlashes();
char* fBuffer;
int32 fBufferSize;
int32 fPathLength;
bool fLocked;
char* fBuffer;
size_t fBufferSize;
size_t fPathLength;
bool fLocked;
};
} // namespace DiskDevice