Exemple #1
0
        private static void AppendDirectoryName(MutableString /*!*/ result, MutableString /*!*/ name)
        {
            int resultLength = result.GetCharCount();

            int i;

            for (i = resultLength - 1; i >= 0; i--)
            {
                if (!IsDirectorySeparator(result.GetChar(i)))
                {
                    break;
                }
            }

            if (i == resultLength - 1)
            {
                if (!IsDirectorySeparator(name.GetFirstChar()))
                {
                    result.Append(DirectorySeparatorChar);
                }
                result.Append(name);
            }
            else if (IsDirectorySeparator(name.GetFirstChar()))
            {
                result.Replace(i + 1, resultLength - i - 1, name);
            }
            else
            {
                result.Append(name);
            }
        }
Exemple #2
0
 public static MutableString /*!*/ ExpandPath(RubyContext /*!*/ context, RubyClass /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ path,
                                              [DefaultProtocol, Optional] MutableString basePath)
 {
     // We ignore basePath parameter if first string starts with a ~
     if (basePath == null || path.GetFirstChar() == '~')
     {
         return(ExpandPath(context, path));
     }
     else
     {
         return(Glob.CanonicalizePath(MutableString.Create(
                                          Path.GetFullPath(Path.Combine(ExpandPath(context, basePath).ConvertToString(), path.ConvertToString()))
                                          )));
     }
 }