Changeset 2972 for trunk/packages/vizservers/nanovis/R2
- Timestamp:
- Apr 16, 2012 12:14:03 PM (12 years ago)
- Location:
- trunk/packages/vizservers/nanovis/R2
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/R2/include/R2/R2FilePath.h
r2877 r2972 4 4 5 5 #include <list> 6 7 #include <R2/R2string.h> 6 #include <string> 8 7 9 8 class R2FilePath … … 17 16 * @return return full path of the file, but if not found, return "" 18 17 */ 19 const char *getPath(const char *fileName);18 std::string getPath(const char *fileName); 20 19 21 20 /** … … 31 30 32 31 private: 33 typedef std::list< R2string> R2stringList;34 typedef std::list< R2string>::iterator R2stringListIter;32 typedef std::list<std::string> StringList; 33 typedef std::list<std::string>::iterator StringListIter; 35 34 36 35 /// application directory 37 static R2string _curDirectory;36 static std::string _curDirectory; 38 37 39 38 /// R2FilePath instance … … 41 40 42 41 /// all default file paths 43 R2stringList _pathList;42 StringList _pathList; 44 43 }; 45 44 -
trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h
r2841 r2972 4 4 5 5 #include <vector> 6 #include <string> 6 7 7 8 #include <R2/R2.h> 8 9 #include <R2/R2Object.h> 9 #include <R2/R2string.h>10 10 11 11 class R2Fonts : public R2Object 12 12 { 13 13 struct R2FontAttributes { 14 char *_fontName;14 std::string _fontName; 15 15 int _textureWidth; 16 16 int _textureHeight; … … 29 29 R2CharInfo _chars[256]; 30 30 }; 31 31 32 32 typedef std::vector<R2FontAttributes> R2FontVector; 33 33 -
trunk/packages/vizservers/nanovis/R2/src/Makefile.in
r2896 r2972 44 44 R2IndexBuffer.o \ 45 45 R2Object.o \ 46 R2VertexBuffer.o \ 47 R2string.o 46 R2VertexBuffer.o 48 47 49 48 R2LIB = R2.a -
trunk/packages/vizservers/nanovis/R2/src/R2FilePath.cpp
r2857 r2972 13 13 #include "Trace.h" 14 14 15 R2string R2FilePath::_curDirectory;15 std::string R2FilePath::_curDirectory; 16 16 R2FilePath R2FilePath::_instance; 17 17 18 char seps[] = ":";18 static char seps[] = ":"; 19 19 20 20 R2FilePath::R2FilePath() … … 22 22 char buff[BUFSIZ+2]; 23 23 #ifdef _WIN32 24 _getcwd(buff, 255);24 _getcwd(buff, sizeof(buff)-1); 25 25 #else 26 if (getcwd(buff, BUFSIZ) == NULL) {26 if (getcwd(buff, sizeof(buff)-1) == NULL) { 27 27 ERROR("can't get current working directory\n"); 28 28 } … … 37 37 R2FilePath::setPath(const char *filePath) 38 38 { 39 char buff[25 5];39 char buff[256]; 40 40 41 41 if (filePath == NULL) { … … 55 55 if (*p == '/') { 56 56 if (*last == '/' || *last == '\\') { 57 _pathList.push_back( R2string(p));57 _pathList.push_back(std::string(p)); 58 58 } else { 59 _pathList.push_back( R2string(p) + "/");59 _pathList.push_back(std::string(p) + "/"); 60 60 } 61 61 } else { 62 62 if (*last == '/' || *last == '\\') { 63 _pathList.push_back(_curDirectory + R2string(p));63 _pathList.push_back(_curDirectory + std::string(p)); 64 64 } else { 65 _pathList.push_back(_curDirectory + R2string(p) + "/");65 _pathList.push_back(_curDirectory + std::string(p) + "/"); 66 66 } 67 67 } … … 76 76 } 77 77 78 const char * 78 std::string 79 79 R2FilePath::getPath(const char* fileName) 80 80 { 81 R2string path;81 std::string path; 82 82 83 R2stringListIter iter; 84 int nameLength = strlen(fileName); 85 for (iter = _pathList.begin(); iter != _pathList.end(); ++iter) { 86 char *path; 83 for (StringListIter iter = _pathList.begin(); 84 iter != _pathList.end(); ++iter) { 85 path = *iter + std::string(fileName); 87 86 88 path = new char[strlen((char *)(*iter)) + 1 + nameLength + 1]; 89 //sprintf(path, "%s/%s", (char *)(*iter), fileName); 90 sprintf(path, "%s%s", (char *)(*iter), fileName); 91 if (access(path, R_OK) == 0) { 87 if (access(path.c_str(), R_OK) == 0) { 92 88 return path; 89 } else { 90 path = ""; 93 91 } 94 delete [] path;95 92 } 96 return NULL;93 return path; 97 94 } 98 95 99 96 void 100 R2FilePath::setWorkingDirectory(int argc, const char **argv)97 R2FilePath::setWorkingDirectory(int argc, const char **argv) 101 98 { 102 char buff[25 5];99 char buff[256]; 103 100 104 101 strcpy(buff, argv[0]); 105 102 for (int i = strlen(buff) - 1; i >= 0; --i) { 106 103 if (buff[i] == '\\' || buff[i] == '/') { 107 buff[i] = '/'; 108 buff[i + 1] = '\0'; 104 buff[i] = '/'; 105 buff[i + 1] = '\0'; 109 106 break; 110 107 } -
trunk/packages/vizservers/nanovis/R2/src/R2Fonts.cpp
r2953 r2972 34 34 unsigned int i; 35 35 for (i = 0; i < _fonts.size(); ++i) { 36 if (strcmp(_fonts[i]._fontName , fontName) == 0) {36 if (strcmp(_fonts[i]._fontName.c_str(), fontName) == 0) { 37 37 _fontIndex = i; 38 38 break; … … 142 142 bool bSuccess = false; 143 143 144 const char *path = R2FilePath::getInstance()->getPath(fontFileName);145 if (path == NULL) {144 std::string path = R2FilePath::getInstance()->getPath(fontFileName); 145 if (path.empty()) { 146 146 return false; 147 147 } 148 std::ifstream fsInput(path , std::ios::binary);148 std::ifstream fsInput(path.c_str(), std::ios::binary); 149 149 if (fsInput) { 150 sFont._fontName = new char [strlen(fontName)+1]; 151 strcpy(sFont._fontName, fontName); 150 sFont._fontName = fontName; 152 151 153 152 // make sure this file is the correct type by checking the header … … 230 229 fsInput.close(); 231 230 } 232 delete [] path;233 231 return bSuccess; 234 232 }
Note: See TracChangeset
for help on using the changeset viewer.