Hi! I wrote the hack below in C++ to get ls to recognize ".hidden" files (files that list directory entries to be removed from the listing ala MacOS X). I even shoehorned it into ls and added "-lstdc++ hidden.o" to coreutils' Makefile. However, I'd much rather use C instead of C++ and plop the code into ls.c itself (and not depend on the standard C++ library). I don't know the first thing about memory management C, so I was hoping someone here knew the equivalent C code (or could direct me to where I could find out). Thanks!

// hidden.h

#ifdef __cplusplus
extern "C" {
void load_hidden_file(const char* a_dir);
int is_hidden(const char* a_entry);
void release_hidden_files();
#ifdef __cplusplus

#endif // HIDDEN_FILE_H

// hidden.cpp
#include <algorithm>
#include <fstream>
#include <string>
#include <vector>
#include "hidden.h"

namespace {
std::vector<std::string> hidden;

void load_hidden_file(const char* a_dir) {
std::string line = a_dir + std::string("/.hidden");
std::ifstream file(line.c_str());
if (file)
while(std::getline(file, line))

int is_hidden(const char* a_entry) {
return (std::find(hidden.begin(), hidden.end(), a_entry) != hidden.end())
|| (a_entry[0] == '.');

void release_hidden_files() {