Author: aschnell
Date: Tue Mar 3 12:38:33 2009
New Revision: 55866
URL: http://svn.opensuse.org/viewcvs/yast?rev=55866&view=rev
Log:
- provide access to lines in AsciiFile and SystemCmd. should allow to use
generic find/select/search functions
Modified:
trunk/storage/libstorage/src/AsciiFile.h
trunk/storage/libstorage/src/Container.cc
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/DmPartCo.cc
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/SystemCmd.cc
trunk/storage/libstorage/src/SystemCmd.h
Modified: trunk/storage/libstorage/src/AsciiFile.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AsciiFile.h?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AsciiFile.h (original)
+++ trunk/storage/libstorage/src/AsciiFile.h Tue Mar 3 12:38:33 2009
@@ -4,10 +4,12 @@
#include <vector>
#include <list>
-using std::string;
namespace storage
{
+ using std::string;
+ using std::vector;
+
class Regex;
@@ -46,6 +48,8 @@
unsigned differentLine( const AsciiFile& File_Cv ) const;
bool removeIfEmpty();
+ const vector<string>& lines() const { return Lines_C; }
+
protected:
bool appendFile( const string& Name_Cv, std::vector<string>& Lines_Cr );
bool appendFile( AsciiFile& File_Cv, std::vector<string>& Lines_Cr );
Modified: trunk/storage/libstorage/src/Container.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Container.cc?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Container.cc (original)
+++ trunk/storage/libstorage/src/Container.cc Tue Mar 3 12:38:33 2009
@@ -247,7 +247,7 @@
void Container::setExtError( const SystemCmd& cmd, bool serr ) const
{
- const string& s = serr ? cmd.stderr() : cmd.stdout();
+ const string& s = boost::join(serr ? cmd.stderr() : cmd.stdout(), "\n");
if( s.size()>0 )
{
sto->setExtError( cmd.cmd() + ":\n" + s );
Modified: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Tue Mar 3 12:38:33 2009
@@ -531,7 +531,7 @@
int
Disk::checkSystemError( const string& cmd_line, const SystemCmd& cmd )
{
- string tmp = cmd.stderr();
+ string tmp = boost::join(cmd.stderr(), "\n");
if (!tmp.empty())
{
y2err("cmd:" << cmd_line);
@@ -542,7 +542,7 @@
}
system_stderr += tmp;
}
- tmp = cmd.stdout();
+ tmp = boost::join(cmd.stdout(), "\n");
if (!tmp.empty())
{
y2mil("cmd:" << cmd_line);
Modified: trunk/storage/libstorage/src/DmPartCo.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/DmPartCo.cc?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/DmPartCo.cc (original)
+++ trunk/storage/libstorage/src/DmPartCo.cc Tue Mar 3 12:38:33 2009
@@ -258,7 +258,7 @@
DmPartCo::init( ProcPart& ppart )
{
SystemCmd c(DMSETUPBIN " table " + quote(nm));
- if( c.retcode()==0 && c.numLines()>=1 && isdigit( c.stdout()[0] ))
+ if( c.retcode()==0 && c.numLines()>=1 && isdigit( c.stdout()[0][0] ))
{
mnr = Dm::dmNumber( nm );
ppart.getSize( "dm-"+decString(mnr), size_k );
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Tue Mar 3 12:38:33 2009
@@ -5425,7 +5425,7 @@
SystemCmd c("/usr/sbin/ntfsresize -f -i " + quote(device));
string fstr = " might resize at ";
string::size_type pos;
- string stdout = c.stdout();
+ string stdout = boost::join(c.stdout(), "\n");
if (c.retcode()==0 && (pos=stdout.find(fstr))!=string::npos)
{
y2mil("pos:" << pos);
Modified: trunk/storage/libstorage/src/SystemCmd.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/SystemCmd.cc?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/SystemCmd.cc (original)
+++ trunk/storage/libstorage/src/SystemCmd.cc Tue Mar 3 12:38:33 2009
@@ -351,17 +351,6 @@
}
-string
-SystemCmd::getString( OutputStream Idx_iv ) const
- {
- if( Idx_iv > 1 )
- {
- y2err("invalid index " << Idx_iv);
- }
- return boost::join(Lines_aC[Idx_iv], "\n");
- }
-
-
unsigned
SystemCmd::numLines( bool Sel_bv, OutputStream Idx_iv ) const
{
Modified: trunk/storage/libstorage/src/SystemCmd.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/SystemCmd.h?rev=55866&r1=55865&r2=55866&view=diff
==============================================================================
--- trunk/storage/libstorage/src/SystemCmd.h (original)
+++ trunk/storage/libstorage/src/SystemCmd.h Tue Mar 3 12:38:33 2009
@@ -8,10 +8,10 @@
#include <vector>
#include <list>
-using std::string;
-
namespace storage
{
+ using std::string;
+ using std::vector;
class OutputProcessor;
@@ -36,8 +36,9 @@
void logOutput() const;
- string stderr() const { return getString(IDX_STDERR); }
- string stdout() const { return getString(IDX_STDOUT); }
+ const vector<string>& stdout() const { return Lines_aC[IDX_STDOUT]; }
+ const vector<string>& stderr() const { return Lines_aC[IDX_STDERR]; }
+
string cmd() const { return lastCmd; }
int retcode() const { return Ret_i; }
@@ -73,8 +74,6 @@
void addLine(const string& Text_Cv, std::vector<string>& Lines_Cr);
void init();
- string getString(OutputStream Idx_ii = IDX_STDOUT) const;
-
FILE* File_aC[2];
std::vector<string> Lines_aC[2];
std::vector