00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <iostream>
00021 #include <fstream>
00022 #include <string>
00023 #include <drizzled/message/catalog.pb.h>
00024
00025 using namespace std;
00026 using namespace drizzled;
00027
00028 int main(int argc, char* argv[])
00029 {
00030 GOOGLE_PROTOBUF_VERIFY_VERSION;
00031
00032 string file_name;
00033 message::Catalog catalog;
00034
00035 if (argc < 2)
00036 {
00037 cerr << "Usage: " << argv[0] << " CATALOG" << endl;
00038 return -1;
00039 }
00040
00041 if (argc == 3)
00042 file_name= argv[2];
00043 else
00044 file_name= argv[1];
00045
00046 catalog.set_name(argv[1]);
00047 catalog.mutable_engine()->set_name("filesystem");
00048 catalog.set_creation_timestamp(time(NULL));
00049 catalog.set_update_timestamp(time(NULL));
00050 catalog.set_uuid("catalog_writer");
00051 catalog.set_version(1);
00052
00053 fstream output(file_name.c_str(), ios::out | ios::trunc | ios::binary);
00054
00055 if (not catalog.SerializeToOstream(&output))
00056 {
00057 cerr << "Failed to write catalog." << endl;
00058 return -1;
00059 }
00060
00061 return 0;
00062 }