diff --git a/src/Util/Casacore.cc b/src/Util/Casacore.cc index 4699f7fdc..fdacd46d5 100644 --- a/src/Util/Casacore.cc +++ b/src/Util/Casacore.cc @@ -103,34 +103,41 @@ casacore::String GetResolvedFilename(const string& root_dir, const string& direc // (absolute pathname with symlinks resolved) casacore::String resolved_filename; casacore::Path path(root_dir); - path.append(directory); - casacore::File cc_directory(path); + if (directory != ".") { + path.append(directory); + } + casacore::File cc_file(path); - if (!cc_directory.exists()) { + // Check directory for error messages + if (!cc_file.exists()) { message = "Directory " + directory + " does not exist."; - } else if (!cc_directory.isReadable()) { + } else if (!cc_file.isReadable()) { message = "Directory " + directory + " is not readable."; } else { + // Check file path.append(file); - casacore::File cc_file(path); - + cc_file = casacore::File(path); if (!cc_file.exists()) { message = "File " + file + " does not exist."; } else if (!cc_file.isReadable()) { message = "File " + file + " is not readable."; } else { try { - resolved_filename = cc_file.path().resolvedName(); + resolved_filename = path.resolvedName(); } catch (const casacore::AipsError& err) { try { - resolved_filename = cc_file.path().absoluteName(); + resolved_filename = path.absoluteName(); + // Workaround for casacore parsing bug when path is "/" + if (resolved_filename.empty()) { + resolved_filename = path.originalName(); + } } catch (const casacore::AipsError& err) { - // return empty string message = "Cannot resolve file path."; } } } } + return resolved_filename; }