{= # # # get_defined_directory.cfv # # This checks if the defined pathname is valid. # It returns the root directories and the tree structure of a valid pathname. # Subdirectories are loaded sequentially from the client side. # # include "templates.util.base_util"; include "templates.util.encoding"; include "templates.util.rbac.rbac_util"; include "templates.file_manager.file_manager_util"; debug_message("\n#### get_defined_directory.cfv \n"); string session_id = volatile.session_id; bool is_file_manager_permission = get_is_file_manager_permission(); string page_token = v.fp.page_token; if (is_file_manager_permission and get_is_valid_page_token(session_id, "file_manager", page_token)) then ( # # # Check and get pathname in local code page (try to rewind pathname if default is not valid) # # bool is_root_directory_items; string pathname_in_utf_8 = v.fp.pathname; pathname_in_utf_8 = replace_all(pathname_in_utf_8, "__HexEsc__5C", "\\"); string pathname_in_local_code_page = get_valid_predefined_pathname_in_local_code_page(pathname_in_utf_8); # Note, is_valid_pathname may be true if only a part of the full pathanme is valid, the invalid part # is simply dropped. bool is_valid_pathname = (pathname_in_local_code_page ne ""); debug_message("#### pathname_in_local_code_page: " . pathname_in_local_code_page . "\n"); debug_message("#### is_valid_pathname: " . is_valid_pathname . "\n"); # # Handle UNC pathname # unc_pathname_in_local_code_page is becomes only defined if the user entered a valid UNC path and when # the root items are assembled. This makes sure that the UNC path (\\SERVERNAME\SHARENAME, i.e. \\pub\pub) becomes # displayed in the left pane of the File Manager in case that it isn't returned by get_directory_contents(). # string unc_pathname_in_local_code_page = ""; if (is_valid_pathname and (_PLATFORM eq "Windows") and starts_with(pathname_in_local_code_page, "\\\\")) then ( unc_pathname_in_local_code_page = pathname_in_local_code_page; ); debug_message("#### unc_pathname_in_local_code_page: " . unc_pathname_in_local_code_page . "\n"); # # # Get root directories (only define unc_pathname_in_local_code_page) # # node n = get_directory_contents_by_type("", unc_pathname_in_local_code_page); node directories = n{"directories"}; # node files = n{"files"}; # Root files are ignored debug_message("#### directories:\n" . node_as_string(directories) . "\n"); int number_directories = num_subnodes(directories); string directories_dat = get_directories_dat(directories, number_directories); # # Get the tree structure # string tree_structure_dat; if (is_valid_pathname) then ( tree_structure_dat = get_pathname_tree_structure_dat(pathname_in_local_code_page); ) else ( tree_structure_dat = "[]"; ); # # # Send response # # string dat = "{"; dat .= add_json("isValidPathname", is_valid_pathname, "bool"); dat .= add_json("nDir", number_directories, "int"); dat .= add_json("dirs", directories_dat, "obj"); dat .= add_json("defaultPathnameStructure", tree_structure_dat, "obj"); dat = close_json(dat); 'fileManager.getDefinedDirectoryResponse(' . dat . ')\n'; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}