2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
24 //%% (c) Copyright 1993, 1994 International Business Machines Corp.
25 //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 //%% (c) Copyright 1993, 1994 Novell, Inc.
27 //%% $XConsortium: tt_db_network_path.C /main/3 1995/10/23 10:03:29 rswiston $
29 * tt_db_network_path.cc - Defines a function that takes a local
30 * path and returns the real local path, hostname, partition
31 * and real remote path of the file. The partition and real
32 * remote path are for the file on its native host.
34 * Copyright (c) 1990 by Sun Microsystems, Inc.
36 * Implementation for filepath utility functions
40 #include "util/tt_path.h"
41 #include "util/tt_file_system.h"
42 #include "util/tt_file_system_entry.h"
43 #include "db/tt_db_hostname_global_map_ref.h"
45 _Tt_db_results _tt_db_network_path (const _Tt_string &path,
46 _Tt_string &local_path,
48 _Tt_string &partition,
49 _Tt_string &network_path)
51 _Tt_db_results results = TT_DB_OK;
54 if (_tt_is_network_path(path)) {
55 local_path = _tt_network_path_to_local_path(path);
57 local_path = _tt_realpath(path);
60 _Tt_file_system file_system;
61 _Tt_file_system_entry_ptr file_system_entry =
62 file_system.bestMatchToPath(local_path);
64 hostname = file_system_entry->getHostname();
66 if (file_system_entry->isLocal()) {
67 partition = file_system_entry->getMountPoint();
69 _Tt_string loop_back_mount_point =
70 file_system_entry->getLoopBackMountPoint();
72 if (loop_back_mount_point.len ()) {
73 // Get the path info after the mount point path
74 local_path = local_path.right(local_path.len() -
75 loop_back_mount_point.len());
77 // Replace the mount point path with
78 // the exported partition path.
79 if (partition != "/") {
80 local_path = loop_back_mount_point.cat(local_path);
83 network_path = hostname.cat(":").cat(local_path);
85 _Tt_db_hostname_global_map_ref map_ref;
86 _Tt_db_client_ptr database =
87 map_ref.getDB(hostname, hostname, results);
89 if (!database.is_null()) {
90 _Tt_string temp_string;
91 _Tt_string local_network_path;
93 if (_tt_is_network_path(path)) {
94 local_network_path = path;
97 _tt_local_network_path(path);
100 results = database->getFilePartition(local_network_path,
105 if ((results == TT_DB_ERR_DB_CONNECTION_FAILED) ||
106 (results == TT_DB_ERR_RPC_CONNECTION_FAILED) ||
107 (results == TT_DB_ERR_RPC_FAILED) ||
108 (results == TT_DB_ERR_DB_OPEN_FAILED)) {
109 map_ref.removeDB (hostname);