This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup 02/14] Factor out reading installed.db


Rather that doing implicitly the first time a packagedb is constructed, do
it explicitly at a certain point in time that is early enough.
---
 ini.cc        | 4 +++-
 package_db.cc | 9 +++++++--
 package_db.h  | 1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ini.cc b/ini.cc
index 82990a2..1162b91 100644
--- a/ini.cc
+++ b/ini.cc
@@ -346,13 +346,15 @@ do_remote_ini (HWND owner)
 static bool
 do_ini_thread (HINSTANCE h, HWND owner)
 {
+  packagedb db;
+  db.read();
+
   size_t ini_count = 0;
   if (source == IDC_SOURCE_LOCALDIR)
     ini_count = do_local_ini (owner);
   else
     ini_count = do_remote_ini (owner);
 
-  packagedb db;
   db.upgrade();
 
   if (ini_count == 0)
diff --git a/package_db.cc b/package_db.cc
index 00395d3..3d6d0de 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -45,10 +45,15 @@ using namespace std;
 
 packagedb::packagedb ()
 {
-  io_stream *db = 0;
+}
+
+void
+packagedb::read ()
+{
   if (!installeddbread)
     {
-      /* no parameters. Read in the local installation database. */
+      /* Read in the local installation database. */
+      io_stream *db = 0;
       db = io_stream::open ("cygfile:///etc/setup/installed.db", "rt", 0);
       installeddbread = 1;
       if (!db)
diff --git a/package_db.h b/package_db.h
index d02dbc4..d26f8ad 100644
--- a/package_db.h
+++ b/package_db.h
@@ -63,6 +63,7 @@ class packagedb
 {
 public:
   packagedb ();
+  void read();
   /* 0 on success */
   int flush ();
   void upgrade ();
-- 
2.12.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]