find_paths_etc(): added user/system only flags.
* B_FIND_PATHS_(USER|SYSTEM)_ONLY cause only the specified paths to be included in the result list.
This commit is contained in:
parent
2bdffa6131
commit
b7a87fd137
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2002-2015, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _FIND_DIRECTORY_H
|
||||
@ -126,6 +126,9 @@ enum {
|
||||
B_FIND_PATH_CREATE_DIRECTORY = 0x0001,
|
||||
B_FIND_PATH_CREATE_PARENT_DIRECTORY = 0x0002,
|
||||
B_FIND_PATH_EXISTING_ONLY = 0x0004,
|
||||
|
||||
B_FIND_PATHS_SYSTEM_ONLY = 0x0010,
|
||||
B_FIND_PATHS_USER_ONLY = 0x0020,
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
|
||||
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -85,6 +86,16 @@ public:
|
||||
return fLocations[0] != NULL && fLocations[1] != NULL;
|
||||
}
|
||||
|
||||
bool IsUserIndex(size_t index) const
|
||||
{
|
||||
return index==0 || index==1;
|
||||
}
|
||||
|
||||
bool IsSystemIndex(size_t index) const
|
||||
{
|
||||
return index==2 || index==3;
|
||||
}
|
||||
|
||||
static InstallationLocations* Default()
|
||||
{
|
||||
static char sBuffer[sizeof(InstallationLocations)];
|
||||
@ -674,6 +685,12 @@ __find_paths_etc(const char* architecture, path_base_directory baseDirectory,
|
||||
size_t totalSize = 0;
|
||||
|
||||
for (size_t i = 0; i < InstallationLocations::kCount; i++) {
|
||||
if (((flags & B_FIND_PATHS_USER_ONLY) != 0
|
||||
&& !installationLocations->IsUserIndex(i))
|
||||
|| ((flags & B_FIND_PATHS_SYSTEM_ONLY) != 0
|
||||
&& !installationLocations->IsSystemIndex(i)))
|
||||
continue;
|
||||
|
||||
relativePaths[i] = get_relative_directory_path(i, baseDirectory);
|
||||
if (relativePaths[i] == NULL)
|
||||
return B_BAD_VALUE;
|
||||
@ -696,6 +713,12 @@ __find_paths_etc(const char* architecture, path_base_directory baseDirectory,
|
||||
char* pathBuffer = (char*)(paths + InstallationLocations::kCount);
|
||||
const char* pathBufferEnd = pathBuffer + totalSize;
|
||||
for (size_t i = 0; i < InstallationLocations::kCount; i++) {
|
||||
if (((flags & B_FIND_PATHS_USER_ONLY) != 0
|
||||
&& !installationLocations->IsUserIndex(i))
|
||||
|| ((flags & B_FIND_PATHS_SYSTEM_ONLY) != 0
|
||||
&& !installationLocations->IsSystemIndex(i)))
|
||||
continue;
|
||||
|
||||
ssize_t pathSize = process_path(installationLocations->At(i),
|
||||
architecture, relativePaths[i], subPath, flags, pathBuffer,
|
||||
pathBufferEnd - pathBuffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user