1:- module(canny_files, [absolute_directory/2]).
 absolute_directory(+Absolute, -Directory) is nondet
Finds the directories of Absolute by walking up the absolute path until it reaches the root. Operates on paths only; it does not check that Absolute actually exists. Absolute can be a directory or file path.

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.

Arguments:
Absolute- specifies an absolute path name. On Windows it must typically include a driver letter, else not absolute in the complete sense under Microsoft Windows since its file system supports multiple root directories on different mounted drives.
   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)