1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "next_filename.h"
- #include "STR.h"
- #include "file_exists.h"
- #include <cmath>
- #include <iomanip>
- bool igl::next_filename(
- const std::string & prefix,
- const int zeros,
- const std::string & suffix,
- std::string & next)
- {
- using namespace std;
-
-
- int i = 0;
- while(true)
- {
- next = STR(prefix << setfill('0') << setw(zeros)<<i<<suffix);
- if(!file_exists(next))
- {
- return true;
- }
- i++;
- if(zeros > 0 && i >= pow(10,zeros))
- {
- return false;
- }
- }
- }
|