summary refs log tree commit diff
path: root/src/path.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@gmail.com>2021-03-11 20:15:47 -0800
committerIrene Knapp <ireneista@gmail.com>2021-03-11 20:15:47 -0800
commit86990efcf8fa63decb05f462d745b95e4992dc77 (patch)
tree46990fd1c749ccca0b6477650973d83174e5e264 /src/path.rs
parenta159d4dd29491a1eb88163e63ceb41a903dc47b6 (diff)
refactor everything into smaller modules; move to using async-std; make the read loop async. some stuff doesn't work yet but it needed to be done and this is as clean a state as it's likely to get in, so we're committing it as a base to build on.
Diffstat (limited to 'src/path.rs')
-rw-r--r--src/path.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/path.rs b/src/path.rs
index 570b8ef..7df10b2 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -6,14 +6,15 @@
  * to get the benefit of its functionality for handling non-Unicode filenames.
  */
 
-use crate::prelude::*;
-use crate::path::error::*;
+#![forbid(unsafe_code)]
+use crate::path::prelude::*;
 
 use std::str::FromStr;
 
 
 lalrpop_mod!(pub parser, "/path/parser.rs");
 pub mod error;
+pub mod prelude;
 
 
 #[derive(Clone,Debug,Eq,Hash,Ord,PartialEq,PartialOrd)]
@@ -230,10 +231,10 @@ pub fn parse_path_list(path_list: &str)
         .parse(path_list)
       {
         Ok(_) => {
-          Err(Error::PathListHasEmptyComponents(path_list.to_string()))
+          Err(PathError::PathListHasEmptyComponents(path_list.to_string()))
         },
         Err(_) => {
-          Err(Error::Parse(original_error.to_string()))
+          Err(PathError::Parse(original_error.to_string()))
         },
       }
     },
@@ -245,7 +246,7 @@ pub fn absolute_directory_path(generic_path: GenericPath)
   -> Result<AbsoluteDirectoryPath>
 {
   if !generic_path.starts_with_slash {
-    return Err(Error::PathLexicallyRelative(generic_path));
+    return Err(PathError::PathLexicallyRelative(generic_path));
   }
 
   let mut flattened_components = Vec::new();
@@ -256,7 +257,7 @@ pub fn absolute_directory_path(generic_path: GenericPath)
         if flattened_components.len() > 0 {
           flattened_components.pop();
         } else {
-          return Err(Error::PathLexicallyInvalid(generic_path));
+          return Err(PathError::PathLexicallyInvalid(generic_path));
         }
       },
       GenericPathComponent::FileOrDirectoryName(name) => {
@@ -275,11 +276,11 @@ pub fn absolute_file_path(generic_path: GenericPath)
   -> Result<AbsoluteFilePath>
 {
   if !generic_path.starts_with_slash {
-    return Err(Error::PathLexicallyRelative(generic_path));
+    return Err(PathError::PathLexicallyRelative(generic_path));
   }
 
   if generic_path.ends_with_slash {
-    return Err(Error::PathLexicallyDirectory(generic_path));
+    return Err(PathError::PathLexicallyDirectory(generic_path));
   }
 
   let mut iterator = generic_path.components.iter();
@@ -289,7 +290,7 @@ pub fn absolute_file_path(generic_path: GenericPath)
       FileName(name.to_string())
     }
     _ => {
-      return Err(Error::PathLexicallyInvalid(generic_path));
+      return Err(PathError::PathLexicallyInvalid(generic_path));
     }
   };
 
@@ -301,7 +302,7 @@ pub fn absolute_file_path(generic_path: GenericPath)
         if flattened_components.len() > 0 {
           flattened_components.pop();
         } else {
-          return Err(Error::PathLexicallyInvalid(generic_path));
+          return Err(PathError::PathLexicallyInvalid(generic_path));
         }
       },
       GenericPathComponent::FileOrDirectoryName(name) => {