Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Ghislain Fourny
Approved revision: 11247
Merged at revision: 11514
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 209 lines (+44/-36)
8 files modified
include/zorba/util/fs_util.h (+7/-3)
modules/org/expath/ns/file.xq.src/file.cpp (+1/-1)
src/diagnostics/diagnostic_en.xml (+5/-5)
src/diagnostics/dict_XX_cpp.xq (+3/-16)
src/diagnostics/pregenerated/dict_en.cpp (+3/-3)
src/diagnostics/pregenerated/dict_zed_keys.h (+2/-2)
src/util/error_util.cpp (+2/-2)
src/util/fs_util.cpp (+21/-4)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Ghislain Fourny Approve
Paul J. Lucas Approve
Review via email: mp+169270@code.launchpad.net

Commit message

file:create-directory() now creates intermediate directories.
(Also fixed error messages off-by-one bug in error_util.)

Description of the change

file:create-directory() now creates intermediate directories.
(Also fixed error messages off-by-one bug in error_util.)

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Ghislain Fourny (gislenius) wrote :

It works, thanks!

review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job pjl-misc-2013-06-14T10-24-56.613Z 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
=== modified file 'include/zorba/util/fs_util.h'
--- include/zorba/util/fs_util.h 2013-06-11 01:26:43 +0000
+++ include/zorba/util/fs_util.h 2013-06-13 18:26:28 +0000
@@ -124,22 +124,26 @@
124 * Creates a directory.124 * Creates a directory.
125 *125 *
126 * @param path The full path of the directory to create.126 * @param path The full path of the directory to create.
127 * @param intermediate If \c true, any non-existent directories along \a path
128 * are also created.
127 * @throws fs::exception if the creation fails.129 * @throws fs::exception if the creation fails.
128 */130 */
129ZORBA_DLL_PUBLIC131ZORBA_DLL_PUBLIC
130void mkdir( char const *path );132void mkdir( char const *path, bool intermediate = false );
131133
132/**134/**
133 * Creates a directory.135 * Creates a directory.
134 *136 *
135 * @tparam PathStringType The \a path string type.137 * @tparam PathStringType The \a path string type.
136 * @param path The full path of the directory to create.138 * @param path The full path of the directory to create.
139 * @param intermediate If \c true, any non-existent directories along \a path
140 * are also created.
137 * @throws fs::exception if the creation fails.141 * @throws fs::exception if the creation fails.
138 */142 */
139template<class PathStringType> inline143template<class PathStringType> inline
140typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type144typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type
141mkdir( PathStringType const &path ) {145mkdir( PathStringType const &path, bool intermediate = false ) {
142 mkdir( path.c_str() );146 mkdir( path.c_str(), intermediate );
143}147}
144148
145#endif /* ZORBA_WITH_FILE_ACCESS */149#endif /* ZORBA_WITH_FILE_ACCESS */
146150
=== modified file 'modules/org/expath/ns/file.xq.src/file.cpp'
--- modules/org/expath/ns/file.xq.src/file.cpp 2013-06-13 14:10:48 +0000
+++ modules/org/expath/ns/file.xq.src/file.cpp 2013-06-13 18:26:28 +0000
@@ -78,7 +78,7 @@
78 fs::type const fs_type = fs::get_type( path );78 fs::type const fs_type = fs::get_type( path );
79 if ( !fs_type )79 if ( !fs_type )
80 try {80 try {
81 fs::mkdir( path );81 fs::mkdir( path, true );
82 }82 }
83 catch ( std::exception const &e ) {83 catch ( std::exception const &e ) {
84 throw raiseFileError( "FOFL9999", e.what(), path );84 throw raiseFileError( "FOFL9999", e.what(), path );
8585
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2013-06-04 14:09:51 +0000
+++ src/diagnostics/diagnostic_en.xml 2013-06-13 18:26:28 +0000
@@ -3718,7 +3718,7 @@
3718 </entry>3718 </entry>
37193719
3720 <entry key="ErrorCodeMessage_12">3720 <entry key="ErrorCodeMessage_12">
3721 <value>error $2: $3</value>3721 <value>error $1: $2</value>
3722 </entry>3722 </entry>
37233723
3724 <entry key="ExpectedNumericOrDurationType">3724 <entry key="ExpectedNumericOrDurationType">
@@ -3765,12 +3765,12 @@
3765 <value>full-text was not enabled in this build</value>3765 <value>full-text was not enabled in this build</value>
3766 </entry>3766 </entry>
37673767
3768 <entry key="FunctionFailedErrorCodeMessage_234">3768 <entry key="FunctionFailedErrorCodeMessage_123">
3769 <value>$2 failed (error $3): $4</value>3769 <value>$1 failed (error $2): $3</value>
3770 </entry>3770 </entry>
37713771
3772 <entry key="FunctionFailed_23o">3772 <entry key="FunctionFailed_12o">
3773 <value>$2 failed${: 3}</value>3773 <value>$1 failed${: 2}</value>
3774 </entry>3774 </entry>
37753775
3776 <entry key="FunctionUndeclared_3">3776 <entry key="FunctionUndeclared_3">
37773777
=== modified file 'src/diagnostics/dict_XX_cpp.xq'
--- src/diagnostics/dict_XX_cpp.xq 2013-02-07 17:24:36 +0000
+++ src/diagnostics/dict_XX_cpp.xq 2013-06-13 18:26:28 +0000
@@ -25,22 +25,9 @@
25 return $entry/@code25 return $entry/@code
26 case $e as element(entry)26 case $e as element(entry)
27 return27 return
28 (28 if ( $e/parent::diagnostic )
29 (: raise an error if sub-message contains $1 as parameter :)29 then concat( "~", $e/parent::diagnostic/@code, "_", $entry/@key )
30 if ( contains ( $e/value, "$1" ) )30 else concat( "~", $entry/@key )
31 then
32 error(
33 fn:QName("http://www.zorba-xquery.com/error", "submessage"),
34 concat(
35 "sub-entry must not contain parameter named $1: ", $e/value
36 )
37 )
38 else
39 (),
40 if ( $e/parent::diagnostic )
41 then concat( "~", $e/parent::diagnostic/@code, "_", $entry/@key )
42 else concat( "~", $entry/@key )
43 )
44 default31 default
45 return error()32 return error()
46 let $value := replace( replace( $entry/value, '\\', '\\\\' ), '"', '\\"' )33 let $value := replace( replace( $entry/value, '\\', '\\\\' ), '"', '\\"' )
4734
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2013-06-04 14:09:51 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2013-06-13 18:26:28 +0000
@@ -620,7 +620,7 @@
620 { "~EmptySeqNoFnRemoveArg", "empty sequence not allowed as 2nd argument of fn:remove()" },620 { "~EmptySeqNoFnRemoveArg", "empty sequence not allowed as 2nd argument of fn:remove()" },
621 { "~EmptySeqNoSearchItem", "empty sequence not allowed as search item of fn:index-of()" },621 { "~EmptySeqNoSearchItem", "empty sequence not allowed as search item of fn:index-of()" },
622 { "~EmptySequence", "empty sequence" },622 { "~EmptySequence", "empty sequence" },
623 { "~ErrorCodeMessage_12", "error $2: $3" },623 { "~ErrorCodeMessage_12", "error $1: $2" },
624 { "~ExpectedNumericOrDurationType", "expected numeric or duration type" },624 { "~ExpectedNumericOrDurationType", "expected numeric or duration type" },
625 { "~ExpectedNumericType", "expected numeric type" },625 { "~ExpectedNumericType", "expected numeric type" },
626 { "~ExpectedType_5", "expected type \"$5\"" },626 { "~ExpectedType_5", "expected type \"$5\"" },
@@ -681,8 +681,8 @@
681 { "~FnNilledArgNotNode", "fn:nilled() argument not a node" },681 { "~FnNilledArgNotNode", "fn:nilled() argument not a node" },
682 { "~FnOnlyInXQueryVersion_3", "function only available in XQuery $3" },682 { "~FnOnlyInXQueryVersion_3", "function only available in XQuery $3" },
683 { "~FullTextNotEnabled", "full-text was not enabled in this build" },683 { "~FullTextNotEnabled", "full-text was not enabled in this build" },
684 { "~FunctionFailedErrorCodeMessage_234", "$2 failed (error $3): $4" },684 { "~FunctionFailedErrorCodeMessage_123", "$1 failed (error $2): $3" },
685 { "~FunctionFailed_23o", "$2 failed${: 3}" },685 { "~FunctionFailed_12o", "$1 failed${: 2}" },
686 { "~FunctionUndeclared_3", "function with arity $3 not declared" },686 { "~FunctionUndeclared_3", "function with arity $3 not declared" },
687 { "~GoodValuesAreUTF8", "valid values are: UTF-8, UTF-16" },687 { "~GoodValuesAreUTF8", "valid values are: UTF-8, UTF-16" },
688 { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" },688 { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" },
689689
=== modified file 'src/diagnostics/pregenerated/dict_zed_keys.h'
--- src/diagnostics/pregenerated/dict_zed_keys.h 2013-05-31 23:44:41 +0000
+++ src/diagnostics/pregenerated/dict_zed_keys.h 2013-06-13 18:26:28 +0000
@@ -245,8 +245,8 @@
245#define ZED_FnNilledArgNotNode "~FnNilledArgNotNode"245#define ZED_FnNilledArgNotNode "~FnNilledArgNotNode"
246#define ZED_FnOnlyInXQueryVersion_3 "~FnOnlyInXQueryVersion_3"246#define ZED_FnOnlyInXQueryVersion_3 "~FnOnlyInXQueryVersion_3"
247#define ZED_FullTextNotEnabled "~FullTextNotEnabled"247#define ZED_FullTextNotEnabled "~FullTextNotEnabled"
248#define ZED_FunctionFailedErrorCodeMessage_234 "~FunctionFailedErrorCodeMessage_234"248#define ZED_FunctionFailedErrorCodeMessage_123 "~FunctionFailedErrorCodeMessage_123"
249#define ZED_FunctionFailed_23o "~FunctionFailed_23o"249#define ZED_FunctionFailed_12o "~FunctionFailed_12o"
250#define ZED_FunctionUndeclared_3 "~FunctionUndeclared_3"250#define ZED_FunctionUndeclared_3 "~FunctionUndeclared_3"
251#define ZED_GoodValuesAreUTF8 "~GoodValuesAreUTF8"251#define ZED_GoodValuesAreUTF8 "~GoodValuesAreUTF8"
252#define ZED_GoodValuesAreXMLEtc "~GoodValuesAreXMLEtc"252#define ZED_GoodValuesAreXMLEtc "~GoodValuesAreXMLEtc"
253253
=== modified file 'src/util/error_util.cpp'
--- src/util/error_util.cpp 2013-05-31 14:36:28 +0000
+++ src/util/error_util.cpp 2013-06-13 18:26:28 +0000
@@ -67,7 +67,7 @@
67 if ( function && *function ) {67 if ( function && *function ) {
68 using namespace internal::diagnostic;68 using namespace internal::diagnostic;
69 parameters::value_type result =69 parameters::value_type result =
70 diagnostic::dict::lookup( ZED( FunctionFailed_23o ) );70 diagnostic::dict::lookup( ZED( FunctionFailed_12o ) );
71 parameters const params( ERROR_PARAMS( function, err_string ) );71 parameters const params( ERROR_PARAMS( function, err_string ) );
72 params.substitute( &result );72 params.substitute( &result );
73 return result;73 return result;
@@ -82,7 +82,7 @@
82 parameters::value_type result;82 parameters::value_type result;
83 if ( function && *function ) {83 if ( function && *function ) {
84 result = diagnostic::dict::lookup(84 result = diagnostic::dict::lookup(
85 ZED( FunctionFailedErrorCodeMessage_234 )85 ZED( FunctionFailedErrorCodeMessage_123 )
86 );86 );
87 params = ERROR_PARAMS( function, code, err_string );87 params = ERROR_PARAMS( function, code, err_string );
88 } else {88 } else {
8989
=== modified file 'src/util/fs_util.cpp'
--- src/util/fs_util.cpp 2013-06-11 01:33:32 +0000
+++ src/util/fs_util.cpp 2013-06-13 18:26:28 +0000
@@ -382,16 +382,33 @@
382382
383#ifdef ZORBA_WITH_FILE_ACCESS383#ifdef ZORBA_WITH_FILE_ACCESS
384384
385void mkdir( char const *path ) {385void mkdir_impl( char const *path, bool ignore_exists = false ) {
386#ifndef WIN32386#ifndef WIN32
387 if ( ::mkdir( path, 0755 ) != 0 )387 if ( ::mkdir( path, 0755 ) != 0 &&
388 !(ignore_exists && (errno == EEXIST || errno == EISDIR)) ) {
388 throw fs::exception( "mkdir()", path );389 throw fs::exception( "mkdir()", path );
390 }
389#else391#else
390 WCHAR wpath[ MAX_PATH ];392 WCHAR wpath[ MAX_PATH ];
391 win32::to_wchar( path, wpath );393 win32::to_wchar( path, wpath );
392 if ( !::CreateDirectory( wpath, NULL ) )394 if ( !::CreateDirectory( wpath, NULL ) &&
395 !(ignore_exists && ::GetLastError() == ERROR_ALREADY_EXISTS) ) {
393 throw fs::exception( "CreateDirectory()", path );396 throw fs::exception( "CreateDirectory()", path );
394#endif397 }
398#endif /* WIN32 */
399}
400
401void mkdir( char const *path, bool intermediate ) {
402 if ( !intermediate )
403 mkdir_impl( path );
404 else {
405 string const dir( dir_name( path ) );
406 if ( dir != path )
407 mkdir( dir, true );
408 else
409 mkdir_impl( dir.c_str(), true );
410 mkdir_impl( path, true );
411 }
395}412}
396413
397string normalize_path( char const *path, char const *base ) {414string normalize_path( char const *path, char const *base ) {

Subscribers

People subscribed via source and target branches