mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2025-12-11 22:02:32 +01:00
Squashed 'gitstatus/' changes from 845f492f..2ecd9907
2ecd9907 add logging to debug https://github.com/romkatv/powerlevel10k/issues/1477 74010456 add a TODO to fix #254 864f1caf Trim '\w' part of bash prompt. (#253) git-subtree-dir: gitstatus git-subtree-split: 2ecd990706255d2000fedbde3b2d2353f63d69a1
This commit is contained in:
parent
799c22f63b
commit
80ec734a95
6 changed files with 23 additions and 12 deletions
14
src/dir.cc
14
src/dir.cc
|
|
@ -106,14 +106,14 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
|
|||
};
|
||||
|
||||
constexpr size_t kBufSize = 8 << 10;
|
||||
entries.clear();
|
||||
const size_t orig_size = entries.size();
|
||||
|
||||
while (true) {
|
||||
char* buf = static_cast<char*>(arena.Allocate(kBufSize, alignof(linux_dirent64)));
|
||||
// Save 256 bytes for the rainy day.
|
||||
int n = syscall(SYS_getdents64, dir_fd, buf, kBufSize - 256);
|
||||
if (n < 0) {
|
||||
entries.clear();
|
||||
entries.resize(orig_size);
|
||||
return false;
|
||||
}
|
||||
for (int pos = 0; pos < n;) {
|
||||
|
|
@ -131,9 +131,9 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
|
|||
}
|
||||
|
||||
if (case_sensitive) {
|
||||
SortEntries<true>(entries.data(), entries.data() + entries.size());
|
||||
SortEntries<true>(entries.data() + orig_size, entries.data() + entries.size());
|
||||
} else {
|
||||
SortEntries<false>(entries.data(), entries.data() + entries.size());
|
||||
SortEntries<false>(entries.data() + orig_size, entries.data() + entries.size());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -211,7 +211,7 @@ char* DirenvConvert(Arena& arena, struct dirent& ent, bool do_convert) {
|
|||
|
||||
bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precompose_unicode,
|
||||
bool case_sensitive) {
|
||||
entries.clear();
|
||||
const size_t orig_size = entries.size();
|
||||
dir_fd = dup(dir_fd);
|
||||
if (dir_fd < 0) return false;
|
||||
DIR* dir = fdopendir(dir_fd);
|
||||
|
|
@ -225,10 +225,10 @@ bool ListDir(int dir_fd, Arena& arena, std::vector<char*>& entries, bool precomp
|
|||
entries.push_back(DirenvConvert(arena, *ent, precompose_unicode));
|
||||
}
|
||||
if (errno) {
|
||||
entries.clear();
|
||||
entries.resize(orig_size);
|
||||
return false;
|
||||
}
|
||||
StrSort(entries.data(), entries.data() + entries.size(), case_sensitive);
|
||||
StrSort(entries.data() + orig_size, entries.data() + entries.size(), case_sensitive);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue