Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.
Commit message: file:create-directory() now creates intermediate directories. (Also fixed error messages off-by-one bug in error_util.) Requested reviews: Paul J. Lucas (paul-lucas) For more details, see: https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/169270 file:create-directory() now creates intermediate directories. (Also fixed error messages off-by-one bug in error_util.) -- https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/169270 Your team Zorba Coders is subscribed to branch lp:zorba.
=== 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 @@ * Creates a directory. * * @param path The full path of the directory to create. + * @param intermediate If \c true, any non-existent directories along \a path + * are also created. * @throws fs::exception if the creation fails. */ ZORBA_DLL_PUBLIC -void mkdir( char const *path ); +void mkdir( char const *path, bool intermediate = false ); /** * Creates a directory. * * @tparam PathStringType The \a path string type. * @param path The full path of the directory to create. + * @param intermediate If \c true, any non-existent directories along \a path + * are also created. * @throws fs::exception if the creation fails. */ template<class PathStringType> inline typename std::enable_if<ZORBA_HAS_C_STR(PathStringType),void>::type -mkdir( PathStringType const &path ) { - mkdir( path.c_str() ); +mkdir( PathStringType const &path, bool intermediate = false ) { + mkdir( path.c_str(), intermediate ); } #endif /* ZORBA_WITH_FILE_ACCESS */ === 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 @@ fs::type const fs_type = fs::get_type( path ); if ( !fs_type ) try { - fs::mkdir( path ); + fs::mkdir( path, true ); } catch ( std::exception const &e ) { throw raiseFileError( "FOFL9999", e.what(), path ); === 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 @@ </entry> <entry key="ErrorCodeMessage_12"> - <value>error $2: $3</value> + <value>error $1: $2</value> </entry> <entry key="ExpectedNumericOrDurationType"> @@ -3765,12 +3765,12 @@ <value>full-text was not enabled in this build</value> </entry> - <entry key="FunctionFailedErrorCodeMessage_234"> - <value>$2 failed (error $3): $4</value> + <entry key="FunctionFailedErrorCodeMessage_123"> + <value>$1 failed (error $2): $3</value> </entry> - <entry key="FunctionFailed_23o"> - <value>$2 failed${: 3}</value> + <entry key="FunctionFailed_12o"> + <value>$1 failed${: 2}</value> </entry> <entry key="FunctionUndeclared_3"> === 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 @@ return $entry/@code case $e as element(entry) return - ( - (: raise an error if sub-message contains $1 as parameter :) - if ( contains ( $e/value, "$1" ) ) - then - error( - fn:QName("http://www.zorba-xquery.com/error", "submessage"), - concat( - "sub-entry must not contain parameter named $1: ", $e/value - ) - ) - else - (), - if ( $e/parent::diagnostic ) - then concat( "~", $e/parent::diagnostic/@code, "_", $entry/@key ) - else concat( "~", $entry/@key ) - ) + if ( $e/parent::diagnostic ) + then concat( "~", $e/parent::diagnostic/@code, "_", $entry/@key ) + else concat( "~", $entry/@key ) default return error() let $value := replace( replace( $entry/value, '\\', '\\\\' ), '"', '\\"' ) === 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 @@ { "~EmptySeqNoFnRemoveArg", "empty sequence not allowed as 2nd argument of fn:remove()" }, { "~EmptySeqNoSearchItem", "empty sequence not allowed as search item of fn:index-of()" }, { "~EmptySequence", "empty sequence" }, - { "~ErrorCodeMessage_12", "error $2: $3" }, + { "~ErrorCodeMessage_12", "error $1: $2" }, { "~ExpectedNumericOrDurationType", "expected numeric or duration type" }, { "~ExpectedNumericType", "expected numeric type" }, { "~ExpectedType_5", "expected type \"$5\"" }, @@ -681,8 +681,8 @@ { "~FnNilledArgNotNode", "fn:nilled() argument not a node" }, { "~FnOnlyInXQueryVersion_3", "function only available in XQuery $3" }, { "~FullTextNotEnabled", "full-text was not enabled in this build" }, - { "~FunctionFailedErrorCodeMessage_234", "$2 failed (error $3): $4" }, - { "~FunctionFailed_23o", "$2 failed${: 3}" }, + { "~FunctionFailedErrorCodeMessage_123", "$1 failed (error $2): $3" }, + { "~FunctionFailed_12o", "$1 failed${: 2}" }, { "~FunctionUndeclared_3", "function with arity $3 not declared" }, { "~GoodValuesAreUTF8", "valid values are: UTF-8, UTF-16" }, { "~GoodValuesAreXMLEtc", "valid values are: xml, html, xhtml, text, binary, json, jsoniq" }, === 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 @@ #define ZED_FnNilledArgNotNode "~FnNilledArgNotNode" #define ZED_FnOnlyInXQueryVersion_3 "~FnOnlyInXQueryVersion_3" #define ZED_FullTextNotEnabled "~FullTextNotEnabled" -#define ZED_FunctionFailedErrorCodeMessage_234 "~FunctionFailedErrorCodeMessage_234" -#define ZED_FunctionFailed_23o "~FunctionFailed_23o" +#define ZED_FunctionFailedErrorCodeMessage_123 "~FunctionFailedErrorCodeMessage_123" +#define ZED_FunctionFailed_12o "~FunctionFailed_12o" #define ZED_FunctionUndeclared_3 "~FunctionUndeclared_3" #define ZED_GoodValuesAreUTF8 "~GoodValuesAreUTF8" #define ZED_GoodValuesAreXMLEtc "~GoodValuesAreXMLEtc" === 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 @@ if ( function && *function ) { using namespace internal::diagnostic; parameters::value_type result = - diagnostic::dict::lookup( ZED( FunctionFailed_23o ) ); + diagnostic::dict::lookup( ZED( FunctionFailed_12o ) ); parameters const params( ERROR_PARAMS( function, err_string ) ); params.substitute( &result ); return result; @@ -82,7 +82,7 @@ parameters::value_type result; if ( function && *function ) { result = diagnostic::dict::lookup( - ZED( FunctionFailedErrorCodeMessage_234 ) + ZED( FunctionFailedErrorCodeMessage_123 ) ); params = ERROR_PARAMS( function, code, err_string ); } else { === 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 @@ #ifdef ZORBA_WITH_FILE_ACCESS -void mkdir( char const *path ) { +void mkdir_impl( char const *path, bool ignore_exists = false ) { #ifndef WIN32 - if ( ::mkdir( path, 0755 ) != 0 ) + if ( ::mkdir( path, 0755 ) != 0 && + !(ignore_exists && (errno == EEXIST || errno == EISDIR)) ) { throw fs::exception( "mkdir()", path ); + } #else WCHAR wpath[ MAX_PATH ]; win32::to_wchar( path, wpath ); - if ( !::CreateDirectory( wpath, NULL ) ) + if ( !::CreateDirectory( wpath, NULL ) && + !(ignore_exists && ::GetLastError() == ERROR_ALREADY_EXISTS) ) { throw fs::exception( "CreateDirectory()", path ); -#endif + } +#endif /* WIN32 */ +} + +void mkdir( char const *path, bool intermediate ) { + if ( !intermediate ) + mkdir_impl( path ); + else { + string const dir( dir_name( path ) ); + if ( dir != path ) + mkdir( dir, true ); + else + mkdir_impl( dir.c_str(), true ); + mkdir_impl( path, true ); + } } string normalize_path( char const *path, char const *base ) {
-- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp