1:- module(canny_files, [absolute_directory/2]).
Fails if Absolute is not an absolute file name, according to is_absolute_file_name/2. Works correctly for Unix and Windows paths. However, it finally unifies with the drive letter under Windows, and the root directory (/) on Unix.
20absolute_directory(Absolute, Directory) :- 21 is_absolute_file_name_or_root(Absolute), 22 absolute_directory_(Absolute, Directory). 23 24absolute_directory_(Absolute, Absolute). 25absolute_directory_(Absolute, Directory) :- 26 file_directory_name_unless_root(Absolute, Directory_), 27 absolute_directory(Directory_, Directory). 28 29is_absolute_file_name_or_root(/) :- !. 30is_absolute_file_name_or_root(File) :- is_absolute_file_name(File). 31 32file_directory_name_unless_root(/, _Directory) :- !, fail. 33file_directory_name_unless_root(File, Directory) :- 34 file_directory_name(File, Directory)