Changeset 2408
- Timestamp:
- Aug 24, 2011, 7:01:44 PM (13 years ago)
- Location:
- trunk/src/core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpBuffer.cc
r1527 r2408 172 172 FILE *f; 173 173 f = fopen(filePath, "wb"); 174 if (f != NULL) {174 if (f == NULL) { 175 175 status.addError("can't open \"%s\": %s\n", filePath, strerror(errno)); 176 176 return false; -
trunk/src/core/RpLibrary.cc
r1707 r2408 1735 1735 1736 1736 /**********************************************************************/ 1737 // METHOD: getFile() 1738 /// Get the value at path and write it to the file at fileName 1739 /** 1740 * Return the number of bytes written 1741 */ 1742 1743 size_t 1744 RpLibrary::getFile (std::string path, std::string fileName) const 1745 { 1746 Rappture::Buffer buf; 1747 1748 buf = getData(path); 1749 1750 if (buf.bad()) { 1751 status.addContext("RpLibrary::getFile()"); 1752 return 0; 1753 } 1754 1755 if (!buf.dump(status, fileName.c_str())) { 1756 status.addContext("RpLibrary::getFile()"); 1757 return 0; 1758 } 1759 1760 return buf.size(); 1761 } 1762 1763 1764 /**********************************************************************/ 1737 1765 // METHOD: put() 1738 1766 /// Put a string value into the xml. … … 1813 1841 // library doesn't exist, do nothing; 1814 1842 status.error("invalid library object"); 1815 status.addContext("RpLibrary::put() ");1843 status.addContext("RpLibrary::put() - putDouble"); 1816 1844 return *this; 1817 1845 } … … 1820 1848 1821 1849 put(path,valStr.str(),id,append); 1822 status.addContext("RpLibrary::put() - putDouble");1823 1850 return *this; 1824 1851 } … … 2007 2034 Rappture::Buffer buf; 2008 2035 Rappture::Buffer fileBuf; 2009 Rappture::Outcome err;2010 2036 2011 2037 if (!this->root) { … … 2014 2040 } 2015 2041 2016 if (!fileBuf.load(err, fileName.c_str())) { 2017 fprintf(stderr, "error loading file: %s\n", err.remark()); 2042 if (!fileBuf.load(status, fileName.c_str())) { 2043 fprintf(stderr, "error loading file: %s\n", status.remark()); 2044 status.addContext("RpLibrary::putFile()"); 2018 2045 return *this; 2019 2046 } … … 2025 2052 put(path, fileBuf.bytes(), "", append, RPLIB_TRANSLATE); 2026 2053 } 2027 status.addContext("RpLibrary::putFile()");2028 2054 return *this; 2029 2055 } -
trunk/src/core/RpLibrary.h
r1041 r2408 81 81 bool getBool ( std::string path = "") const; 82 82 Rappture::Buffer getData ( std::string path = "") const; 83 size_t getFile ( std::string path, 84 std::string fileName) const; 83 85 84 86 /* -
trunk/src/core/RpLibraryFInterface.cc
r1105 r2408 605 605 606 606 /**********************************************************************/ 607 // FUNCTION: rp_lib_get_file() 608 /// Get data located at 'path' and write it to the file 'fileName'. 609 /** 610 * Returns if any bytes were written to the file 611 */ 612 int rp_lib_get_file ( int* handle, /* integer handle of library */ 613 char* path, /* null terminated path */ 614 char* fileName, /* name of file to write data to */ 615 int path_len, /* length of the path variable */ 616 int fileName_len /* length of the fileName variable */ 617 ) 618 { 619 size_t nbytes = 0; 620 int ret = 0; 621 622 RpLibrary* lib = NULL; 623 624 std::string inPath = ""; 625 std::string filePath = ""; 626 627 inPath = null_terminate_str(path,path_len); 628 filePath = null_terminate_str(fileName,fileName_len); 629 630 if ((handle) && (*handle != 0)) { 631 lib = (RpLibrary*) getObject_Void(*handle); 632 633 if (lib) { 634 nbytes = lib->getFile(inPath, filePath); 635 } 636 } 637 638 if (nbytes > 0) { 639 ret = 1; 640 } 641 642 return ret; 643 } 644 645 646 647 /**********************************************************************/ 607 648 // FUNCTION: rp_lib_put_str() 608 649 /// Put string into Rappture Library Object at location 'path'. -
trunk/src/core/RpLibraryFInterface.h
r1086 r2408 78 78 char* path, 79 79 int path_len); 80 81 int rp_lib_get_file ( int* handle, 82 char* path, 83 char* fileName, 84 int path_len, 85 int fileName_len); 80 86 81 87 void rp_lib_put_str ( int* handle, -
trunk/src/core/RpLibraryFStubs.c
r1018 r2408 340 340 } 341 341 342 int rp_lib_get_file_ ( int* handle, 343 char* path, 344 char* fileName, 345 int path_len, 346 int fileName_len) { 347 348 return rp_lib_get_file(handle,path,fileName,path_len,fileName_len); 349 } 350 351 int rp_lib_get_file__ ( int* handle, 352 char* path, 353 char* fileName, 354 int path_len, 355 int fileName_len) { 356 357 return rp_lib_get_file(handle,path,fileName,path_len,fileName_len); 358 } 359 360 int RP_LIB_GET_FILE ( int* handle, 361 char* path, 362 char* fileName, 363 int path_len, 364 int fileName_len) { 365 366 return rp_lib_get_file(handle,path,fileName,path_len,fileName_len); 367 } 368 342 369 void 343 370 rp_lib_put_str_ ( int* handle, … … 353 380 354 381 void 355 rp_lib_put_str__ ( 382 rp_lib_put_str__ ( int* handle, 356 383 char* path, 357 384 char* value, -
trunk/src/core/RpLibraryFStubs.h
r1018 r2408 82 82 int path_len); 83 83 84 int rp_lib_get_file_ ( int* handle, 85 char* path, 86 char* fileName, 87 int path_len, 88 int fileName_len); 89 84 90 void rp_lib_put_str_ ( int* handle, 85 91 char* path, … … 223 229 int path_len); 224 230 231 int rp_lib_get_file__ ( int* handle, 232 char* path, 233 char* fileName, 234 int path_len, 235 int fileName_len); 236 225 237 void rp_lib_put_str__ ( int* handle, 226 238 char* path, … … 365 377 int path_len); 366 378 379 int RP_LIB_GET_FILE ( int* handle, 380 char* path, 381 char* fileName, 382 int path_len, 383 int fileName_len); 384 367 385 void RP_LIB_PUT_STR ( int* handle, 368 386 char* path,
Note: See TracChangeset
for help on using the changeset viewer.