Merge lp:~zorba-coders/zorba/uuid-state-file into lp:zorba

Proposed by Matthias Brantner
Status: Merged
Approved by: Matthias Brantner
Approved revision: 10664
Merged at revision: 10665
Proposed branch: lp:~zorba-coders/zorba/uuid-state-file
Merge into: lp:zorba
Diff against target: 56 lines (+15/-4)
1 file modified
src/util/uuid/uuid.cpp (+15/-4)
To merge this branch: bzr merge lp:~zorba-coders/zorba/uuid-state-file
Reviewer Review Type Date Requested Status
Till Westmann Approve
Matthias Brantner Approve
Review via email: mp+93514@code.launchpad.net

Commit message

Put the state file written by the uuid functionality into the system's temp directory (temporary solution).

Description of the change

Put the state file written by the uuid functionality into the system's temp directory (temporary solution).

To post a comment you must log in.
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Till Westmann (tillw) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job uuid-state-file-2012-02-17T00-51-04.673Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/util/uuid/uuid.cpp'
2--- src/util/uuid/uuid.cpp 2011-10-04 12:15:31 +0000
3+++ src/util/uuid/uuid.cpp 2012-02-17 00:49:46 +0000
4@@ -21,6 +21,7 @@
5
6 #include "util/uuid/sysdep.h"
7 #include "util/uuid/uuid.h"
8+#include "util/fs_util.h"
9
10 namespace zorba {
11
12@@ -93,6 +94,16 @@
13
14 static uuid_state st;
15
16+zstring get_tmp_state_name()
17+{
18+ zstring lTmpFileName;
19+#ifdef ZORBA_WITH_FILE_ACCESS
20+ fs::get_temp_file<zstring>(&lTmpFileName);
21+ lTmpFileName = lTmpFileName.substr(0, lTmpFileName.find_last_of(fs::dir_separator) + 1);
22+#endif
23+ return lTmpFileName += "state";
24+}
25+
26 //read_state -- read UUID generator state from non-volatile store
27 int read_state(xs_short *clockseq, xs_unsignedLong *timestamp,
28 uuid_node_t *node)
29@@ -103,11 +114,11 @@
30 //only need to read state once per boot
31 if (!inited) {
32 #ifdef WIN32
33- errno_t err = fopen_s( &fp, "state", "rb");
34+ errno_t err = fopen_s( &fp, get_tmp_state_name().c_str(), "rb");
35 if ( err != 0)
36 return 0;
37 #else
38- fp = fopen("state", "rb");
39+ fp = fopen(get_tmp_state_name().c_str(), "rb");
40 if (fp == NULL)
41 return 0;
42 #endif
43@@ -143,11 +154,11 @@
44 st.node = node;
45 if (timestamp >= next_save) {
46 #ifdef WIN32
47- errno_t err = fopen_s( &fp, "state", "wb");
48+ errno_t err = fopen_s( &fp, get_tmp_state_name().c_str(), "wb");
49 if ( err != 0)
50 return ;
51 #else
52- fp = fopen("state", "wb");
53+ fp = fopen(get_tmp_state_name().c_str(), "wb");
54 if (fp == NULL)
55 return ;
56 #endif

Subscribers

People subscribed via source and target branches