dba/files  library module
R

Summary

Change directory.
Authors
  • Christian Grün, BaseX Team 2005-23, BSD License
Related documents
ViewDescriptionFormat
xqdocxqDoc xml file from the source modulexml
xqparsexqparse xml file from the source modulexml

Imports

This module is imported by 0 modules. It imports 1 modules.

(None)
imports
dba/files
imports

Variables

3.1 $dba:CAT

Summary
Top category
Type
Source ( 1 lines)
variable $dba:CAT := 'files'

Functions

4.1 dba:dir-change

Arities: #1R

Summary
Changes the directory.
Signatures
dba:dir-change ( $dir as xs:string ) as element(rest:response)
Parameters
  • dir as xs:string directory
Return
  • element(rest:response) redirection
Invoked by 0 functions from 0 modules
    Annotations (2)
    %rest:path('/dba/dir-change')
    %rest:query-param('dir','{$dir}')
    Source ( 22 lines)
    function dba:dir-change(
      $dir  as xs:string
    ) as element(rest:response) {
      try {
        let $sep := file:dir-separator()
        let $path := file:path-to-native(if(contains($dir, $sep)) then (
          $dir
        ) else (
          config:directory() || $dir || $sep)
        )
        return (
          (: ensure that the directory can be accessed :)
          prof:void(file:list($path)),
      
          config:directory($path),
          config:query('')
        ),
        web:redirect($dba:CAT)
      } catch file:io-error {
        web:redirect($dba:CAT, map { 'error': $err:description })
      }
    }

    Namespaces

    The following namespaces are defined:

    PrefixUri
    configdba/config
    dbadba/files 2 3 4 5 6 7 8
    errhttp://www.w3.org/2005/xqt-errors
    filehttp://expath.org/ns/file
    profhttp://basex.org/modules/prof
    resthttp://exquery.org/ns/restxq
    webhttp://basex.org/modules/web
    xshttp://www.w3.org/2001/XMLSchema

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/dir-changedba:dir-change#1

    Source Code

    (:~
     : Change directory.
     :
     : @author Christian Grün, BaseX Team 2005-23, BSD License
     :)
    module namespace dba = 'dba/files';
    
    import module namespace config = 'dba/config' at '../lib/config.xqm';
    
    (:~ Top category :)
    declare variable $dba:CAT := 'files';
    
    (:~
     : Changes the directory.
     : @param  $dir  directory
     : @return redirection
     :)
    declare
      %rest:path('/dba/dir-change')
      %rest:query-param('dir', '{$dir}')
    function dba:dir-change(
      $dir  as xs:string
    ) as element(rest:response) {
      try {
        let $sep := file:dir-separator()
        let $path := file:path-to-native(if(contains($dir, $sep)) then (
          $dir
        ) else (
          config:directory() || $dir || $sep)
        )
        return (
          (: ensure that the directory can be accessed :)
          prof:void(file:list($path)),
      
          config:directory($path),
          config:query('')
        ),
        web:redirect($dba:CAT)
      } catch file:io-error {
        web:redirect($dba:CAT, map { 'error': $err:description })
      }
    };