diff options
Diffstat (limited to '')
-rw-r--r-- | src/stable/file.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/stable/file.cpp b/src/stable/file.cpp index 8d10596..81b476d 100644 --- a/src/stable/file.cpp +++ b/src/stable/file.cpp | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <fcntl.h> | 12 | #include <fcntl.h> |
13 | #include <unistd.h> | 13 | #include <unistd.h> |
14 | #include <time.h> | 14 | #include <time.h> |
15 | #include "bu/random.h" | ||
15 | 16 | ||
16 | #include "bu/config.h" | 17 | #include "bu/config.h" |
17 | 18 | ||
@@ -190,7 +191,6 @@ void Bu::File::setBlocking( bool bBlocking ) | |||
190 | Bu::File Bu::File::tempFile( Bu::String &sName ) | 191 | Bu::File Bu::File::tempFile( Bu::String &sName ) |
191 | { | 192 | { |
192 | uint32_t iX; | 193 | uint32_t iX; |
193 | iX = time( NULL ) + getpid(); | ||
194 | int iXes; | 194 | int iXes; |
195 | for( iXes = sName.getSize()-1; iXes >= 0; iXes-- ) | 195 | for( iXes = sName.getSize()-1; iXes >= 0; iXes-- ) |
196 | { | 196 | { |
@@ -200,11 +200,11 @@ Bu::File Bu::File::tempFile( Bu::String &sName ) | |||
200 | iXes++; | 200 | iXes++; |
201 | if( iXes == sName.getSize() ) | 201 | if( iXes == sName.getSize() ) |
202 | throw Bu::ExceptionBase("Invalid temporary filename template."); | 202 | throw Bu::ExceptionBase("Invalid temporary filename template."); |
203 | for( int iter = 0; iter < 100; iter++ ) | 203 | for( int iter = 0; iter < 1000; iter++ ) |
204 | { | 204 | { |
205 | for( int j = iXes; j < sName.getSize(); j++ ) | 205 | for( int j = iXes; j < sName.getSize(); j++ ) |
206 | { | 206 | { |
207 | iX = (1103515245 * iX + 12345); | 207 | uint32_t iX = Bu::Random::rand(); |
208 | sName[j] = ('A'+(iX%26)) | ((iX&0x1000)?(0x20):(0)); | 208 | sName[j] = ('A'+(iX%26)) | ((iX&0x1000)?(0x20):(0)); |
209 | } | 209 | } |
210 | 210 | ||
@@ -214,7 +214,7 @@ Bu::File Bu::File::tempFile( Bu::String &sName ) | |||
214 | |Bu::File::Create|Bu::File::Exclusive ); | 214 | |Bu::File::Create|Bu::File::Exclusive ); |
215 | } catch(...) { } | 215 | } catch(...) { } |
216 | } | 216 | } |
217 | throw Bu::FileException("Failed to create unique temporary file after 100" | 217 | throw Bu::FileException("Failed to create unique temporary file after 1000" |
218 | " iterations."); | 218 | " iterations."); |
219 | } | 219 | } |
220 | 220 | ||