- Timestamp:
- Feb 22, 2006, 8:40:36 AM (17 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Gnuplot.cc
r64 r70 4 4 5 5 #include <cstdio> 6 #include <string> 6 7 #include <unistd.h> 7 #include <string>8 8 9 #include <iostream>10 9 11 10 namespace theplu { -
trunk/lib/Gnuplot.h
r65 r70 27 27 /// communication with the binary. 28 28 /// 29 /// Temporary files are created in directory /tmp. These temporar u29 /// Temporary files are created in directory /tmp. These temporary 30 30 /// files are removed on a normal program exit. 31 31 /// … … 143 143 assert(plotcmd=="plot" || plotcmd=="replot"); 144 144 char name[]="/tmp/svnstatXXXXXX"; 145 if (mkstemp(name) == -1){ 145 int fd=mkstemp(name); // mkstemp return a file descriptor 146 if (fd == -1) 146 147 throw GnuplotException(std::string("Failed to get unique filename: ") + 147 148 name); 148 } 149 // Jari would like to do something like 'std::ofstream tmp(fd);' 150 // but has to settle for (which is stupid since the file is 151 // already open for writing. 149 152 std::ofstream tmp(name); 150 if (tmp.bad()) 151 throw GnuplotException(std::string("Failed to create file: ") + name); 152 153 for (size_t i = 0; i<y.size() && (i<x.size() || x.empty()); ++i ){ 153 for (size_t i = 0; i<y.size() && (i<x.size() || x.empty()); ++i ) 154 154 if (x.empty()) 155 155 tmp << y[i] << '\n'; 156 156 else 157 157 tmp << x[i] << '\t' << y[i] << '\n'; 158 } 158 // Jari, here the stupidity goes beyond everything - the 159 // ofstream must be closed as well as the file descriptor. If 160 // not the program will exhaust the availabe number of 161 // simultaneous open files. 159 162 tmp.close(); 163 close(fd); 164 160 165 std::string cmdstring(plotcmd + " '" + name + "' u 1:2 title '" + 161 166 linetitle_ + "' with " + linestyle_ + "\n");
Note: See TracChangeset
for help on using the changeset viewer.