#
# patch "ChangeLog"
# from [4c6d67b16c8bff1e2456242ab48d853d3d34dc34]
# to [8e048f4e850b805915266d7c96a991c41a5a6056]
#
# patch "file_io.cc"
# from [9d4808690a65bb6c488bfbb32000bd386a6ff82e]
# to [febfb6d77ff68b672149e4eaebe863d681f936a7]
#
# patch "file_io.hh"
# from [6902d2af8432d25ad5f30fee5e449928a3674a8c]
# to [8adb1eccca1a007c6be0f14e7f7d66c0265d971a]
#
========================================================================
--- ChangeLog 4c6d67b16c8bff1e2456242ab48d853d3d34dc34
+++ ChangeLog 8e048f4e850b805915266d7c96a991c41a5a6056
@@ -1,5 +1,10 @@
2005-08-25 Nathaniel Smith
+ * file_io.cc (read_data): Implement. Remove the base64>
+ versions.
+
+2005-08-25 Nathaniel Smith
+
* file_io.cc (move_file, move_dir): Implement.
2005-08-25 Nathaniel Smith
========================================================================
--- file_io.cc 9d4808690a65bb6c488bfbb32000bd386a6ff82e
+++ file_io.cc febfb6d77ff68b672149e4eaebe863d681f936a7
@@ -198,20 +198,16 @@
fs::rename(old_path, new_path);
}
-static void
-read_data_impl(fs::path const & p,
- data & dat)
+void
+read_data(any_path const & p, data & dat)
{
- if (!fs::exists(p))
- throw oops("file '" + p.string() + "' does not exist");
-
- if (fs::is_directory(p))
- throw oops("file '" + p.string() + "' cannot be read as data; it is a directory");
-
- ifstream file(p.string().c_str(),
+ require_path_is_file(p,
+ F("file %s does not exist") % p,
+ F("file %s cannot be read as data; it is a directory") % p);
+
+ ifstream file(p.as_external().c_str(),
ios_base::in | ios_base::binary);
- if (!file)
- throw oops(string("cannot open file ") + p.string() + " for reading");
+ N(file, F("cannot open file %s for reading") % p);
Botan::Pipe pipe;
pipe.start_msg();
file >> pipe;
@@ -219,65 +215,7 @@
dat = pipe.read_all_as_string();
}
-// This function can only be called once per run.
-static void
-read_data_stdin(data & dat)
-{
- static bool have_consumed_stdin = false;
- N(!have_consumed_stdin, F("Cannot read standard input multiple times"));
- have_consumed_stdin = true;
- Botan::Pipe pipe;
- pipe.start_msg();
- cin >> pipe;
- pipe.end_msg();
- dat = pipe.read_all_as_string();
-}
-
void
-read_data(local_path const & path, data & dat)
-{
- read_data_impl(localized(path), dat);
-}
-
-void
-read_data(file_path const & path, data & dat)
-{
- read_data_impl(localized(path), dat);
-}
-
-void
-read_data(local_path const & path,
- base64< gzip > & dat)
-{
- data data_plain;
- read_data_impl(localized(path), data_plain);
- gzip data_compressed;
- base64< gzip > data_encoded;
- encode_gzip(data_plain, data_compressed);
- encode_base64(data_compressed, dat);
-}
-
-void
-read_data(file_path const & path,
- base64< gzip > & dat)
-{
- read_data(local_path(path()), dat);
-}
-
-void
-read_localized_data(file_path const & path,
- base64< gzip > & dat,
- lua_hooks & lua)
-{
- data data_plain;
- read_localized_data(path, data_plain, lua);
- gzip data_compressed;
- base64< gzip > data_encoded;
- encode_gzip(data_plain, data_compressed);
- encode_base64(data_compressed, dat);
-}
-
-void
read_localized_data(file_path const & path,
data & dat,
lua_hooks & lua)
@@ -308,6 +246,20 @@
}
+// This function can only be called once per run.
+static void
+read_data_stdin(data & dat)
+{
+ static bool have_consumed_stdin = false;
+ N(!have_consumed_stdin, F("Cannot read standard input multiple times"));
+ have_consumed_stdin = true;
+ Botan::Pipe pipe;
+ pipe.start_msg();
+ cin >> pipe;
+ pipe.end_msg();
+ dat = pipe.read_all_as_string();
+}
+
void
read_data_for_command_line(utf8 const & path, data & dat)
{
========================================================================
--- file_io.hh 6902d2af8432d25ad5f30fee5e449928a3674a8c
+++ file_io.hh 8adb1eccca1a007c6be0f14e7f7d66c0265d971a
@@ -83,13 +83,9 @@
any_path const & new_path);
void read_data(any_path const & path, data & data);
-void read_data(any_path const & path, base64< gzip > & data);
void read_localized_data(file_path const & path,
data & dat,
lua_hooks & lua);
-void read_localized_data(file_path const & path,
- base64< gzip > & dat,
- lua_hooks & lua);
// This function knows that "-" means "stdin".
void read_data_for_command_line(utf8 const & path, data & dat);