serializer: set output name to .serialized 66/201466/3
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 14 Mar 2019 09:59:05 +0000 (10:59 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Fri, 15 Mar 2019 14:03:34 +0000 (15:03 +0100)
By default libdbuspolicy may expect serialized policy file
in default location, with XML policy file name modified
by adding .serialized suffix.

This changes serializer default behavior to create output files
with the same naming rules instead of using result.dat.

Of course, if a user specifies its own specific output file name,
the serializer still creates output file with the given name.

Change-Id: I5ca0699027013e23fe2d83c5abd80bdebc165b1c

src/dbuspolicy_serializer.cpp

index 63b0e19..deb009a 100644 (file)
@@ -21,13 +21,15 @@ static void print_help(const char *name) {
        cout << "usage: " << name << " [-o output_filename] <input_filename>" << endl;
        cout << "       " << name << " {--system|--session} [-o output_filename]" << endl;
        cout << endl;
+       cout << "If not specified, output_filename is input_filename.serialized" << endl;
+       cout << endl;
 }
 
 int main(int argc, char *argv[])
 {
        BusType bus_type = BusType::SYSTEM_BUS;
        bool need_input_filename = true;
-       std::string output_filename = "result.dat";
+       std::string output_filename;
        std::string input_filename;
        int c;
 
@@ -67,6 +69,9 @@ int main(int argc, char *argv[])
                }
        }
 
+       if (output_filename.empty())
+               output_filename = input_filename + ".serialized";
+
        cout << "Read from: " << input_filename << " write to: " << output_filename << endl;
        ldp_xml_parser::Serializer serializer;
        ofstream output(output_filename, ofstream::binary);