53 QApplication app(argc, argv, false); // GUIenabled=false |
53 QApplication app(argc, argv, false); // GUIenabled=false |
54 |
54 |
55 if (argc <= 2) { |
55 if (argc <= 2) { |
56 showHelp(); |
56 showHelp(); |
57 } else { |
57 } else { |
|
58 //bool backup = false; |
58 QString source, target; |
59 QString source, target; |
|
60 //QStringList restore; |
59 QStringList args(app.arguments()); |
61 QStringList args(app.arguments()); |
60 |
62 |
61 for (int n = 0; n < args.count(); n++) { |
63 for (int n = 0; n < args.count(); n++) { |
62 if (args[n].toLower() == "-s") { |
64 if (args[n].toLower() == "-s") { |
63 source = args[n+1]; |
65 source = args[n+1]; |
64 n++; |
66 n++; |
65 } else if (args[n].toLower() == "-t") { |
67 } else if (args[n].toLower() == "-t") { |
66 target = args[n+1]; |
68 target = args[n+1]; |
67 n++; |
69 n++; |
68 } |
70 /* |
|
71 } else if (args[n].toLower() == "--backup-and-replace") { |
|
72 backup = true; |
|
73 } else if (args[n].toLower() == "-restore") { |
|
74 n++; |
|
75 while (n < args.count()) { |
|
76 restore.append( args[n] ); |
|
77 n++; |
|
78 } |
|
79 */ |
|
80 } |
69 } |
81 } |
|
82 /* |
|
83 if (restore.count()) { |
|
84 for (int i = 0; i < restore.count(); i++) { |
|
85 QString orig = restore.at(i) + ".orig"; |
|
86 if ( QFile::exists(orig) ) { |
|
87 QFile::remove(restore.at(i)); |
|
88 QFile origFile(orig); |
|
89 origFile.rename(restore.at(i)); |
|
90 } |
|
91 } |
|
92 return 0; |
|
93 } |
|
94 */ |
70 |
95 |
71 if (source.length() > 0) { |
96 if (source.length() > 0) { |
|
97 /* |
|
98 if (backup) { |
|
99 QString orig = source + ".orig"; |
|
100 if ( QFile::exists(orig) ) { |
|
101 QFile::remove(orig); |
|
102 } |
|
103 QFile origFile(source); |
|
104 origFile.rename(orig); |
|
105 target = source; |
|
106 source = orig; |
|
107 } |
|
108 */ |
72 if (!QFile::exists(source)) { |
109 if (!QFile::exists(source)) { |
73 std::cout << "Error: file " << source.toStdString() << " does not exist.\n"; |
110 std::cout << "Error: file " << source.toStdString() << " does not exist.\n"; |
74 } else { |
111 } else { |
75 // Open file and parse lines. Each line should have three value separated with: |
112 // Open file and parse lines. Each line should have three value separated with: |
76 QFile sourceFile(source); |
113 QFile sourceFile(source); |
77 if (sourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
114 if (sourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) { |
78 if (!target.length()) { |
115 if (!target.length()) { |
79 target = source + ".bin"; |
116 target = source + ".bin"; |
80 } |
117 } |
81 if (QFile::exists(target)) { |
118 QFile targetFile(target); |
82 std::cout << "Error: target file already exists.\n"; |
119 if (targetFile.open(QIODevice::WriteOnly)) { |
83 } else { |
120 HbDocumentLoader loader; |
84 QFile targetFile(target); |
121 loader.createBinary( &sourceFile, &targetFile ); |
85 if (targetFile.open(QIODevice::WriteOnly)) { |
122 targetFile.close(); |
86 HbDocumentLoader loader; |
|
87 loader.createBinary( &sourceFile, &targetFile ); |
|
88 targetFile.close(); |
|
89 } |
|
90 } |
123 } |
91 sourceFile.close(); |
124 sourceFile.close(); |
92 } |
125 } |
93 } |
126 } |
94 } |
127 } |