Changeset 924
- Timestamp:
- 08/05/08 15:41:53
- Files:
-
- trunk/include/vpb/FileUtils (modified) (2 diffs)
- trunk/src/vpb/DataSet.cpp (modified) (4 diffs)
- trunk/src/vpb/DatabaseBuilderIO.cpp (modified) (1 diff)
- trunk/src/vpb/FileUtils.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/vpb/FileUtils
r903 r924 50 50 #endif 51 51 52 #include <string> 53 52 54 namespace vpb 53 55 { … … 75 77 extern VPB_EXPORT int mkpath(const char *path, int mode); 76 78 79 extern VPB_EXPORT bool hasWritePermission(const std::string& filename); 80 77 81 }; trunk/src/vpb/DataSet.cpp
r908 r924 1476 1476 1477 1477 if (_archive.valid()) _archive->writeNode(node,filename); 1478 else osgDB::writeNodeFile(node, filename); 1478 else 1479 { 1480 if (vpb::hasWritePermission(filename)) 1481 { 1482 osgDB::ReaderWriter::WriteResult result = 1483 osgDB::Registry::instance()->writeNode(node, filename,osgDB::Registry::instance()->getOptions()); 1484 1485 if (!result.success()) 1486 { 1487 log(osg::WARN, "Error: error occurred when writing out file %s",filename.c_str()); 1488 } 1489 } 1490 else 1491 { 1492 log(osg::WARN, "Error: do not have write permission to write out file %s",filename.c_str()); 1493 } 1494 } 1479 1495 } 1480 1496 … … 1484 1500 1485 1501 if (_archive.valid()) _archive->writeImage(image,filename); 1486 else osgDB::writeImageFile(image, filename); 1502 else 1503 { 1504 if (vpb::hasWritePermission(filename)) 1505 { 1506 osgDB::ReaderWriter::WriteResult result = 1507 osgDB::Registry::instance()->writeImage(image, filename,osgDB::Registry::instance()->getOptions()); 1508 1509 if (!result.success()) 1510 { 1511 log(osg::WARN, "Error: error occurred when writing out file %s",filename.c_str()); 1512 } 1513 } 1514 else 1515 { 1516 log(osg::WARN, "Error: do not have write permission to write out file %s",filename.c_str()); 1517 } 1518 } 1487 1519 } 1488 1520 … … 2879 2911 if (result) 2880 2912 { 2881 log(osg::NOTICE,"Error: could not create directory %i",errno);2913 log(osg::NOTICE,"Error: could not create directory, errorno=%i",errno); 2882 2914 return 1; 2883 2915 } … … 2907 2939 if (result) 2908 2940 { 2909 log(osg::NOTICE,"Error: could not create directory %i",errno);2941 log(osg::NOTICE,"Error: could not create directory, errorno=%i",errno); 2910 2942 return 1; 2911 2943 } trunk/src/vpb/DatabaseBuilderIO.cpp
r694 r924 90 90 { 91 91 public: 92 93 VPBReaderWriter() 94 { 95 supportsExtension("vpb","VirtualPlanetBuilder source format"); 96 supportsExtension("source","VirtualPlanetBuilder source format"); 97 } 98 92 99 virtual const char* className() const { return "VPB Reader/Writer"; } 93 100 trunk/src/vpb/FileUtils.cpp
r920 r924 2 2 #include <vpb/BuildLog> 3 3 #include <osgDB/FileUtils> 4 #include <osgDB/FileNameUtils> 4 5 5 6 #ifdef WIN32 … … 138 139 139 140 } 141 142 bool vpb::hasWritePermission(const std::string& filename) 143 { 144 log(osg::NOTICE,"vpb::access(%s, W_OK)=%i",filename.c_str(), vpb::access(filename.c_str(), W_OK)); 145 146 if (vpb::access(filename.c_str(), W_OK)==0) return true; 147 148 std::string path = osgDB::getFilePath(filename); 149 if (path.empty()) path = "."; 150 151 log(osg::NOTICE,"vpb::access(%s, W_OK)=%i",path.c_str(), vpb::access(path.c_str(), W_OK)); 152 153 return (vpb::access(path.c_str(), W_OK)==0); 154 } 155
