Fixed entry_ref_to_path() and optimized dir_to_path(). The basic
Storage Kit unit test are passed again. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8563 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -997,16 +997,31 @@ BPrivate::Storage::entry_ref_to_path( const struct entry_ref *ref, char *result,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BPrivate::Storage::entry_ref_to_path(dev_t device, ino_t directory, const char *name,
|
BPrivate::Storage::entry_ref_to_path(dev_t device, ino_t directory,
|
||||||
char *path, size_t size)
|
const char *name, char *path, size_t size)
|
||||||
{
|
{
|
||||||
status_t status = _kern_dir_node_ref_to_path(device, directory, path, size);
|
status_t error;
|
||||||
if (status < B_OK)
|
if (strcmp(name, ".") == 0) {
|
||||||
return status;
|
error = _kern_dir_node_ref_to_path(device, directory, path, size);
|
||||||
|
} else if (strcmp(name, "..") == 0) {
|
||||||
strlcat(path, "/", size);
|
char tmpPath[B_PATH_NAME_LENGTH];
|
||||||
strlcat(path, name, size);
|
error = _kern_dir_node_ref_to_path(device, directory, tmpPath,
|
||||||
return B_OK;
|
B_PATH_NAME_LENGTH);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
strlcat(tmpPath, "/", B_PATH_NAME_LENGTH);
|
||||||
|
strlcat(tmpPath, name, B_PATH_NAME_LENGTH);
|
||||||
|
error = get_canonical_path(tmpPath, path, size);
|
||||||
|
} else {
|
||||||
|
error = _kern_dir_node_ref_to_path(device, directory, path, size);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
int32 len = strlen(path);
|
||||||
|
if (path[len - 1] != '/')
|
||||||
|
strlcat(path, "/", B_PATH_NAME_LENGTH);
|
||||||
|
strlcat(path, name, B_PATH_NAME_LENGTH);
|
||||||
|
}
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1023,15 +1038,13 @@ BPrivate::Storage::dir_to_path( FileDescriptor dir, char *result, size_t size )
|
|||||||
{
|
{
|
||||||
if (dir < 0 || result == NULL)
|
if (dir < 0 || result == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
// get stat
|
||||||
entry_ref entry;
|
Stat st;
|
||||||
status_t status;
|
status_t error = get_stat(dir, &st);
|
||||||
|
if (error != B_OK)
|
||||||
status = dir_to_self_entry_ref(dir, &entry);
|
return error;
|
||||||
if (status != B_OK)
|
// get path for the node ref
|
||||||
return status;
|
return _kern_dir_node_ref_to_path(st.st_dev, st.st_ino, result, size);
|
||||||
|
|
||||||
return entry_ref_to_path(&entry, result, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \param path the path name.
|
/*! \param path the path name.
|
||||||
@@ -1104,7 +1117,7 @@ BPrivate::Storage::get_canonical_path(const char *path, char *&result)
|
|||||||
\param result a pointer to a buffer the resulting path name shall be
|
\param result a pointer to a buffer the resulting path name shall be
|
||||||
written into.
|
written into.
|
||||||
\param size the size of the buffer
|
\param size the size of the buffer
|
||||||
\return \c B_OK if everything went fine, an error code otherwise
|
\return \c B_OK if everything went fine, an error code otherwise
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BPrivate::Storage::get_canonical_dir_path(const char *path, char *result, size_t size)
|
BPrivate::Storage::get_canonical_dir_path(const char *path, char *result, size_t size)
|
||||||
|
|||||||
Reference in New Issue
Block a user