From 9898746ef3732979bf30e9048021b6232ddf15ac Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 19 Nov 2003 17:27:16 +0000 Subject: * nix-env: a tool to manage user environments. * Replace all directory reading code by a generic readDirectory() function. --- src/libstore/db.cc | 4 ++-- src/libstore/globals.cc | 1 + src/libstore/globals.hh | 3 +++ src/libstore/references.cc | 12 ++++-------- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/libstore') diff --git a/src/libstore/db.cc b/src/libstore/db.cc index 63ec2724fcb3..a97111a3a96d 100644 --- a/src/libstore/db.cc +++ b/src/libstore/db.cc @@ -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, diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index a292b49aeae0..e5d76ff48563 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -3,6 +3,7 @@ string nixStore = "/UNINIT"; string nixDataDir = "/UNINIT"; string nixLogDir = "/UNINIT"; +string nixStateDir = "/UNINIT"; string nixDBPath = "/UNINIT"; bool keepFailed = false; diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 1b4d0bde3ffe..3da294cc829a 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -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; diff --git a/src/libstore/references.cc b/src/libstore/references.cc index ab743f76d2d3..2bea44131ec0 100644 --- a/src/libstore/references.cc +++ b/src/libstore/references.cc @@ -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); } } -- cgit 1.4.1