Skip to content

Commit

Permalink
Fix file list for root directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pford committed Dec 6, 2024
1 parent 8d13764 commit ecfe720
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Util/Casacore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ecfe720

Please sign in to comment.