Changeset 620
- Timestamp:
- 09/06/07 13:09:35 (15 years ago)
- Files:
-
- trunk/libffado/src/bebob/bebob_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/genericavc/avc_vendormodel.cpp (modified) (4 diffs)
- trunk/libffado/src/libutil/serialize.cpp (modified) (2 diffs)
- trunk/libffado/src/libutil/serialize.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/bebob/bebob_avdevice.cpp
r618 r620 446 446 Glib::ustring cachePath; 447 447 char* pCachePath; 448 if ( asprintf( &pCachePath, "%s/cache/ libffado/", CACHEDIR ) < 0 ) {448 if ( asprintf( &pCachePath, "%s/cache/", CACHEDIR ) < 0 ) { 449 449 debugError( "Could not create path string for cache pool (trying '/var/cache/libffado' instead)\n" ); 450 450 cachePath == "/var/cache/libffado/"; … … 487 487 AvDevice::saveCache() 488 488 { 489 // // the path looks like this: 490 // // PATH_TO_CACHE + GUID + CONFIGURATION_ID 491 // 492 // Glib::ustring sDevicePath = getCachePath() + m_pConfigRom->getGuidString(); 493 // struct stat buf; 494 // if ( stat( sDevicePath.c_str(), &buf ) == 0 ) { 495 // if ( !S_ISDIR( buf.st_mode ) ) { 496 // debugError( "\"%s\" is not a directory\n", sDevicePath.c_str() ); 497 // return false; 498 // } 499 // } else { 500 // if ( mkdir( sDevicePath.c_str(), S_IRWXU | S_IRWXG ) != 0 ) { 501 // debugError( "Could not create \"%s\" directory\n", sDevicePath.c_str() ); 502 // return false; 503 // } 504 // } 505 // 506 // char* configId; 507 // asprintf(&configId, "%08x", BeBoB::AvDevice::getConfigurationId() ); 508 // if ( !configId ) { 509 // debugError( "Could not create id string\n" ); 510 // return false; 511 // } 512 // Glib::ustring sFileName = sDevicePath + "/" + configId + ".xml"; 513 // free( configId ); 514 // debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", sFileName.c_str() ); 515 // 516 // Util::XMLSerialize ser( sFileName ); 517 // return serialize( "", ser ); 518 return false; 489 // the path looks like this: 490 // PATH_TO_CACHE + GUID + CONFIGURATION_ID 491 string tmp_path = getCachePath() + m_pConfigRom->getGuidString(); 492 493 // the following piece should do something like 'mkdir -p some/path/with/some/dirs/which/do/not/exist' 494 vector<string> tokens; 495 tokenize( tmp_path, tokens, "/" ); 496 string path; 497 for ( vector<string>::const_iterator it = tokens.begin(); 498 it != tokens.end(); 499 ++it ) 500 { 501 if ( path == "" ) { 502 if ( *it == "~" ) 503 path = getenv( "HOME" ); 504 else 505 path = *it; 506 } else { 507 path = path + "/" + *it; 508 } 509 510 struct stat buf; 511 if ( stat( path.c_str(), &buf ) == 0 ) { 512 if ( !S_ISDIR( buf.st_mode ) ) { 513 debugError( "\"%s\" is not a directory\n", path.c_str() ); 514 return false; 515 } 516 } else { 517 if ( mkdir( path.c_str(), S_IRWXU | S_IRWXG ) != 0 ) { 518 debugError( "Could not create \"%s\" directory\n", path.c_str() ); 519 return false; 520 } 521 } 522 } 523 524 // come up with an unique file name for the current settings 525 char* configId; 526 asprintf(&configId, "%08x", BeBoB::AvDevice::getConfigurationId() ); 527 if ( !configId ) { 528 debugError( "Could not create id string\n" ); 529 return false; 530 } 531 string filename = path + "/" + configId + ".xml"; 532 free( configId ); 533 debugOutput( DEBUG_LEVEL_NORMAL, "filename %s\n", filename.c_str() ); 534 535 Util::XMLSerialize ser( filename ); 536 return serialize( "", ser ); 519 537 } 520 538 trunk/libffado/src/genericavc/avc_vendormodel.cpp
r607 r620 23 23 24 24 #include "genericavc/avc_vendormodel.h" 25 #include "libutil/serialize.h" 25 26 26 27 #include <fstream> … … 34 35 using namespace std; 35 36 36 static void37 tokenize(const string& str,38 vector<string>& tokens,39 const string& delimiters = " ")40 {41 // Skip delimiters at beginning.42 string::size_type lastPos = str.find_first_not_of(delimiters, 0);43 // Find first "non-delimiter".44 string::size_type pos = str.find_first_of(delimiters, lastPos);45 46 while (string::npos != pos || string::npos != lastPos)47 {48 // Found a token, add it to the vector.49 tokens.push_back(str.substr(lastPos, pos - lastPos));50 // Skip delimiters. Note the "not_of"51 lastPos = str.find_first_not_of(delimiters, pos);52 // Find next "non-delimiter"53 pos = str.find_first_of(delimiters, lastPos);54 }55 }56 57 //-------------------------------------------------58 59 37 GenericAVC::VendorModelEntry::VendorModelEntry() 60 38 : vendor_id( 0 ) … … 89 67 { 90 68 bool equal=true; 91 69 92 70 equal &= (vendor_id == rhs.vendor_id); 93 71 equal &= (model_id == rhs.model_id); … … 216 194 if ( it != m_vendorModelEntries.end() ) 217 195 return *it; 218 196 219 197 struct VendorModelEntry invalid; 220 198 return invalid; trunk/libffado/src/libutil/serialize.cpp
r516 r620 26 26 using namespace std; 27 27 28 void tokenize(const string& str,29 vector<string>& tokens,30 const string& delimiters = " ")31 {32 // Skip delimiters at beginning.33 string::size_type lastPos = str.find_first_not_of(delimiters, 0);34 // Find first "non-delimiter".35 string::size_type pos = str.find_first_of(delimiters, lastPos);36 37 while (string::npos != pos || string::npos != lastPos) {38 // Found a token, add it to the vector.39 tokens.push_back(str.substr(lastPos, pos - lastPos));40 // Skip delimiters. Note the "not_of"41 lastPos = str.find_first_not_of(delimiters, pos);42 // Find next "non-delimiter"43 pos = str.find_first_of(delimiters, lastPos);44 }45 }46 47 /////////////////////////////////48 28 49 29 IMPL_DEBUG_MODULE( Util::XMLSerialize, XMLSerialize, DEBUG_LEVEL_NORMAL ); … … 302 282 return nodeSet.size() > 0; 303 283 } 284 285 void 286 tokenize(const string& str, 287 vector<string>& tokens, 288 const string& delimiters) 289 { 290 // Skip delimiters at beginning. 291 string::size_type lastPos = str.find_first_not_of(delimiters, 0); 292 // Find first "non-delimiter". 293 string::size_type pos = str.find_first_of(delimiters, lastPos); 294 295 while (string::npos != pos || string::npos != lastPos) 296 { 297 // Found a token, add it to the vector. 298 tokens.push_back(str.substr(lastPos, pos - lastPos)); 299 // Skip delimiters. Note the "not_of" 300 lastPos = str.find_first_not_of(delimiters, pos); 301 // Find next "non-delimiter" 302 pos = str.find_first_of(delimiters, lastPos); 303 } 304 } trunk/libffado/src/libutil/serialize.h
r516 r620 122 122 } 123 123 124 void tokenize(const std::string& str, std::vector<std::string>& tokens, const std::string& delimiters = " "); 125 124 126 #endif