Author: aschnell
Date: Tue Mar 24 15:34:38 2009
New Revision: 56371
URL: http://svn.opensuse.org/viewcvs/yast?rev=56371&view=rev
Log:
- cleanup
Modified:
trunk/storage/libstorage/src/AppUtil.cc
trunk/storage/libstorage/src/AppUtil.h
trunk/storage/libstorage/src/Disk.cc
trunk/storage/libstorage/src/Storage.cc
trunk/storage/libstorage/src/StorageTypes.h
Modified: trunk/storage/libstorage/src/AppUtil.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.cc?rev=56371&r1=56370&r2=56371&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.cc (original)
+++ trunk/storage/libstorage/src/AppUtil.cc Tue Mar 24 15:34:38 2009
@@ -41,50 +41,6 @@
return(ret);
}
-bool
-searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr)
-{
- int LineNr_ii = 0;
- return searchFile(File_Cr, Pat_Cv, Line_Cr, LineNr_ii);
-}
-
-bool
-searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr, int& LineNr_ir)
-{
- int End_ii;
- bool Found_bi = false;
- bool BeginOfLine_bi;
- string Tmp_Ci;
- int LineNr_ii;
- string Search_Ci(Pat_Cv);
-
- BeginOfLine_bi = Search_Ci.length() > 0 && Search_Ci[0] == '^';
- if (BeginOfLine_bi)
- Search_Ci.erase(0, 1);
- End_ii = File_Cr.numLines();
- LineNr_ii = LineNr_ir;
- while (!Found_bi && LineNr_ii < End_ii)
- {
- string::size_type Idx_ii;
-
- Tmp_Ci = File_Cr[LineNr_ii++];
- Idx_ii = Tmp_Ci.find(Search_Ci);
- if (Idx_ii != string::npos)
- {
- if (BeginOfLine_bi)
- Found_bi = Idx_ii == 0;
- else
- Found_bi = true;
- }
- }
- if (Found_bi)
- {
- Line_Cr = Tmp_Ci;
- LineNr_ir = LineNr_ii - 1;
- }
- return Found_bi;
-}
-
void createPath(string Path_Cv)
{
@@ -491,7 +447,7 @@
Regex rx("^" + Regex::ws + "([0-9]+)" + Regex::ws + string(driver) + "$");
- if (find_if(lines.begin(), lines.end(), regex_matches(rx)) != lines.end())
+ if (find_if(lines, regex_matches(rx)) != lines.end())
rx.cap(1) >> ret;
else
y2err("did not find " << driver << " in /proc/devices");
Modified: trunk/storage/libstorage/src/AppUtil.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/AppUtil.h?rev=56371&r1=56370&r2=56371&view=diff
==============================================================================
--- trunk/storage/libstorage/src/AppUtil.h (original)
+++ trunk/storage/libstorage/src/AppUtil.h Tue Mar 24 15:34:38 2009
@@ -13,12 +13,6 @@
{
using std::string;
-
-class AsciiFile;
-
-bool searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr);
-bool searchFile(AsciiFile& File_Cr, string Pat_Cv, string& Line_Cr,
- int& StartLine_ir);
void createPath(string Path_Cv);
bool checkNormalFile(string Path_Cv);
bool checkDir(string Path_Cv);
Modified: trunk/storage/libstorage/src/Disk.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Disk.cc?rev=56371&r1=56370&r2=56371&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Disk.cc (original)
+++ trunk/storage/libstorage/src/Disk.cc Tue Mar 24 15:34:38 2009
@@ -67,107 +67,94 @@
addToList( p );
}
-Disk::Disk( Storage * const s, const string& fname ) :
- Container(s,"",staticType())
- {
+
+Disk::Disk(Storage * const s, const string& fname)
+ : Container(s, "", staticType())
+{
init_disk = dmp_slave = iscsi = gpt_enlarge = false;
nm = fname.substr( fname.find_last_of( '/' )+1);
if( nm.find("disk_")==0 )
nm.erase( 0, 5 );
- AsciiFile file( fname );
- string line;
- if( searchFile( file, "^Device:", line ) )
- {
- dev = extractNthWord( 1, line );
- }
+
+ AsciiFile file(fname);
+ const vector<string>& lines = file.lines();
+ vector<string>::const_iterator it;
+
+ if ((it = find_if(lines, string_starts_with("Device:"))) != lines.end())
+ dev = extractNthWord(1, *it);
+
mnr = mjr = 0;
- if( searchFile( file, "^Major:", line ) )
- {
- extractNthWord( 1, line ) >> mjr;
- }
- if( searchFile( file, "^Minor:", line ) )
- {
- extractNthWord( 1, line ) >> mnr;
- }
+ if ((it = find_if(lines, string_starts_with("Major:"))) != lines.end())
+ extractNthWord(1, *it) >> mjr;
+ if ((it = find_if(lines, string_starts_with("Minor:"))) != lines.end())
+ extractNthWord(1, *it) >> mnr;
+
range = 4;
- if( searchFile( file, "^Range:", line ) )
- {
- extractNthWord( 1, line ) >> range;
- }
+ if ((it = find_if(lines, string_starts_with("Range:"))) != lines.end())
+ extractNthWord(1, *it) >> range;
+
cyl = 1024;
- if( searchFile( file, "^Cylinder:", line ) )
- {
- extractNthWord( 1, line ) >> cyl;
- }
+ if ((it = find_if(lines, string_starts_with("Cylinder:"))) != lines.end())
+ extractNthWord(1, *it) >> cyl;
head = 1024;
- if( searchFile( file, "^Head:", line ) )
- {
- extractNthWord( 1, line ) >> head;
- }
+ if ((it = find_if(lines, string_starts_with("Head:"))) != lines.end())
+ extractNthWord(1, *it) >> head;
sector = 32;
- if( searchFile( file, "^Sector:", line ) )
- {
- extractNthWord( 1, line ) >> sector;
- }
+ if ((it = find_if(lines, string_starts_with("Sector:"))) != lines.end())
+ extractNthWord(1, *it) >> sector;
byte_cyl = head * sector * 512;
- if( searchFile( file, "^Label:", line ) )
- {
- label = extractNthWord( 1, line );
- }
+
+ if ((it = find_if(lines, string_starts_with("Label:"))) != lines.end())
+ label = extractNthWord(1, *it);
+
max_primary = 0;
- if( searchFile( file, "^MaxPrimary:", line ) )
- {
- extractNthWord( 1, line ) >> max_primary;
- }
+ if ((it = find_if(lines, string_starts_with("MaxPrimary:"))) != lines.end())
+ extractNthWord(1, *it) >> max_primary;
ext_possible = false;
- if( searchFile( file, "^ExtPossible:", line ) )
- {
- extractNthWord( 1, line ) >> ext_possible;
- }
+ if ((it = find_if(lines, string_starts_with("ExtPossible:"))) != lines.end())
+ extractNthWord(1, *it) >> ext_possible;
max_logical = 0;
- if( searchFile( file, "^MaxLogical:", line ) )
- {
- extractNthWord( 1, line ) >> max_logical;
- }
+ if ((it = find_if(lines, string_starts_with("MaxLogical:"))) != lines.end())
+ extractNthWord(1, *it) >> max_logical;
+
ronly = false;
- if( searchFile( file, "^Readonly:", line ) )
- {
- extractNthWord( 1, line ) >> ronly;
- }
+ if ((it = find_if(lines, string_starts_with("Readonly:"))) != lines.end())
+ extractNthWord(1, *it) >> ronly;
+
if( FakeDisk() && isdigit( nm[nm.size()-1] ))
- {
+ {
string::size_type p = nm.find_last_not_of( "0123456789" );
nm.erase( p+1 );
- }
+ }
+
size_k = 0;
- if( searchFile( file, "^SizeK:", line ) )
- {
- extractNthWord( 1, line ) >> size_k;
- }
+ if ((it = find_if(lines, string_starts_with("SizeK:"))) != lines.end())
+ extractNthWord(1, *it) >> size_k;
+
udev_path.clear();
- if( searchFile( file, "^UdevPath:", line ) )
- {
- udev_path = extractNthWord( 1, line );
- }
+ if ((it = find_if(lines, string_starts_with("UdevPath:"))) != lines.end())
+ udev_path = extractNthWord(1, *it);
udev_id.clear();
- if( searchFile( file, "^UdevId:", line ) )
- {
- udev_id.push_back( extractNthWord( 1, line ));
- }
- int lnr = 0;
- while( searchFile( file, "^Partition:", line, lnr ))
+ if ((it = find_if(lines, string_starts_with("UdevId:"))) != lines.end())
+ udev_id.push_back(extractNthWord(1, *it));
+
+ for (it = lines.begin(); it != lines.end(); ++it)
+ {
+ if (string_starts_with("Partition:")(*it))
{
- lnr++;
- Partition *p = new Partition( *this, extractNthWord( 1, line, true ));
- addToList( p );
+ Partition* p = new Partition(*this, extractNthWord(1, *it, true));
+ addToList( p );
}
- y2deb("constructed disk " << dev << " from file " << fname);
}
+ y2deb("constructed disk " << dev << " from file " << fname);
+}
+
+
Disk::~Disk()
- {
+{
y2deb("destructed disk " << dev);
- }
+}
void
Modified: trunk/storage/libstorage/src/Storage.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/Storage.cc?rev=56371&r1=56370&r2=56371&view=diff
==============================================================================
--- trunk/storage/libstorage/src/Storage.cc (original)
+++ trunk/storage/libstorage/src/Storage.cc Tue Mar 24 15:34:38 2009
@@ -137,7 +137,7 @@
AsciiFile sc( "/etc/sysconfig/storage" );
const vector<string>& lines = sc.lines();
Regex rx('^' + Regex::ws + "DEVICE_NAMES" + '=' + "(['\"]?)([^'\"]*)\\1" + Regex::ws + '$');
- if (find_if(lines.begin(), lines.end(), regex_matches(rx)) != lines.end())
+ if (find_if(lines, regex_matches(rx)) != lines.end())
{
string val = boost::to_lower_copy(rx.cap(2), locale::classic());
if( val == "id" )
@@ -815,7 +815,7 @@
for( VolIterator i=begin; i!=end; ++i )
{
- vector<string>::const_iterator pos = find_if(lines.begin(), lines.end(), string_starts_with(i->device() + " "));
+ vector<string>::const_iterator pos = find_if(lines, string_starts_with(i->device() + " "));
if (pos != lines.end())
{
i->getTestmodeData(*pos);
Modified: trunk/storage/libstorage/src/StorageTypes.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/StorageTypes.h?rev=56371&r1=56370&r2=56371&view=diff
==============================================================================
--- trunk/storage/libstorage/src/StorageTypes.h (original)
+++ trunk/storage/libstorage/src/StorageTypes.h Tue Mar 24 15:34:38 2009
@@ -1,6 +1,9 @@
#ifndef STORAGE_TYPES_H
#define STORAGE_TYPES_H
+
+#include <string>
+#include <vector>
#include <ostream>
#include