* vfs_normalize_path() and _user_normalize_path() use a common helper

function (normalize_path()), now. There was some code duplication
  before.
* Added "bool traverseLink" parameter to vfs_normalize_path(). When
  true and the leaf component is a symlink, it will be resolved.
* KPath:
  - Added similar leaf link traversal parameter to SetTo() and
    SetPath().
  - Added Normalize().
  - Added DetachBuffer(), which returns the object's current buffer and
    unsets itself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27751 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-09-26 23:30:28 +00:00
parent 0914d6da5a
commit e8d3eff968
4 changed files with 147 additions and 144 deletions
+8 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2006, Ingo Weinhold, [email protected].
* Copyright 2004-2008, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _K_PATH_H
@@ -21,18 +21,21 @@ class KPath {
~KPath();
status_t SetTo(const char *path, bool normalize = false,
size_t bufferSize = B_PATH_NAME_LENGTH);
size_t bufferSize = B_PATH_NAME_LENGTH,
bool traverseLeafLink = false);
void Adopt(KPath& other);
status_t InitCheck() const;
status_t SetPath(const char *path, bool normalize = false);
status_t SetPath(const char *path, bool normalize = false,
bool traverseLeafLink = false);
const char *Path() const;
size_t Length() const { return fPathLength; }
size_t BufferSize() const { return fBufferSize; }
char *LockBuffer();
void UnlockBuffer();
char* DetachBuffer();
const char *Leaf() const;
status_t ReplaceLeaf(const char *newLeaf);
@@ -41,6 +44,8 @@ class KPath {
status_t Append(const char *toAppend, bool isComponent = true);
status_t Normalize(bool traverseLeafLink);
KPath& operator=(const KPath& other);
KPath& operator=(const char* path);
+1 -1
View File
@@ -128,7 +128,7 @@ status_t vfs_get_module_path(const char *basePath, const char *moduleName,
/* service call for whoever needs a normalized path */
status_t vfs_normalize_path(const char *path, char *buffer, size_t bufferSize,
bool kernel);
bool traverseLink, bool kernel);
/* service call for whoever wants to create a special node */
status_t vfs_create_special_node(const char *path, fs_vnode *subVnode,