#
# patch "ChangeLog"
# from [09fc1962e328b98b40e53a69fd715d68265279ff]
# to [14c949f934bdc8eb70186ad02c92866c2ef5d006]
#
# patch "database.cc"
# from [8d0f3f9f112b640c2eb877595fbce56e8b04ac02]
# to [5d925a861c0fd595434f76a7d916e609fcfd4859]
#
# patch "database.hh"
# from [14ba00bff0d68669687755c58a3b35172333cfe1]
# to [8cc3e02dbed0ddc46ba6c32b8572c316340eb282]
#
# patch "file_io.cc"
# from [442fc17a140ef95f024c4aa58a22aa4a924a3cb8]
# to [a3744fefaa6ad87cfefecaed427b21adc16581bd]
#
# patch "file_io.hh"
# from [5712c71aa04e18828ae63e33ed0e0030d4d40e8d]
# to [c235365c658cc4716e935087ada543b663f7bb0c]
#
# patch "monotone.cc"
# from [25377c90318075893420d6062e3471d6c14cd084]
# to [604d5b80f18d40961ae6d589064c7791cc3def71]
#
# patch "paths.cc"
# from [323736ebeb967accea41ef853150771414055d66]
# to [1da5513341ff15b2887ebd5040934405aa5d4e00]
#
# patch "paths.hh"
# from [ae48a5f399ef3c5e157acbce535415fca6b67715]
# to [d1545b2288da082ff04bde7e36760748079f9053]
#
# patch "vocab.cc"
# from [705631e329160226f4ef065c411ac42c22dd56c1]
# to [cebf734fb6a83a66665786e2c1486d4934137066]
#
# patch "vocab_terms.hh"
# from [fe3bf7a7700bdde82211ba0be39caf248025e00b]
# to [9abc8225074b278d3b7a57c291ab5d8fd0a98ea6]
#
========================================================================
--- ChangeLog 09fc1962e328b98b40e53a69fd715d68265279ff
+++ ChangeLog 14c949f934bdc8eb70186ad02c92866c2ef5d006
@@ -1,5 +1,11 @@
2005-08-23 Nathaniel Smith
+ * vocab_terms.hh, vocab.cc: Remove file_path, local_path.
+ * database.{hh,cc}, monotone.cc: Convert to paths.hh.
+ * file_io.{hh,cc}: Start to convert to paths.hh.
+
+2005-08-23 Nathaniel Smith
+
* paths.{cc,hh} (fully_normalized_path): Implement.
(external_path): Rename to system_path.
Misc. other updates.
========================================================================
--- database.cc 8d0f3f9f112b640c2eb877595fbce56e8b04ac02
+++ database.cc 5d925a861c0fd595434f76a7d916e609fcfd4859
@@ -15,8 +15,6 @@
#include
#include
-#include
-#include
#include
@@ -61,7 +59,7 @@
const char *sqlite3_column_text_s(sqlite3_stmt*, int col);
}
-database::database(fs::path const & fn) :
+database::database(system_path const & fn) :
filename(fn),
// nb. update this if you change the schema. unfortunately we are not
// using self-digesting schemas due to comment irregularities and
@@ -131,19 +129,22 @@
}
static void
-check_sqlite_format_version(fs::path const & filename)
+check_sqlite_format_version(system_path const & filename)
{
- if (fs::exists(filename))
+ switch (path_state(filename))
{
- N(!fs::is_directory(filename),
- F("database %s is a directory\n") % filename.string());
-
+ path::nonexistent:
+ return;
+ path::directory:
+ N(false, F("database %s is a directory") % filename);
+ break;
+ path::file:
// sqlite 3 files begin with this constant string
// (version 2 files begin with a different one)
std::string version_string("SQLite format 3");
- std::ifstream file(filename.string().c_str());
- N(file, F("unable to probe database version in file %s") % filename.string());
+ std::ifstream file(filename.as_external().c_str());
+ N(file, F("unable to probe database version in file %s") % filename);
for (std::string::const_iterator i = version_string.begin();
i != version_string.end(); ++i)
@@ -151,7 +152,7 @@
char c;
file.get(c);
N(c == *i, F("database %s is not an sqlite version 3 file, "
- "try dump and reload") % filename.string());
+ "try dump and reload") % filename);
}
}
}
@@ -178,18 +179,19 @@
if (! init)
{
- N(fs::exists(filename),
- F("database %s does not exist") % filename.string());
- N(!fs::is_directory(filename),
- F("database %s is a directory") % filename.string());
+ path::state state = path_state(filename);
+ N(state != path::nonexistent,
+ F("database %s does not exist") % filename);
+ N(state != path::directory,
+ F("database %s is a directory") % filename);
}
check_sqlite_format_version(filename);
int error;
- error = sqlite3_open(filename.string().c_str(), &__sql);
+ error = sqlite3_open(filename.as_external().c_str(), &__sql);
if (error)
- throw oops(string("could not open database: ") + filename.string() +
- (": " + string(sqlite3_errmsg(__sql))));
+ throw oops((F("could not open database: %s: %s")
+ % filename % sqlite3_errmsg(__sql)).str());
if (init)
{
sqlite3_exec(__sql, schema_constant, NULL, NULL, NULL);
@@ -209,15 +211,15 @@
if (__sql)
throw oops("cannot initialize database while it is open");
- N(!fs::exists(filename),
+ N(!path_state(filename),
F("could not initialize database: %s: already exists")
- % filename.string());
+ % filename);
- fs::path journal = mkpath(filename.string() + "-journal");
- N(!fs::exists(journal),
+ system_path journal(filename.as_external() + "-journal");
+ N(!path_state(journal),
F("existing (possibly stale) journal file '%s' "
"has same stem as new database '%s'")
- % journal.string() % filename.string());
+ % journal % filename);
sqlite3 *s = sql(true);
I(s != NULL);
@@ -330,14 +332,14 @@
char buf[constants::bufsz];
string tmp;
- N(filename.string() != "",
+ N(!filename.empty(),
F("need database name"));
- N(!fs::exists(filename),
- F("cannot create %s; it already exists\n") % filename.string());
- int error = sqlite3_open(filename.string().c_str(), &__sql);
+ N(!path_state(filename),
+ F("cannot create %s; it already exists") % filename);
+ int error = sqlite3_open(filename.as_external().c_str(), &__sql);
if (error)
- throw oops(string("could not open database: ") + filename.string() +
- (string(sqlite3_errmsg(__sql))));
+ throw oops((F("could not open database: %s: %s")
+ % filename % sqlite3_errmsg(__sql)).str());
while(in)
{
@@ -431,14 +433,14 @@
database::version(ostream & out)
{
string id;
- N(filename.string() != "",
+ N(!filename.empty(),
F("need database name"));
- int error = sqlite3_open(filename.string().c_str(), &__sql);
+ int error = sqlite3_open(filename.as_external().c_str(), &__sql);
if (error)
{
sqlite3_close(__sql);
- throw oops(string("could not open database: ") + filename.string() +
- (": " + string(sqlite3_errmsg(__sql))));
+ throw oops((F("could not open database: %s: %s")
+ % filename % sqlite3_errmsg(__sql)).str());
}
calculate_schema_id(__sql, id);
sqlite3_close(__sql);
@@ -448,14 +450,14 @@
void
database::migrate()
{
- N(filename.string() != "",
+ N(!filename.empty(),
F("need database name"));
- int error = sqlite3_open(filename.string().c_str(), &__sql);
+ int error = sqlite3_open(filename.as_external().c_str(), &__sql);
if (error)
{
sqlite3_close(__sql);
- throw oops(string("could not open database: ") + filename.string() +
- (": " + string(sqlite3_errmsg(__sql))));
+ throw oops((F("could not open database: %s: %s")
+ % filename % sqlite3_errmsg(__sql)).str());
}
migrate_monotone_schema(__sql);
sqlite3_close(__sql);
@@ -660,11 +662,11 @@
// general application-level logic
void
-database::set_filename(fs::path const & file)
+database::set_filename(system_path const & file)
{
if (__sql)
{
- throw oops("cannot change filename to " + file.string() + " while db is open");
+ throw oops("cannot change filename to " + file + " while db is open");
}
filename = file;
}
========================================================================
--- database.hh 14ba00bff0d68669687755c58a3b35172333cfe1
+++ database.hh 8cc3e02dbed0ddc46ba6c32b8572c316340eb282
@@ -17,12 +17,11 @@
#include