mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
b2cb66890b
Summary: This diff implements DirList for Windows and use it for readdir implemetation. On Windows readdir will return all the entries in one single call. Reviewed By: simpkins Differential Revision: D20480871 fbshipit-source-id: 15abb337c55c5016debeb0680a1a3a7063b341c3
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
#include <folly/Range.h>
|
|
#include <sys/stat.h>
|
|
#include <memory>
|
|
#include "eden/fs/utils/DirType.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
/**
|
|
* Helper class for populating directory listings.
|
|
*/
|
|
class DirList {
|
|
public:
|
|
struct ExtractedEntry {
|
|
std::string name;
|
|
uint64_t inode;
|
|
dtype_t type;
|
|
|
|
ExtractedEntry(folly::StringPiece name, uint64_t inode, dtype_t type)
|
|
: name{name}, inode{inode}, type{type} {}
|
|
};
|
|
|
|
DirList() = default;
|
|
|
|
DirList(const DirList&) = delete;
|
|
DirList& operator=(const DirList&) = delete;
|
|
DirList(DirList&&) = default;
|
|
DirList& operator=(DirList&&) = default;
|
|
|
|
/**
|
|
* Add a new directory entry to the list.
|
|
*/
|
|
void add(folly::StringPiece name, uint64_t inode, dtype_t type);
|
|
|
|
const std::vector<ExtractedEntry>& extract() const {
|
|
return list_;
|
|
}
|
|
|
|
private:
|
|
std::vector<ExtractedEntry> list_;
|
|
};
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|