* nix-env: a tool to manage user environments.
* Replace all directory reading code by a generic readDirectory() function.
This commit is contained in:
parent
fd7ac09f10
commit
9898746ef3
16 changed files with 412 additions and 51 deletions
|
@ -166,7 +166,7 @@ void Database::open(const string & path)
|
|||
/* The following code provides automatic recovery of the
|
||||
database environment. Recovery is necessary when a process
|
||||
dies while it has the database open. To detect this,
|
||||
processes atomically increment a counter when the open the
|
||||
processes atomically increment a counter when they open the
|
||||
database, and decrement it when they close it. If we see
|
||||
that counter is > 0 but no processes are accessing the
|
||||
database---determined by attempting to obtain a write lock
|
||||
|
@ -199,7 +199,7 @@ void Database::open(const string & path)
|
|||
other readers or writers. */
|
||||
|
||||
int n = getAccessorCount(fdAccessors);
|
||||
setAccessorCount(fdAccessors, 1);
|
||||
setAccessorCount(fdAccessors, 1);
|
||||
|
||||
if (n != 0) {
|
||||
printMsg(lvlTalkative,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
string nixStore = "/UNINIT";
|
||||
string nixDataDir = "/UNINIT";
|
||||
string nixLogDir = "/UNINIT";
|
||||
string nixStateDir = "/UNINIT";
|
||||
string nixDBPath = "/UNINIT";
|
||||
|
||||
bool keepFailed = false;
|
||||
|
|
|
@ -16,6 +16,9 @@ extern string nixDataDir; /* !!! fix */
|
|||
/* nixLogDir is the directory where we log various operations. */
|
||||
extern string nixLogDir;
|
||||
|
||||
/* nixStateDir is the directory where state is stored. */
|
||||
extern string nixStateDir;
|
||||
|
||||
/* nixDBPath is the path name of our Berkeley DB environment. */
|
||||
extern string nixDBPath;
|
||||
|
||||
|
|
|
@ -36,14 +36,10 @@ void checkPath(const string & path,
|
|||
throw SysError(format("getting attributes of path `%1%'") % path);
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
AutoCloseDir dir = opendir(path.c_str());
|
||||
|
||||
struct dirent * dirent;
|
||||
while (errno = 0, dirent = readdir(dir)) {
|
||||
string name = dirent->d_name;
|
||||
if (name == "." || name == "..") continue;
|
||||
search(name, ids, seen);
|
||||
checkPath(path + "/" + name, ids, seen);
|
||||
Strings names = readDirectory(path);
|
||||
for (Strings::iterator i = names.begin(); i != names.end(); i++) {
|
||||
search(*i, ids, seen);
|
||||
checkPath(path + "/" + *i, ids, seen);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue