ADDED: path_segments/2 for portable reasoning about path components.

The platform-specific directory separator is taken into account.
The clean representation of segments as a list simplifies reasoning.
This commit is contained in:
Markus Triska
2020-07-19 11:07:03 +02:00
parent bd0aa16322
commit 2768beec4c
3 changed files with 62 additions and 0 deletions

View File

@@ -175,6 +175,7 @@ pub enum SystemClauseType {
FileSize,
FileExists,
DirectoryExists,
DirectorySeparator,
MakeDirectory,
DeleteFile,
WorkingDirectory,
@@ -344,6 +345,7 @@ impl SystemClauseType {
&SystemClauseType::FileSize => clause_name!("$file_size"),
&SystemClauseType::FileExists => clause_name!("$file_exists"),
&SystemClauseType::DirectoryExists => clause_name!("$directory_exists"),
&SystemClauseType::DirectorySeparator => clause_name!("$directory_separator"),
&SystemClauseType::MakeDirectory => clause_name!("$make_directory"),
&SystemClauseType::DeleteFile => clause_name!("$delete_file"),
&SystemClauseType::WorkingDirectory => clause_name!("$working_directory"),
@@ -682,6 +684,7 @@ impl SystemClauseType {
("$file_size", 2) => Some(SystemClauseType::FileSize),
("$file_exists", 1) => Some(SystemClauseType::FileExists),
("$directory_exists", 1) => Some(SystemClauseType::DirectoryExists),
("$directory_separator", 1) => Some(SystemClauseType::DirectorySeparator),
("$make_directory", 1) => Some(SystemClauseType::MakeDirectory),
("$delete_file", 1) => Some(SystemClauseType::DeleteFile),
("$working_directory", 2) => Some(SystemClauseType::WorkingDirectory),