btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / storage / MergedDirectory.h
blobcf020bae60fa7636ab4770ef3c8cbaa56f36bf48
1 /*
2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
7 */
8 #ifndef _MERGED_DIRECTORY_H
9 #define _MERGED_DIRECTORY_H
12 #include <EntryList.h>
13 #include <ObjectList.h>
16 class BDirectory;
19 class BMergedDirectory : public BEntryList {
20 public:
21 // policy how to handle equally named entries in different
22 // directories
23 enum BPolicy {
24 B_ALLOW_DUPLICATES,
25 B_ALWAYS_FIRST,
26 B_COMPARE
29 public:
30 BMergedDirectory(
31 BPolicy policy = B_ALWAYS_FIRST);
32 virtual ~BMergedDirectory();
34 status_t Init();
36 BPolicy Policy() const;
37 void SetPolicy(BPolicy policy);
39 status_t AddDirectory(BDirectory* directory);
40 status_t AddDirectory(const char* path);
42 virtual status_t GetNextEntry(BEntry* entry,
43 bool traverse = false);
44 virtual status_t GetNextRef(entry_ref* ref);
45 virtual int32 GetNextDirents(struct dirent* direntBuffer,
46 size_t bufferSize,
47 int32 maxEntries = INT_MAX);
48 virtual status_t Rewind();
49 virtual int32 CountEntries();
51 protected:
52 virtual bool ShallPreferFirstEntry(const entry_ref& entry1,
53 int32 index1, const entry_ref& entry2,
54 int32 index2);
55 // always invoked with index1 < index2
57 private:
58 typedef BObjectList<BDirectory> DirectoryList;
59 struct EntryNameSet;
61 private:
62 void _FindBestEntry(dirent* direntBuffer);
64 private:
65 DirectoryList fDirectories;
66 BPolicy fPolicy;
67 int32 fDirectoryIndex;
68 EntryNameSet* fVisitedEntries;
72 #endif // _MERGED_DIRECTORY_H