summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsnappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143>2013-01-06 19:21:26 +0000
committersnappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143>2013-01-06 19:21:26 +0000
commit81f34784b7b812dcda956ee489dfdc74ec2da990 (patch)
tree7acd77f25a472aab13e9531a7953275deee7ae05
parent698af469b47fe809905e2ed173ad84241de5800f (diff)
downloadsnappy-git-81f34784b7b812dcda956ee489dfdc74ec2da990.tar.gz
Adjust the Snappy open-source distribution for the changes in Google's
internal file API. R=sanjay git-svn-id: https://snappy.googlecode.com/svn/trunk@70 03e5f5b5-db94-4691-08a0-1a8bf15f6143
-rw-r--r--snappy-test.cc9
-rw-r--r--snappy-test.h29
-rw-r--r--snappy_unittest.cc16
3 files changed, 37 insertions, 17 deletions
diff --git a/snappy-test.cc b/snappy-test.cc
index 6a0611e..487b29c 100644
--- a/snappy-test.cc
+++ b/snappy-test.cc
@@ -46,10 +46,13 @@ string ReadTestDataFile(const string& base) {
string contents;
const char* srcdir = getenv("srcdir"); // This is set by Automake.
if (srcdir) {
- File::ReadFileToStringOrDie(
- string(srcdir) + "/testdata/" + base, &contents);
+ file::ReadFileToString(string(srcdir) + "/testdata/" + base,
+ &contents,
+ file::Defaults()).CheckSuccess();
} else {
- File::ReadFileToStringOrDie("testdata/" + base, &contents);
+ file::ReadFileToString("/testdata/" + base,
+ &contents,
+ file::Defaults()).CheckSuccess();
}
return contents;
}
diff --git a/snappy-test.h b/snappy-test.h
index 08b5cb7..bec9020 100644
--- a/snappy-test.h
+++ b/snappy-test.h
@@ -126,10 +126,20 @@ extern "C" {
#endif
namespace {
+
namespace File {
void Init() { }
+} // namespace File
+
+namespace file {
+ int Defaults() { }
+
+ class DummyStatus {
+ public:
+ void CheckSuccess() { }
+ };
- void ReadFileToStringOrDie(const char* filename, string* data) {
+ DummyStatus ReadFileToString(const char* filename, string* data, int unused) {
FILE* fp = fopen(filename, "rb");
if (fp == NULL) {
perror(filename);
@@ -150,14 +160,18 @@ namespace File {
fclose(fp);
}
- void ReadFileToStringOrDie(const string& filename, string* data) {
- ReadFileToStringOrDie(filename.c_str(), data);
+ DummyStatus ReadFileToString(const string& filename,
+ string* data,
+ int unused) {
+ ReadFileToString(filename.c_str(), data, unused);
}
- void WriteStringToFileOrDie(const string& str, const char* filename) {
- FILE* fp = fopen(filename, "wb");
+ DummyStatus WriteStringToFile(const string& str,
+ const string& filename,
+ int unused) {
+ FILE* fp = fopen(filename.c_str(), "wb");
if (fp == NULL) {
- perror(filename);
+ perror(filename.c_str());
exit(1);
}
@@ -169,7 +183,8 @@ namespace File {
fclose(fp);
}
-} // namespace File
+} // namespace file
+
} // namespace
namespace snappy {
diff --git a/snappy_unittest.cc b/snappy_unittest.cc
index f3b9c83..f345dc3 100644
--- a/snappy_unittest.cc
+++ b/snappy_unittest.cc
@@ -971,18 +971,19 @@ TEST(Snappy, FindMatchLengthRandom) {
static void CompressFile(const char* fname) {
string fullinput;
- File::ReadFileToStringOrDie(fname, &fullinput);
+ file::ReadFileToString(fname, &fullinput, file::Defaults()).CheckSuccess();
string compressed;
Compress(fullinput.data(), fullinput.size(), SNAPPY, &compressed, false);
- File::WriteStringToFileOrDie(compressed,
- string(fname).append(".comp").c_str());
+ file::WriteStringToFile(
+ string(fname).append(".comp").c_str(), compressed,
+ file::Defaults()).CheckSuccess();
}
static void UncompressFile(const char* fname) {
string fullinput;
- File::ReadFileToStringOrDie(fname, &fullinput);
+ file::ReadFileToString(fname, &fullinput, file::Defaults()).CheckSuccess();
size_t uncompLength;
CHECK(CheckUncompressedLength(fullinput, &uncompLength));
@@ -991,13 +992,14 @@ static void UncompressFile(const char* fname) {
uncompressed.resize(uncompLength);
CHECK(snappy::Uncompress(fullinput.data(), fullinput.size(), &uncompressed));
- File::WriteStringToFileOrDie(uncompressed,
- string(fname).append(".uncomp").c_str());
+ file::WriteStringToFile(
+ string(fname).append(".uncomp").c_str(), uncompressed,
+ file::Defaults()).CheckSuccess();
}
static void MeasureFile(const char* fname) {
string fullinput;
- File::ReadFileToStringOrDie(fname, &fullinput);
+ file::ReadFileToString(fname, &fullinput, file::Defaults()).CheckSuccess();
printf("%-40s :\n", fname);
int start_len = (FLAGS_start_len < 0) ? fullinput.size() : FLAGS_start_len;